List of usage examples for org.apache.shiro.session ExpiredSessionException ExpiredSessionException
public ExpiredSessionException(Throwable cause)
From source file:com.caricah.iotracah.bootstrap.security.realm.state.IOTClient.java
License:Apache License
public void validate() throws InvalidSessionException { //check for stopped: if (getIsActive() && isStopped()) { //timestamp is set, so the session is considered stopped: String msg = "Session with id [" + getId() + "] has been " + "explicitly stopped. No further interaction under this session is " + "allowed."; throw new StoppedSessionException(msg); }/*from w w w.j ava2s . c o m*/ //check for expiration if (getIsActive() && isTimedOut()) { expire(); //throw an exception explaining details of why it expired: Date lastAccessTime = getLastAccessTime(); long timeout = getTimeout(); Serializable sessionId = getId(); DateFormat df = DateFormat.getInstance(); String msg = "Session with id [" + sessionId + "] has expired. " + "Last access time: " + df.format(lastAccessTime) + ". Current time: " + df.format(new Date()) + ". Session timeout is set to " + timeout + " seconds (" + (timeout * 1d) / 60 + " minutes)"; if (log.isTraceEnabled()) { log.trace(msg); } throw new ExpiredSessionException(msg); } }
From source file:controllers.acentera.Admin.java
License:Open Source License
@With(AnonymousSecurityController.class) public static Result index() { if (request().cookie(SecurityController.AUTH_TOKEN) != null) { Logger.debug("APPLICATION RETURN INDEX -> " + Play.application().configuration().getString("application.env")); //Still need to have a subject try {/*from w w w. j a v a2s. c om*/ Subject s = SecurityController.getSubject(); Session ss = SecurityController.getSession(); Logger.debug("Principal is : " + s.getPrincipal()); if (ss == null || s.getPrincipal() == null) { throw new ExpiredSessionException("Expired"); } Logger.debug("AuthtneicateD ? " + s.isAuthenticated()); } catch (Exception error) { //In case we have other exceptions error.printStackTrace(); Logger.debug(" REDIRECT FROM INDEX() TO /login and force logout..."); SecurityController.logout(ctx()); return redirect("/"); } return ok(index.render("ACenterA Cloud", 1, Play.application().configuration().getString("application.env"), "admin")); } else { return ok(login.render("login", "")); } }
From source file:controllers.acentera.Admin.java
License:Open Source License
@With(SecurityController.class) public static Result indexWithPath(String path) { String[] t = request().headers().get("referer"); String host = request().getHeader("Host"); response().setHeader("PRAGMA", "no-cache"); response().setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); response().setHeader("EXPIRES", "Sat, 16-Mar-2000 01:11:11 GMT"); try {// ww w . ja v a 2s . c om Subject s = SecurityController.getSubject(); Session ss = SecurityController.getSession(); Logger.debug("With Security Principal is : " + s.getPrincipal()); if (ss == null || s.getPrincipal() == null) { throw new ExpiredSessionException("Expired"); } Logger.debug("AuthtneicateD ? " + s.isAuthenticated()); } catch (Exception error) { //In case we have other exceptions error.printStackTrace(); Logger.debug(" REDIRECT FROM INDEXWITHPATH() TO /login and force logout..."); SecurityController.logout(ctx()); return redirect("/"); } if ((t != null) && (t.length > 0)) { String referer = t[0]; response().setHeader("REDIRECT", ""); return ok(index.render("ACenterA Cloud", 1, Play.application().configuration().getString("application.env"), "admin")); } else { response().setHeader("REDIRECT", ""); return redirect("/admin/#" + request().path()); } }
From source file:controllers.acentera.Application.java
License:Open Source License
@With(AnonymousSecurityController.class) public static Result index() { if (request().cookie(SecurityController.AUTH_TOKEN) != null) { Logger.debug("APPLICATION RETURN INDEX -> " + play.Play.application().configuration().getString("application.env")); //Still need to have a subject try {/*from w ww. j ava 2 s. com*/ Subject s = SecurityController.getSubject(); Session ss = SecurityController.getSession(); Logger.debug("Principal is : " + s.getPrincipal()); if (ss == null || s.getPrincipal() == null) { throw new ExpiredSessionException("Expired"); } Logger.debug("AuthtneicateD ? " + s.isAuthenticated()); } catch (Exception error) { //In case we have other exceptions error.printStackTrace(); SecurityController.logout(ctx()); Logger.debug(" REDIRECT FROM APPlication.INDEX() TO /login and force logout..."); return redirect("/"); } return ok(index.render("ACenterA Cloud", 1, play.Play.application().configuration().getString("application.env"), "user")); } else { return ok(login.render("login", "")); } }
From source file:controllers.acentera.Application.java
License:Open Source License
@With(SecurityController.class) public static Result indexWithPath(String path) { String[] t = request().headers().get("referer"); String host = request().getHeader("Host"); response().setHeader("PRAGMA", "no-cache"); response().setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); response().setHeader("EXPIRES", "Sat, 16-Mar-2000 01:11:11 GMT"); try {//from w ww. j a va2 s . c o m Subject s = SecurityController.getSubject(); Session ss = SecurityController.getSession(); Logger.debug("With Security Principal is : " + s.getPrincipal()); if (ss == null || s.getPrincipal() == null) { throw new ExpiredSessionException("Expired"); } Logger.debug("AuthtneicateD ? " + s.isAuthenticated()); } catch (Exception error) { //In case we have other exceptions error.printStackTrace(); Logger.debug(" REDIRECT FROM APPlication.IndexWithPath() TO /login and force logout..."); SecurityController.logout(ctx()); return redirect("/"); } if ((t != null) && (t.length > 0)) { String referer = t[0]; response().setHeader("REDIRECT", ""); return ok(index.render("ACenterA Cloud", 1, play.Play.application().configuration().getString("application.env"), "user")); } else { response().setHeader("REDIRECT", ""); return redirect("/#" + request().path()); } }
From source file:org.tolven.session.DefaultTolvenSession.java
License:Open Source License
@Override public void validate() throws InvalidSessionException { //check for stopped: if (isStopped()) { //timestamp is set, so the session is considered stopped: String msg = "Session with id [" + getId() + "] has been " + "explicitly stopped. No further interaction under this session is " + "allowed."; throw new StoppedSessionException(msg); }/*from ww w .ja va2 s . c o m*/ //check for expiration if (isTimedOut()) { expire(); //throw an exception explaining details of why it expired: Date lastAccessTime = getLastAccessTime(); long timeout = getTimeout(); Serializable sessionId = getId(); DateFormat df = DateFormat.getInstance(); String msg = "Session with id [" + sessionId + "] has expired. " + "Last access time: " + df.format(lastAccessTime) + ". Current time: " + df.format(new Date()) + ". Session timeout is set to " + timeout / MILLIS_PER_SECOND + " seconds (" + timeout / MILLIS_PER_MINUTE + " minutes)"; throw new ExpiredSessionException(msg); } }