Example usage for javax.servlet.http HttpSession setMaxInactiveInterval

List of usage examples for javax.servlet.http HttpSession setMaxInactiveInterval

Introduction

In this page you can find the example usage for javax.servlet.http HttpSession setMaxInactiveInterval.

Prototype

public void setMaxInactiveInterval(int interval);

Source Link

Document

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.

Usage

From source file:org.n52.v3d.terrainserver.povraywts.WebTerrainServlet.java

private WTSSession setUpSession(WTSSession pWtsSession, boolean pCacheScene, HttpServletRequest pRequest,
        VgEnvelope pBBox, String pDrape, String pWmsLayers) {
    HttpSession lSession;
    TempFileHandler lRequTmpMngr;/*w  ww  . j av a  2  s  . c  o m*/
    TempFileHandler lSessionTmpMngr = null;

    if (pCacheScene) {
        lSession = pRequest.getSession(true);
        if (lSession == null)
            throw new T3dException("Could not get session object...", 102);

        lRequTmpMngr = new TempFileHandler();

        if (lSession.isNew()) {
            lSession.setMaxInactiveInterval(mSessionMaxInactiveInterval);
            lSessionTmpMngr = new TempFileHandler();
            lSession.setAttribute("shndlr_" + lSession.getId(), lSessionTmpMngr);
        } else {
            lSessionTmpMngr = (TempFileHandler) lSession.getAttribute("shndlr_" + lSession.getId());
            if (lSessionTmpMngr == null) {
                // Session nicht neu, aber lTmpMngr nicht in Session, Fall tritt z. B. in JSP-Client auf.
                lSessionTmpMngr = new TempFileHandler();
                lSession.setAttribute("shndlr_" + lSession.getId(), lSessionTmpMngr);
            } else {
                // Parameterwerte der letzten Anfrage holen...
                VgEnvelope oldBBox = (VgEnvelope) lSession.getAttribute("rqBBOX_" + lSession.getId()); // BBOX
                String oldDrape = (String) lSession.getAttribute("rqDRAPE_" + lSession.getId()); // DRAPE
                String oldWmsLayers = (String) lSession.getAttribute("rqWMSLAYERS_" + lSession.getId()); // WMSLAYERS
                boolean changesBBox = false, changesDrp = false;
                // BBOX seit letzter Anfrage gendert?
                if (oldBBox != null && !oldBBox.isSpatiallyEquivalent(pBBox))
                    changesBBox = true;
                // DRAPE seit letzter Anfrage gendert?
                if (oldDrape != null && oldDrape.compareTo(pDrape) != 0)
                    changesDrp = true;
                // WMSLAYERS seit letzter Anfrage gendert?
                if (oldWmsLayers != null && oldWmsLayers.compareTo(pWmsLayers) != 0)
                    changesDrp = true;

                // ... und im Falle relevanter nderungen Cache-Inhalte leeren:
                if (changesBBox) {
                    lSession.removeAttribute("terrain_" + lSession.getId());
                    lSessionTmpMngr
                            .removeTempFile((String) lSession.getAttribute("demgif_" + lSession.getId()));
                    lSession.removeAttribute("demgif_" + lSession.getId());
                }
                if (changesDrp || changesBBox) {
                    lSessionTmpMngr.removeTempFile((String) lSession.getAttribute("drape_" + lSession.getId()));
                    lSession.removeAttribute("drape_" + lSession.getId());
                }
            }
            lSession.setAttribute("rqBBOX_" + lSession.getId(), pBBox); // BBOX in Session legen
            lSession.setAttribute("rqDRAPE_" + lSession.getId(), pDrape); // DRAPE in Session legen
            lSession.setAttribute("rqWMSLAYERS_" + lSession.getId(), pWmsLayers); // WMSLAYERS in Session legen
        }
    } else {
        // Fr CACHESCENE=false ggf. Objekte aus vorherigen Aufrufen mit CACHESCENE=true aus Session entfernen:
        lSession = pRequest.getSession(false);
        if (lSession != null) {
            lSession.removeAttribute("shndlr_" + lSession.getId());
            lSession.removeAttribute("terrain_" + lSession.getId());
            lSession.removeAttribute("drape_" + lSession.getId());
            lSession.removeAttribute("demgif_" + lSession.getId());
            lSession.invalidate();
        }
        lRequTmpMngr = new TempFileHandler();
    }
    pWtsSession.setHttpSession(lSession);
    pWtsSession.setRequTempFileHandler(lRequTmpMngr);
    pWtsSession.setSessionTempFileHandler(lSessionTmpMngr);
    return pWtsSession;
}

