List of usage examples for javax.servlet.http HttpSession getMaxInactiveInterval
public int getMaxInactiveInterval();
From source file:org.yawlfoundation.yawl.resourcing.jsf.SessionBean.java
public void resetSessionTimeout() { HttpSession session = getExternalSession(); if (defaultSessionTimeoutValue != session.getMaxInactiveInterval()) { session.setMaxInactiveInterval(defaultSessionTimeoutValue); }//from w ww. j a v a 2 s . c om }
From source file:dk.itst.oiosaml.sp.service.SAMLAssertionConsumerHandler.java
private void handleSAMLResponse(RequestContext ctx, OIOResponse response) throws IOException, ServletException { Audit.log(Operation.AUTHNREQUEST_SEND, false, response.getInResponseTo(), response.toXML()); HttpSession session = ctx.getSession(); if (log.isDebugEnabled()) { log.debug("Calling URL.:" + ctx.getRequest().getRequestURI() + "?" + ctx.getRequest().getQueryString()); log.debug("SessionId..:" + session.getId()); }/*from w w w. java 2 s . c o m*/ RelayState relayState = RelayState.fromRequest(ctx.getRequest()); if (log.isDebugEnabled()) log.debug("Got relayState..:" + relayState); String idpEntityId = response.getOriginatingIdpEntityId(ctx.getSessionHandler()); if (log.isDebugEnabled()) log.debug("Received SAML Response from " + idpEntityId + ": " + response.toXML()); boolean allowPassive = ctx.getConfiguration().getBoolean(Constants.PROP_PASSIVE, false); Metadata metadata = ctx.getIdpMetadata().getMetadata(idpEntityId); response.decryptAssertion(ctx.getCredential(), !ctx.getConfiguration().getBoolean(Constants.PROP_REQUIRE_ENCRYPTION, false)); response.validateResponse(ctx.getSpMetadata().getAssertionConsumerServiceLocation(0), metadata.getCertificates(), allowPassive); if (allowPassive && response.isPassive()) { log.debug("Received passive response, setting passive userassertion"); Assertion assertion = SAMLUtil.buildXMLObject(Assertion.class); assertion.setID("" + System.currentTimeMillis()); ctx.getSessionHandler().setAssertion(session.getId(), new OIOAssertion(assertion)); PassiveUserAssertion passiveUserAssertion = new PassiveUserAssertion( ctx.getConfiguration().getString(Constants.PROP_PASSIVE_USER_ID)); session.setAttribute(Constants.SESSION_USER_ASSERTION, passiveUserAssertion); Audit.log(Operation.LOGIN, passiveUserAssertion.getSubject()); } else { OIOAssertion assertion = response.getAssertion(); assertion.validateAssertion(validator, ctx.getSpMetadata().getEntityID(), ctx.getSpMetadata().getAssertionConsumerServiceLocation(0)); UserAssertion userAssertion = new UserAssertionImpl(assertion); if (!invokeAuthenticationHandler(ctx, userAssertion)) { Audit.logError(Operation.LOGIN, false, response.getInResponseTo(), "Authentication handler stopped authentication"); log.error("Authentication handler stopped authentication"); return; } Audit.setAssertionId(assertion.getID()); Audit.log(Operation.LOGIN, assertion.getSubjectNameIDValue() + "/" + assertion.getAssuranceLevel() + " via " + assertion.getIssuer()); Audit.log(Operation.LOGIN_SESSION, Integer.toString(session.getMaxInactiveInterval())); // Store the assertion in the session store // release the DOM tree now the signature is validated - due to large memory consumption Assertion assertion2 = assertion.getAssertion(); assertion2.releaseChildrenDOM(true); assertion2.releaseDOM(); assertion2.detach(); ctx.getSessionHandler().setAssertion(session.getId(), assertion); session.setAttribute(Constants.SESSION_USER_ASSERTION, userAssertion); } if (relayState.getRelayState() != null) { HTTPUtils.sendResponse(ctx.getSessionHandler().getRequest(relayState.getRelayState()), ctx); } else { HTTPUtils.sendResponse(null, ctx); } }
From source file:org.jahia.ajax.gwt.content.server.JahiaContentManagementServiceImpl.java
@Override public SessionValidationResult isValidSession() throws GWTJahiaServiceException { // >0 : schedule poll repeating for this value // 0 : session expire // <0 : polling deactivated final String loginUrl = getLogingUrl(); final HttpSession session = getRequest().getSession(false); if (session != null) { Long date = (Long) session.getAttribute("lastPoll"); long lastAccessed = session.getLastAccessedTime(); long now = System.currentTimeMillis(); boolean invalidated = false; if (date != null && (date / 1000 == lastAccessed / 1000)) { // last call was (probably) a poll call long first = (Long) session.getAttribute("firstPoll"); if (logger.isDebugEnabled()) { logger.debug("Inactive since : " + (now - first)); }/*from ww w . j a va 2 s. com*/ if (now - first < session.getMaxInactiveInterval() * 1000) { session.setMaxInactiveInterval(session.getMaxInactiveInterval() - (int) ((now - first) / 1000)); } else { session.invalidate(); invalidated = true; } } else { session.setAttribute("firstPoll", now); } if (!invalidated) { session.setAttribute("lastPoll", now); } return new SessionValidationResult(loginUrl, sessionPollingFrequency); } else { return new SessionValidationResult(loginUrl, 0); } }