Example usage for javax.servlet.http HttpSession removeAttribute

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

Introduction

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

Prototype

public void removeAttribute(String name);

Source Link

Document

Removes the object bound with the specified name from this session.

Usage

From source file:org.artifactory.webapp.servlet.RequestUtils.java

public static void removeAuthentication(HttpServletRequest request) {
    HttpSession session = request.getSession(false);
    if (session != null) {
        session.removeAttribute(LAST_USER_KEY);
    }/*from w  ww.j a  va 2  s  .c o m*/
}

From source file:be.fedict.eid.applet.service.impl.AuthenticationChallenge.java

/**
 * Gives back the authentication challenge. This challenge is checked for
 * freshness and can be consumed only once.
 * //w  w w.j  a va  2  s .  c om
 * @param session
 * @param maxMaturity
 * @return
 */
public static byte[] getAuthnChallenge(HttpSession session, Long maxMaturity) {
    AuthenticationChallenge authenticationChallenge = (AuthenticationChallenge) session
            .getAttribute(AUTHN_CHALLENGE_SESSION_ATTRIBUTE);
    if (null == authenticationChallenge) {
        throw new SecurityException("no challenge in session");
    }
    session.removeAttribute(AUTHN_CHALLENGE_SESSION_ATTRIBUTE);
    Date now = new Date();
    if (null == maxMaturity) {
        maxMaturity = DEFAULT_MAX_MATURITY;
    }
    long dt = now.getTime() - authenticationChallenge.getTimestamp().getTime();
    if (dt > maxMaturity) {
        throw new SecurityException("maximum challenge maturity reached");
    }
    byte[] challenge = authenticationChallenge.getChallenge();
    return challenge;
}

From source file:com.adito.vfs.VFSRepository.java

/**
 * Remove a {@link VFSRepository} repository from the given session. 
 * @param session/*  www. j a va 2  s .co m*/
 */
public static void removeRepository(SessionInfo session) {
    HttpSession httpSession = session.getHttpSession();
    if (httpSession != null) {
        httpSession.removeAttribute(REPOSITORY_ATTR);
        if (log.isInfoEnabled())
            log.info("Removed repository");
    }
}

From source file:app.navigate.entity.EntityRedirectorPage.java

public static EntitySubtypeRedirectInfo getEntitySubtypeRedirectInfo(NavigationContext nc, Object id) {
    HttpSession session = nc.getHttpRequest().getSession();
    EntitySubtypeRedirectInfo esri = (EntitySubtypeRedirectInfo) session.getAttribute(SESSATTRNAME_ESRI);
    session.removeAttribute(SESSATTRNAME_ESRI); // get rid of it so it's not hanging around for next call
    if (esri != null && esri.getId().equals(id))
        return esri;
    else//from   w  ww.j  a v a2s  .com
        return null;
}

From source file:edu.cornell.mannlib.vitro.webapp.beans.DisplayMessage.java

/**
 * Get the current message from the session, and remove it from the session
 * so it won't be displayed again.//  w w  w. j a v a  2  s.  co m
 * 
 * If there is no message, return the empty string.
 */
public static String getMessageAndClear(HttpSession session) {
    String message = NO_MESSAGE;
    if (session != null) {
        Object sessionMessage = session.getAttribute(ATTRIBUTE_NAME);
        if (sessionMessage != null) {
            if (sessionMessage instanceof String) {
                log.debug("Get message: '" + sessionMessage + "'");
                message = (String) sessionMessage;
            }
            session.removeAttribute(ATTRIBUTE_NAME);
        } else {
            log.debug("Get no message.");
        }
    }
    return message;
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditSubmission.java

public static void clearAllEditSubmissionsInSession(HttpSession sess) {
    if (sess == null)
        return;//  w  ww  . j a  va2s  . c  o  m
    sess.removeAttribute("editSubmission");
}

From source file:fr.paris.lutece.portal.web.PortalJspBean.java

/**
 * Remove the upload filter next url from the session
 * @param request the HTTP request/*from   ww  w. j a v a  2 s.  c o  m*/
 */
public static void removeUploadFilterSiteNextUrl(HttpServletRequest request) {
    HttpSession session = request.getSession();
    session.removeAttribute(ATTRIBUTE_UPLOAD_FILTER_SITE_NEXT_URL);
}

From source file:nl.b3p.viewer.stripes.AttributesActionBean.java

/**
 * Call this to clear the "total feature count" cached value when a new feature 
 * is added to a feature source. Only clears the cache for the current session.
 *///  w w  w.  j a  va 2s  .  c  o  m
public static void clearTotalCountCache(ActionBeanContext context) {
    HttpSession sess = context.getRequest().getSession();
    sess.removeAttribute(CACHE_APPLAYER);
    sess.removeAttribute(CACHE_FILTER);
    sess.removeAttribute(CACHE_TIME);
    sess.removeAttribute(CACHE_COUNT);
}

From source file:org.jbpcc.admin.jsf.JsfUtil.java

@SuppressWarnings("unchecked")
public static void cleanHttpSession() {
    HttpSession session = (HttpSession) getCurrentFacesContext().getExternalContext().getSession(true);
    SessionObjectKey sessionObjKeyArray[] = SessionObjectKey.values();
    for (SessionObjectKey objectKey : sessionObjKeyArray) {
        session.removeAttribute(objectKey.getKey());
    }//  w ww. ja  v a 2s .co  m

    java.util.Enumeration attrs = session.getAttributeNames();
    while (attrs.hasMoreElements()) {
        String attr = (String) attrs.nextElement();
        if (attr.endsWith("Bean")) {
            session.removeAttribute(attr);
        }
    }
}

From source file:org.carewebframework.security.spring.DesktopSecurityContextRepository.java

/**
 * Returns the security context from the session, if it exists.
 * /*from  w ww.j  a va 2s. c o m*/
 * @param session Session where security context is stored.
 * @param remove If true and a security context is found in the session, it is removed.
 * @return The security context, or null if none found.
 */
private static SecurityContext getSecurityContext(HttpSession session, boolean remove) {
    SecurityContext securityContext = (SecurityContext) session.getAttribute(CONTEXT_KEY);

    if (securityContext != null && remove) {
        session.removeAttribute(CONTEXT_KEY);
    }

    return securityContext;
}