From source file:byps.http.HHttpServlet.java

protected HSession doCreateSession(final HttpServletRequest request) throws BException {
    // Create new JSESSIONID to support load balancing.
    // For newer clients, we do not rely on the JSESSIONID to identify the BYPS
    // session in incoming requests.
    // Otherwise two JSON connections in a browser window could not be
    // distinguished.
    // Older clients still need to reach their HSession by the JSESSIONID.
    HttpSession hsess = request.getSession(true);
    if (log.isDebugEnabled())
        log.debug("JSESSIONID=" + hsess.getId());

    // Assign a set of BYPS session objects to the app server's session.
    hsess.setAttribute(HConstants.HTTP_SESSION_BYPS_SESSIONS, new HHttpSessionObject());

    // Constrain the lifetime of the session to 10s. It is extended, if the
    // session gets authenticated.
    hsess.setMaxInactiveInterval(HConstants.MAX_INACTIVE_SECONDS_BEFORE_AUTHENTICATED);

    // Create new BYPS session
    final HTargetIdFactory targetIdFactory = getTargetIdFactory();
    final BTargetId targetId = targetIdFactory.createTargetId();
    final HSession sess = createSession(hsess, request.getRemoteUser());
    sess.setTargetId(targetId);/*from ww w .j  a va2 s .c om*/
    if (log.isDebugEnabled())
        log.debug("targetId=" + targetId);

    // Add session to session map
    final BHashMap<String, HSession> sessions = HSessionListener.getAllSessions();
    final String bsessionId = targetId.toSessionId();
    sessions.put(bsessionId, sess);

    // Add BRemote for utility requests.
    addUtilityRequestsInterface(sess);
    return sess;
}

From source file:com.adito.security.DefaultLogonController.java

public void resetSessionTimeout(User user, PropertyProfile profile, HttpSession session) {
    try {//from www. j a v a  2s.c o  m
        Map sessionTimeoutBlocks = (Map) session.getAttribute(Constants.SESSION_TIMEOUT_BLOCKS);
        int minutes = 0;
        if (sessionTimeoutBlocks == null || sessionTimeoutBlocks.size() == 0) {
            minutes = CoreUtil.getUsersProfilePropertyIntOrDefault(session,
                    "webServer.sessionInactivityTimeout", user);
        }
        if (log.isDebugEnabled())
            log.debug("Resetting timeout for session " + session.getId() + " to " + minutes + " minutes");
        session.setMaxInactiveInterval(minutes == 0 ? -1 : minutes * 60);
    } catch (Exception e) {
        log.error("Failed to reset session timeout.", e);
    }
}

From source file:com.adito.security.DefaultLogonController.java

private synchronized void moveSessionTimeoutBlocks(HttpSession oldSession, HttpSession newSession) {
    Map sessionTimeoutBlocks = (Map) oldSession.getAttribute(Constants.SESSION_TIMEOUT_BLOCKS);
    if (sessionTimeoutBlocks != null) {
        newSession.setAttribute(Constants.SESSION_TIMEOUT_BLOCKS, sessionTimeoutBlocks);
    }/*www . j  a  v  a 2 s.c  o  m*/
    Integer vpnClientSessionTimeoutBlockId = (Integer) oldSession
            .getAttribute(Constants.AGENT_SESSION_TIMEOUT_BLOCK_ID);
    if (vpnClientSessionTimeoutBlockId != null) {
        newSession.setAttribute(Constants.AGENT_SESSION_TIMEOUT_BLOCK_ID, vpnClientSessionTimeoutBlockId);
    }
    newSession.setMaxInactiveInterval(sessionTimeoutBlocks == null || sessionTimeoutBlocks.size() == 0
            ? oldSession.getMaxInactiveInterval()
            : -1);
}

From source file:cn.ccrise.spimp.web.LoginController.java

