Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

url filter problem

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i work with following code but error can occur.so please help me step-by-step process for this by using visual jsf in netbeans 6.1


public class LoggedOnPhaseListener implements PhaseListener {

private static final long serialVersionUID = 7805022367671101424L;
private static final Log logger = LogFactory.getLog(LoggedOnPhaseListener.class);

public LoggedOnPhaseListener() {
logger.info("LoggedOnPhaseListener created");
}

@Override
public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}

@Override
public void beforePhase(PhaseEvent ev) {

boolean expire = false;
FacesContext facesContext = ev.getFacesContext();

// We going to the logon page or the expire page
boolean loginPage = facesContext.getViewRoot().getViewId().lastIndexOf("login") > -1 ? true : false;
boolean forgottenPasswordPage = facesContext.getViewRoot().getViewId().lastIndexOf("forgottenPassword") > -1 ? true : false;
boolean forgottenUsernamePage = facesContext.getViewRoot().getViewId().lastIndexOf("forgottenUsername") > -1 ? true : false;
boolean adminReactivationPage = facesContext.getViewRoot().getViewId().lastIndexOf("adminReactivation") > -1 ? true : false;
boolean expirePage = facesContext.getViewRoot().getViewId().lastIndexOf("sessionExpire") > -1 ? true : false;

if (!loginPage && !expirePage && !forgottenPasswordPage && !forgottenUsernamePage && !adminReactivationPage && !loggedIn(facesContext)) {
expire = true;
}

if (expire) {
logger.info("user session is not valid... logging out");
facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, "sessionExpired");
}

}

@Override
public void afterPhase(PhaseEvent ev) {
}

private boolean loggedIn(FacesContext facesContext) {
boolean result = true;
Map<String, Object> smap = facesContext.getExternalContext().getSessionMap();
if (smap.containsKey("loggedOnDetails")) {
LoggedOnDetails details = (LoggedOnDetails) smap.get("loggedOnDetails");
if (details.getUserDTO() == null) {
result = false;
}
} else {
result = false;
}
return result;
}
}
reply
    Bookmark Topic Watch Topic
  • New Topic