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:eu.eidas.node.utils.EidasNodeErrorUtil.java

private static String getSamlStatusCode(final HttpServletRequest req) {
    Object phase = req.getSession().getAttribute(EIDASParameters.SAML_PHASE.toString());
    return phase == EIDASValues.SP_REQUEST ? EIDASStatusCode.REQUESTER_URI.toString()
            : EIDASStatusCode.RESPONDER_URI.toString();
}

From source file:edu.ucsb.nceas.metacat.util.RequestUtil.java

/**
 * Add the user's login id to the session on this request
 * /*w w w . j a  v a2s.c  o m*/
 * @param request
 *            the request that will get forwarded
 * @param userId
 *            the user's login id
 */
public static void setUserId(HttpServletRequest request, String userId) {
    request.getSession().setAttribute("userId", userId);
}

From source file:eu.eidas.node.utils.EidasNodeErrorUtil.java

private static String getInResponseTo(final HttpServletRequest req) {
    Object inResponseTo = req.getSession().getAttribute(EIDASParameters.SAML_IN_RESPONSE_TO.toString());
    return inResponseTo == null ? "error" : inResponseTo.toString();
}

From source file:com.ecyrd.jspwiki.preferences.Preferences.java

/**
 *  Returns a preference value programmatically.
 *  FIXME//from w w w .  ja v  a 2s.  co  m
 *  
 *  @param wikiContext
 *  @param name
 *  @return the preference value
 */
public static String getPreference(WikiContext wikiContext, String name) {
    HttpServletRequest request = wikiContext.getHttpRequest();
    if (request == null)
        return null;

    Preferences prefs = (Preferences) request.getSession().getAttribute(SESSIONPREFS);

    if (prefs != null)
        return prefs.get(name);

    return null;
}

From source file:com.formkiq.core.webflow.FlowManager.java

/**
 * Finds the current {@link WebFlow} if one exists.
 * @param req {@link HttpServletRequest}
 * @return {@link WebFlow}/*from ww w .  j  a  v  a  2 s  .  com*/
 */
private static WebFlow getCurrentWebFlow(final HttpServletRequest req) {

    Pair<String, Integer> webflowkey = getExecutionSessionKey(req.getParameter(PARAMETER_EXECUTION));
    String sessionKey = webflowkey.getLeft();

    if (StringUtils.hasText(sessionKey)) {
        Object obj = req.getSession().getAttribute(sessionKey);
        if (obj instanceof WebFlow) {
            WebFlow wf = (WebFlow) obj;
            return wf;
        }
    }

    throw new FlowNotFoundException();
}

From source file:mercury.BaseHandler.java

public static Properties getI18nProperties(final HttpServletRequest request, String module) {
    return BaseHandler.getI18nProperties(request.getSession(), module);
}

From source file:com.jada.admin.AdminLookupDispatchAction.java

static public AdminBean getAdminBean(HttpServletRequest request) {
    return (AdminBean) request.getSession().getAttribute("adminBean");
}

From source file:com.jada.admin.AdminLookupDispatchAction.java

static public void setAdminBean(HttpServletRequest request, AdminBean adminBean) {
    request.getSession().setAttribute("adminBean", adminBean);
}

From source file:be.fedict.eid.applet.service.signer.HttpSessionTemporaryDataStorage.java

/**
 * Gives back the current HTTP session using JACC.
 * //  ww w.  j  a  v  a2  s . co m
 * @return
 */
public static HttpSession getHttpSession() {
    HttpServletRequest httpServletRequest;
    try {
        httpServletRequest = (HttpServletRequest) PolicyContext
                .getContext("javax.servlet.http.HttpServletRequest");
    } catch (PolicyContextException e) {
        throw new RuntimeException("JACC error: " + e.getMessage());
    }

    HttpSession httpSession = httpServletRequest.getSession();
    return httpSession;
}

From source file:com.xpn.xwiki.user.impl.xwiki.MyBasicAuthenticator.java

public static void showLogin(HttpServletRequest request, HttpServletResponse response, String realmName)
        throws IOException {
    // save this request
    SecurityFilter.saveRequestInformation(request);

    // determine the number of login attempts
    int loginAttempts;
    if (request.getSession().getAttribute(LOGIN_ATTEMPTS) != null) {
        loginAttempts = ((Integer) request.getSession().getAttribute(LOGIN_ATTEMPTS)).intValue();
        loginAttempts += 1;//from ww  w . j ava2 s.  com
    } else {
        loginAttempts = 1;
    }
    request.getSession().setAttribute(LOGIN_ATTEMPTS, new Integer(loginAttempts));

    if (loginAttempts <= MAX_ATTEMPTS) {
        response.setHeader("WWW-Authenticate", "BASIC realm=\"" + realmName + "\"");
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    } else {
        request.getSession().removeAttribute(LOGIN_ATTEMPTS);
        response.sendError(HttpServletResponse.SC_UNAUTHORIZED, LOGIN_FAILED_MESSAGE);
    }
}