@RequestMapping(value = "/auth", method = RequestMethod.POST)
@ResponseBody/*from  ww  w  .  j a  va 2 s  . c om*/
public Response auth(String principal, String credential, HttpSession httpSession,
        HttpServletRequest httpServletRequest) {
    // ????
    boolean isPrincipalBlank = StringUtils.isBlank(principal);
    boolean isCredentialBlank = StringUtils.isBlank(credential);
    Map<String, String> errors = Maps.newHashMap();
    if (isPrincipalBlank) {
        errors.put("principal", PRINCIPAL_BLANK);
    }
    if (isCredentialBlank) {
        errors.put("credential", CREDENTIAL_BLANK);
    }

    // ?
    String license = PropertiesUtils.getString("app.license");
    if (Strings.isNullOrEmpty(license)) {
        errors.put("message", UNRFGISTERED);
        return new Response(errors);
    }
    Date expireDay = null;
    try {
        expireDay = new SimpleDateFormat("yyyy-MM-dd").parse(AES.decodeAes128(KEY, license));
    } catch (ParseException e) {
        errors.put("message", UNRFGISTERED);
        return new Response(errors);
    }
    if (expireDay.before(new Date())) {
        errors.put("message", EXPIRE);
        return new Response(errors);
    }

    // ????
    if (!isPrincipalBlank && !isCredentialBlank) {
        if (accountService.auth(principal, credential)) {
            // ?session
            Account loginAccount = accountService.get(principal);

            // ??
            if (loginAccount.isLocked()) {
                errors.put("message", PRINCIPAL_LOCKED);
            } else {
                httpSession.setAttribute(PropertiesUtils.getString(PropertiesUtils.SESSION_KEY_PROPERTY),
                        loginAccount);
                httpSession.setMaxInactiveInterval(MAX_INACTIVE_INTERVAL);

                // 
                logEntityServiceImpl.info(LogEntityServiceImpl.DEFAULT_USER_NAME,
                        "[" + principal + "]", httpServletRequest.getRemoteAddr());
            }
        } else {
            errors.put("message", PRINCIPAL_OR_CREDENTIAL_WRONG);

            // 
            logEntityServiceImpl.info(LogEntityServiceImpl.DEFAULT_USER_NAME,
                    "[" + principal + "]??", httpServletRequest.getRemoteAddr());
        }
    }

    return new Response(errors);
}

From source file:org.jahia.bin.Render.java

