Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

URL filter  RSS feed

 
nkarthi123
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i done logout operation.but url is copy to browser the page go.pleases anybody help this?
 
Mourouganandame Arunachalam
Ranch Hand
Posts: 398
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean?
 
Marius Snyman
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Harihara Sudhan:
i done logout operation.but url is copy to browser the page go.pleases anybody help this?


Here is a suggestion:
1. Create a class that implements PhaseListener
2. In the beforephase method validate which pages may be seen.
3. Also determine whether a use object exists.
4. If the client is visiting a page that requires a login reroutes the client to the login or a session expired page.

Example:
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;
}
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!