Example usage for javax.servlet.http HttpServletRequest getSession

List of usage examples for javax.servlet.http HttpServletRequest getSession

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getSession.

Prototype

public HttpSession getSession();

Source Link

Document

Returns the current session associated with this request, or if the request does not have a session, creates one.

Usage

From source file:edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale.java

/**
 * Get the list of selectable Locales from the servlet context. May return
 * an empty list, but never returns null.
 *//*  ww w  .j  av  a 2s  . c om*/
public static List<Locale> getSelectableLocales(HttpServletRequest req) {
    return getSelectableLocales(req.getSession().getServletContext());
}

From source file:com.swiftcorp.portal.common.util.WebUtils.java

public static String getUniqueCode(HttpServletRequest request) {
    HttpSession session = request.getSession();
    LoginDetailInfoDTO loginInfo = (LoginDetailInfoDTO) session.getAttribute(SESSION_KEYS.LOGIN_INFO);
    return loginInfo.getUser().getUniqueCode();
}

From source file:com.swiftcorp.portal.common.util.WebUtils.java

public static RoleDTO getUserRole(HttpServletRequest request) {
    HttpSession session = request.getSession();
    UserDTO userDTO = (UserDTO) session.getAttribute(SESSION_KEYS.USER);
    return userDTO.getRole();
}

From source file:com.wordpress.metaphorm.authProxy.state.UserToken.java

public static UserToken constructFromHttpServletRequest(HttpServletRequest servletReq)
        throws PortalException, SystemException {

    UserToken userToken = new UserToken();

    String sessionId = servletReq.getSession().getId();
    userToken.sessionIdHashed = DigestUtils.sha1Hex(sessionId);

    userToken.userId = PortalUtil.getUserId(servletReq);
    userToken.scopeGroupId = PortalUtil.getScopeGroupId(servletReq);
    userToken.companyId = PortalUtil.getCompanyId(servletReq);
    String unhashed = "PORTLET:" + userToken.companyId + ":" + userToken.scopeGroupId + ":" + userToken.userId
            + ":" + userToken.sessionIdHashed; // + ":" + secret;
    userToken.hash = DigestUtils.sha1Hex(unhashed + ":" + secret);

    userToken.p_auth = "";

    return userToken;
}

From source file:com.fruit.core.util.IWebUtils.java

public static void removeCurrentSysUser(HttpServletRequest request, HttpServletResponse response) {
    CookieUtils.delCookie("", request, response);
    removeCurrentSysUserFromSession(request.getSession());
}

From source file:com.orangeleap.common.security.CasUtil.java

public static Authentication getAuthenticationToken() {
    HttpServletRequest request = OrangeLeapRequestLocal.getRequest();
    if (request == null)
        return null;
    HttpSession session = request.getSession();
    if (session == null)
        return null;
    SecurityContextImpl si = (SecurityContextImpl) session
            .getAttribute(HttpSessionContextIntegrationFilter.SPRING_SECURITY_CONTEXT_KEY);
    if (si == null)
        return null;
    return si.getAuthentication();
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator.java

/**
 * Ask the currently configured AuthenticatorFactory to give us an
 * Authenticator for this request./* w ww  .ja v a 2 s.co m*/
 * 
 * If there is no factory, configure a Basic one.
 */
public static Authenticator getInstance(HttpServletRequest request) {
    ServletContext ctx = request.getSession().getServletContext();
    Object attribute = ctx.getAttribute(FACTORY_ATTRIBUTE_NAME);
    if (!(attribute instanceof AuthenticatorFactory)) {
        setAuthenticatorFactory(new BasicAuthenticator.Factory(), ctx);
        attribute = ctx.getAttribute(FACTORY_ATTRIBUTE_NAME);
    }
    AuthenticatorFactory factory = (AuthenticatorFactory) attribute;

    return factory.getInstance(request);
}

From source file:com.vmware.appfactory.file.upload.ProgressReporter.java

/**
 * Get the progress of the upload in the form of a clone copy of ProgressListenerImpl.
 *
 * @param request - HttpServletRequest//from w  w w  .ja va2s .  c  o  m
 * @param uploadId - a key representing the progress copy in session.
 * @return implementation of ProgressListener
 */
public static ProgressListener getProgressListener(HttpServletRequest request, String uploadId) {
    if (uploadId != null) {
        ProgressListener pListener = (ProgressListener) request.getSession()
                .getAttribute(createSessionKey(uploadId));

        // Return a clone copy of the listener.
        if (pListener instanceof ProgressListenerImpl) {
            return ((ProgressListenerImpl) pListener).clone();
        }
    }

    /* The upload process may have already finished and AppApiController.uploadAndCreate()
     * may have removed ProgressListener instance from session already. Hence return null.
     */
    return null;
}

From source file:com.swiftcorp.portal.common.util.WebUtils.java

public static Long getLoggedInUserId(HttpServletRequest request) {
    HttpSession session = request.getSession();
    LoginDetailInfoDTO loginInfo = (LoginDetailInfoDTO) session.getAttribute(SESSION_KEYS.LOGIN_INFO);
    Long userId = null;/*  www  . ja va  2 s  .  c  o  m*/

    if (loginInfo != null) {
        userId = loginInfo.getUser().getComponentId();
    }

    if (userId == null) {
        // for initial phase assuming this is as default case
        userId = new Long(1);
    }

    return userId;
}

From source file:org.openxdata.server.servlet.MultimediaServlet.java

public static void clearFormSessionData(HttpServletRequest request, String formId) {
    HttpSession session = request.getSession();
    session.setAttribute(getFormKey(formId), null);
}