public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception {
    if (isDisabled()) {
        resp.sendError(HttpServletResponse.SC_NOT_FOUND);
        return null;
    }//from   w  w w . j  av a  2s  .  co  m
    String method = req.getMethod();
    if (req.getParameter(METHOD_TO_CALL) != null) {
        method = req.getParameter(METHOD_TO_CALL).toUpperCase();
    }
    if (!isMethodAllowed(method)) {
        resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        return null;
    }
    long startTime = System.currentTimeMillis();
    String sessionId = null;
    try {
        final HttpSession session = req.getSession();
        if (logger.isInfoEnabled()) {
            sessionId = session.getId();
        }
        URLResolver urlResolver = urlResolverFactory.createURLResolver(req.getPathInfo(), req.getServerName(),
                workspace, req);

        req.setAttribute("urlResolver", urlResolver);

        session.setAttribute("workspace", urlResolver.getWorkspace());

        if (sessionExpiryTime != null && session.getMaxInactiveInterval() != sessionExpiryTime * 60) {
            session.setMaxInactiveInterval(sessionExpiryTime * 60);
        }

        RenderContext renderContext = createRenderContext(req, resp, jcrSessionFactory.getCurrentUser());
        renderContext.setWorkspace(urlResolver.getWorkspace());

        urlResolver.setRenderContext(renderContext);
        req.getSession().setAttribute(Constants.SESSION_LOCALE, urlResolver.getLocale());
        jcrSessionFactory.setCurrentLocale(urlResolver.getLocale());
        if (renderContext.isPreviewMode() && req.getParameter(ALIAS_USER) != null
                && !JahiaUserManagerService.isGuest(jcrSessionFactory.getCurrentUser())) {
            JahiaUserManagerService userManagerService = ServicesRegistry.getInstance()
                    .getJahiaUserManagerService();
            JCRUserNode userNode = userManagerService.lookupUser(req.getParameter(ALIAS_USER),
                    urlResolver.getSiteKey());
            if (userNode != null) {
                jcrSessionFactory.setCurrentAliasedUser(userNode.getJahiaUser());
            }
        }

        // check permission
        try {
            if (!hasAccess(urlResolver.getNode())) {
                if (JahiaUserManagerService.isGuest(jcrSessionFactory.getCurrentUser())) {
                    throw new JahiaUnauthorizedException();
                } else {
                    throw new JahiaForbiddenAccessException();
                }
            }
        } catch (PathNotFoundException e) {

        }

        renderContext.setSiteInfo(urlResolver.getSiteInfo());

        if (renderContext.isPreviewMode() && req.getParameter(PREVIEW_DATE) != null
                && !JahiaUserManagerService.isGuest(jcrSessionFactory.getCurrentUser())) {
            Calendar previewDate = Calendar.getInstance();
            previewDate.setTime(new Date(new Long(req.getParameter(PREVIEW_DATE))));
            jcrSessionFactory.setCurrentPreviewDate(previewDate);
        }
        if (method.equals(METHOD_GET)) {
            Resource resource;
            resource = urlResolver.getResource();
            if (!StringUtils.isEmpty(urlResolver.getRedirectUrl())
                    && (StringUtils.isEmpty(resource.getTemplate())
                            || StringUtils.equals(resource.getTemplate(), "default"))) {
                Map<String, List<String>> parameters = new HashMap<String, List<String>>();
                parameters.put(NEW_NODE_OUTPUT_FORMAT, LIST_WITH_EMPTY_STRING);
                parameters.put(REDIRECT_HTTP_RESPONSE_CODE, REDIRECT_CODE_MOVED_PERMANENTLY);

                performRedirect(urlResolver.getRedirectUrl(),
                        StringUtils.isEmpty(urlResolver.getVanityUrl())
                                ? "/" + urlResolver.getLocale().toString() + urlResolver.getPath()
                                : urlResolver.getVanityUrl(),
                        req, resp, parameters, false);
            } else {
                renderContext.setMainResource(resource);
                if (renderContext.getSite() == null) {
                    // If Site has not been resolved by the servlet (so far only dashboard mode is doing that
                    JCRSiteNode site = resource.getNode().getResolveSite();
                    if (!Url.isLocalhost(req.getServerName()) && !renderContext.isEditMode()) {
                        JCRSessionWrapper session1 = resource.getNode().getSession();
                        if (urlResolver.getSiteKey() != null
                                && (site == null || !site.getSiteKey().equals(urlResolver.getSiteKey()))) {
                            site = (JCRSiteNode) session1.getNode("/sites/" + urlResolver.getSiteKey());
                        } else if (renderContext.isLiveMode() && urlResolver.getSiteKeyByServerName() != null
                                && (site == null
                                        || !site.getSiteKey().equals(urlResolver.getSiteKeyByServerName()))) {
                            site = (JCRSiteNode) session1
                                    .getNode("/sites/" + urlResolver.getSiteKeyByServerName());
                        }
                    }
                    String jsite = null;
                    HttpServletRequest request = renderContext.getRequest();
                    if (request != null) {
                        jsite = request.getParameter("jsite");
                    }
                    if (jsite == null && renderContext.getMainResource() != null) {
                        jsite = (String) renderContext.getMainResource().getModuleParams().get("jsite");
                    }
                    if (jsite != null) {
                        try {
                            site = (JCRSiteNode) resource.getNode().getSession().getNodeByIdentifier(jsite);
                        } catch (ItemNotFoundException e) {
                            if (JahiaUserManagerService.isGuest(jcrSessionFactory.getCurrentUser())) {
                                throw new JahiaUnauthorizedException();
                            } else {
                                throw new JahiaForbiddenAccessException();
                            }
                        }
                    }
                    if (resource.getNode().getPath().startsWith("/sites/") && (site == null || (!site.getPath()
                            .startsWith("/modules/")
                            && !site.isAllowsUnlistedLanguages()
                            && !(renderContext.isLiveMode()
                                    ? site.getActiveLiveLanguagesAsLocales().contains(urlResolver.getLocale())
                                    : site.getLanguagesAsLocales().contains(urlResolver.getLocale()))))) {
                        throw new PathNotFoundException("This language does not exist on this site");
                    }
                    renderContext.setSite(site);
                }
                //                    resource.pushWrapper("wrapper.fullpage");

                if (urlResolver.getPath().endsWith(".do")) {
                    Action action = templateService.getActions().get(resource.getResolvedTemplate());
                    Map<String, List<String>> parameters = toParameterMapOfListOfString(req);
                    if (action != null) {
                        doAction(req, resp, urlResolver, renderContext, resource, action, parameters);
                    } else {
                        logger.error("Action {} does not exist", resource.getResolvedTemplate());
                        throw new PathNotFoundException("Action does not exist");
                    }
                } else {
                    long lastModified = getLastModified(resource, renderContext);

                    if (lastModified == -1) {
                        // servlet doesn't support if-modified-since, no reason
                        // to go through further expensive logic
                        doGet(req, resp, renderContext, resource, startTime);
                    } else {
                        long ifModifiedSince = req.getDateHeader(HEADER_IFMODSINCE);
                        if (ifModifiedSince < (lastModified / 1000 * 1000)) {
                            // If the servlet mod time is later, call doGet()
                            // Round down to the nearest second for a proper compare
                            // A ifModifiedSince of -1 will always be less
                            maybeSetLastModified(resp, lastModified);
                            doGet(req, resp, renderContext, resource, startTime);
                        } else {
                            resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                        }
                    }
                }
            }
        } else if (method.equals(METHOD_HEAD)) {
            doHead(req, resp);

        } else if (method.equals(METHOD_POST)) {
            doPost(req, resp, renderContext, urlResolver);

        } else if (method.equals(METHOD_PUT)) {
            doPut(req, resp, renderContext, urlResolver);

        } else if (method.equals(METHOD_DELETE)) {
            doDelete(req, resp, renderContext, urlResolver);

        } else if (method.equals(METHOD_OPTIONS)) {
            doOptions(req, resp);

        } else if (method.equals(METHOD_TRACE)) {
            doTrace(req, resp);

        } else {
            //
            // Note that this means NO servlet supports whatever
            // method was requested, anywhere on this server.
            //
            resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        }
    } catch (Exception e) {
        List<ErrorHandler> handlers = templateService.getErrorHandler();
        for (ErrorHandler handler : handlers) {
            if (handler.handle(e, req, resp)) {
                return null;
            }
        }
        DefaultErrorHandler.getInstance().handle(e, req, resp);
    } finally {
        if (logger.isInfoEnabled()) {
            StringBuilder sb = new StringBuilder(100);
            sb.append("Rendered [").append(req.getRequestURI());
            if (jcrSessionFactory.getCurrentUser() != null) {
                sb.append("] user=[").append(jcrSessionFactory.getCurrentUser().getUsername());
            }
            sb.append("] ip=[").append(req.getRemoteAddr()).append("] sessionID=[").append(sessionId)
                    .append("] in [").append(System.currentTimeMillis() - startTime).append("ms]");
            logger.info(sb.toString());
        }
    }
    return null;
}

From source file:com.adito.security.DefaultLogonController.java

public synchronized int addSessionTimeoutBlock(HttpSession session, String reason) {
    Map sessionTimeoutBlocks = (Map) session.getAttribute(Constants.SESSION_TIMEOUT_BLOCKS);
    if (sessionTimeoutBlocks == null) {
        sessionTimeoutBlocks = new HashMap();
        session.setAttribute(Constants.SESSION_TIMEOUT_BLOCKS, sessionTimeoutBlocks);
    }//from w  w  w. jav a  2 s .  c  o m
    sessionTimeoutBlocks.put(String.valueOf(++sessionTimeoutBlockId), reason);
    if (log.isDebugEnabled())
        log.debug("Preventing session timeout on session " + session.getId() + " (id of "
                + sessionTimeoutBlockId + ") because '" + reason + "'. There are now "
                + sessionTimeoutBlocks.size() + " reasons not to timeout the session.");
    session.setMaxInactiveInterval(-1);
    return sessionTimeoutBlockId;
}

From source file:org.jahia.admin.sites.ManageSites.java

/**
 * Display Delete Site confirmation./*  ww w  .  jav a 2 s .  co  m*/
 *
 * @param request  Servlet request.
 * @param response Servlet response.
 * @param session  HttpSession object.
 */
private void displayDelete(HttpServletRequest request, HttpServletResponse response, HttpSession session)
        throws IOException, ServletException {
    //logger.debug(" display delete site started ");

    // change session time out to 1 hour ( the extraction can be very long !)
    int timeOut = session.getMaxInactiveInterval();

    try {
        session.setMaxInactiveInterval(7200);

        // get site...
        String site_id = StringUtils.defaultString(request.getParameter("siteid")).trim();
        Integer siteID = new Integer(site_id);

        JahiaSite site = sMgr.getSite(siteID.intValue());

        // retrieve previous form values...
        String jahiaDisplayMessage = Jahia.COPYRIGHT;
        String siteTitle = (String) request.getAttribute("siteTitle");
        String siteServerName = (String) request.getAttribute("siteServerName");
        String siteKey = (String) request.getAttribute("siteKey");
        String siteDescr = (String) request.getAttribute("siteDescr");

        // set default values...
        if (siteTitle == null) {
            siteTitle = site.getTitle();
        }
        if (siteServerName == null) {
            siteServerName = site.getServerName();
        }
        if (siteKey == null) {
            siteKey = site.getSiteKey();
        }
        if (siteDescr == null) {
            siteDescr = site.getDescr();
        }

        // set request attributes...
        request.setAttribute("jahiaDisplayMessage", jahiaDisplayMessage);
        request.setAttribute("siteTitle", siteTitle);
        request.setAttribute("siteServerName", siteServerName);
        request.setAttribute("siteKey", siteKey);
        request.setAttribute("siteDescr", siteDescr);
        request.setAttribute("siteID", siteID);

        // list of user providers
        JahiaUserManagerService userServ = ServicesRegistry.getInstance().getJahiaUserManagerService();
        List<JahiaUserManagerProvider> usrProviders = new ArrayList<JahiaUserManagerProvider>();
        for (JahiaUserManagerProvider usrProviderBean : userServ.getProviderList()) {
            if (!usrProviderBean.isReadOnly()) {
                usrProviders.add(usrProviderBean);
            }
        }
        request.setAttribute("usrProviders", usrProviders);

        // redirect...
        JahiaAdministration.doRedirect(request, response, session, JSP_PATH + "site_delete.jsp");
    } catch (Exception e) {
        logger.error("Error while display site delete UI", e);
        // redirect to list...
        String jahiaDisplayMessage = getMessage("org.jahia.admin.warningMsg..processingError.label");
        session.setAttribute(CLASS_NAME + "jahiaDisplayMessage", jahiaDisplayMessage);
        displayList(request, response, session);
    } finally {
        // restore time out
        session.setMaxInactiveInterval(timeOut);
    }

    // reset display message...
    session.setAttribute(CLASS_NAME + "jahiaDisplayMessage", Jahia.COPYRIGHT);
}

From source file:com.adito.security.DefaultLogonController.java

public synchronized void removeSessionTimeoutBlock(HttpSession session, int sessionTimeoutBlockId) {
    try {//from  w w  w .ja  va2 s .  c  o  m
        Map sessionTimeoutBlocks = (Map) session.getAttribute(Constants.SESSION_TIMEOUT_BLOCKS);
        if (sessionTimeoutBlocks != null) {
            String reason = (String) sessionTimeoutBlocks.get(String.valueOf(sessionTimeoutBlockId));
            if (reason == null) {
                log.warn("No session timeout block with id of " + sessionTimeoutBlockId);
            } else {
                sessionTimeoutBlocks.remove(String.valueOf(sessionTimeoutBlockId));
                if (log.isDebugEnabled())
                    log.debug("Removing session timeout block " + sessionTimeoutBlockId + " for session "
                            + session.getId() + " ('" + reason + "'). There are now "
                            + sessionTimeoutBlocks.size() + " reasons not to timeout the session.");
            }
            if (sessionTimeoutBlocks.size() == 0) {
                session.removeAttribute(Constants.SESSION_TIMEOUT_BLOCKS);
                User user = (User) session.getAttribute(Constants.USER);
                int minutes = CoreUtil.getUsersProfilePropertyIntOrDefault(session,
                        "webServer.sessionInactivityTimeout", user);
                if (log.isDebugEnabled())
                    log.debug("Initialising timeout for session " + session.getId() + " to " + minutes
                            + " minutes");
                session.setMaxInactiveInterval(minutes == 0 ? -1 : minutes * 60);
            }
        }
    } catch (IllegalStateException ise) {
        log.warn("Couldnt remove session timeout block.", ise);
    }
}

From source file:org.yawlfoundation.yawl.resourcing.jsf.SessionBean.java

public void resetSessionTimeout() {
    HttpSession session = getExternalSession();
    if (defaultSessionTimeoutValue != session.getMaxInactiveInterval()) {
        session.setMaxInactiveInterval(defaultSessionTimeoutValue);
    }// w  w w  .  j a  v  a2  s. c  o m
}