Example usage for javax.servlet.http HttpSession getAttributeNames

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

Introduction

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

Prototype

public Enumeration<String> getAttributeNames();

Source Link

Document

Returns an Enumeration of String objects containing the names of all the objects bound to this session.

Usage

From source file:com.flexive.war.filter.SessionFixationFilter.java

private Map<String, Object> getAttributes(HttpSession session) {
    final Map<String, Object> attributes = Maps.newHashMap();
    final Enumeration attributeNames = session.getAttributeNames();
    while (attributeNames.hasMoreElements()) {
        final String name = (String) attributeNames.nextElement();
        attributes.put(name, session.getAttribute(name));
    }/* w  ww.  j a va2  s .c  om*/
    return attributes;
}

From source file:org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor.java

@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response,
        WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {

    if (request instanceof ServletServerHttpRequest) {
        ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request;
        HttpSession session = servletRequest.getServletRequest().getSession(false);
        if (session != null) {
            Enumeration<String> names = session.getAttributeNames();
            while (names.hasMoreElements()) {
                String name = names.nextElement();
                if (CollectionUtils.isEmpty(this.attributeNames) || this.attributeNames.contains(name)) {
                    if (logger.isTraceEnabled()) {
                        logger.trace("Adding HTTP session attribute to handshake attributes: " + name);
                    }// w w w .j  a  va 2 s  .  co m
                    attributes.put(name, session.getAttribute(name));
                } else {
                    if (logger.isTraceEnabled()) {
                        logger.trace("Skipped HTTP session attribute");
                    }
                }
            }
        }
    }
    return true;
}

From source file:org.apache.roller.planet.ui.core.filters.DebugFilter.java

/**
 * Inspect incoming urls and see if they should be routed.
 *//*from   w  w w  . j  ava2 s.  c  o  m*/
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) res;

    log.info("entering");

    // print out session details
    HttpSession session = request.getSession(false);
    if (session != null) {
        log.info("inbound session contains:");
        Enumeration foo = session.getAttributeNames();
        while (foo.hasMoreElements()) {
            String attr = (String) foo.nextElement();
            log.info(attr + " = " + session.getAttribute("attr"));
        }
    }

    // keep going
    chain.doFilter(request, response);

    // print out session details
    session = request.getSession(false);
    if (session != null) {
        log.info("outbound session contains:");
        Enumeration bar = session.getAttributeNames();
        while (bar.hasMoreElements()) {
            String attr = (String) bar.nextElement();
            log.info(attr + " = " + session.getAttribute("attr"));
        }
    }

    log.info("exiting");
}

From source file:com.sun.socialsite.web.filters.DebugFilter.java

/**
 * Inspect incoming urls and see if they should be routed.
 *//*from  w  w w . j  ava2  s  . c o m*/
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) res;

    log.info("--- entering");
    log.info(request.getMethod() + " " + request.getRequestURL().toString());
    log.info("st=" + request.getParameter("st"));

    // print out session details
    HttpSession session = request.getSession(false);
    if (session != null) {
        log.info("inbound session contains:");
        Enumeration foo = session.getAttributeNames();
        while (foo.hasMoreElements()) {
            String attr = (String) foo.nextElement();
            log.info("   " + attr + " = " + session.getAttribute("attr"));
        }
    }

    // keep going
    chain.doFilter(request, response);

    // print out session details
    session = request.getSession(false);
    if (session != null) {
        log.info("outbound session contains:");
        Enumeration bar = session.getAttributeNames();
        while (bar.hasMoreElements()) {
            String attr = (String) bar.nextElement();
            log.info("    " + attr + " = " + session.getAttribute("attr"));
        }
    }

    log.info("--- exiting");
}

From source file:com.icesoft.faces.async.render.RunnableRender.java

/**
 * See note above in run method. Just fiddle with the session to try to cause
 * IllegalStateExceptions before Seam takes over.
 * /*from w  w  w . ja  v a2 s  .  co  m*/
 * @param state PersistentFacesState used in rendering
 * @throws IllegalStateException If logged out. 
 */
private void testSession(PersistentFacesState state) throws IllegalStateException {
    FacesContext fc = state.getFacesContext();
    Object o = fc.getExternalContext().getSession(false);
    if (o == null) {
        renderable.renderingException(new FatalRenderingException("Session has ended (User Logout?)"));
    } else {
        if (o instanceof HttpSession) {
            HttpSession session = (HttpSession) o;
            session.getAttributeNames();
        } else if (o instanceof PortletSession) {
            PortletSession ps = (PortletSession) o;
            ps.getAttributeNames();
        }
    }
}

From source file:org.topazproject.ambra.auth.web.UsernameReplacementWithGuidFilter.java

private void dumpSession(final HttpSession initialSession) {
    log.debug("Session Attributes:");
    final Enumeration attribs1 = initialSession.getAttributeNames();
    while (attribs1.hasMoreElements()) {
        final String attribName1 = (String) attribs1.nextElement();
        log.debug(attribName1 + ":" + initialSession.getAttribute(attribName1).toString());
    }//from  w ww. ja v a  2  s .c  om
}

From source file:org.debux.webmotion.server.render.RenderException.java

protected Map<String, Object> getSessionAttributes(HttpSession session) {
    Map<String, Object> result = new HashMap<String, Object>();
    for (Enumeration<String> names = session.getAttributeNames(); names.hasMoreElements();) {
        String name = names.nextElement();
        Object value = session.getAttribute(name);
        result.put(name, value);//from  ww  w  .j  av a2 s. c  o  m
    }
    return result;
}

From source file:de.itsvs.cwtrpc.security.DefaultRpcHttpSessionStrategy.java

protected void clearSession(HttpServletRequest request, HttpServletResponse response, HttpSession session)
        throws IOException, ServletException {
    for (@SuppressWarnings("unchecked")
    Enumeration<String> names = session.getAttributeNames(); names.hasMoreElements();) {
        session.removeAttribute(names.nextElement());
    }/*  www  . j  a  va  2s .co  m*/
}

From source file:com.autentia.tnt.util.JPivotUtils.java

/**
 * Ejecuta una query MDX sobre un cubo OLAP utilizando el datasource por defecto. <br>
 * El resultado lo almacena en el contexto de sesin para que pueda ser recogido y pintado por las etiquetas de JPivot.
 * /* w  w w.j  a v a  2s .co m*/
 * @param mdxQuery query a ejecutar
 * @param cubeSchema URL del que representa el cubo OLAP
 * @return
 * @throws SAXException
 * @throws IOException
 * @throws OlapException
 */
public static OlapModel executeOlapQuery(String mdxQuery, URL schema, HttpSession session)
        throws SAXException, IOException, OlapException {

    final RequestContext context = RequestContext.instance();

    // final URL schema = JpivotUtils.class.getResource(cubeSchema);//new URL("file:///"+cubeSchema);//

    final MondrianModelFactory.Config cfg = new MondrianModelFactory.Config();
    cfg.setMdxQuery(mdxQuery);
    cfg.setSchemaUrl(schema.toExternalForm());
    cfg.setDataSource(DATA_SOURCE);

    final MondrianModel mondrianModel = MondrianModelFactory.instance(cfg);
    final OlapModel olapModel = (OlapModel) mondrianModel.getTopDecorator();
    olapModel.setLocale(context.getLocale());
    // olapModel.setLocale(FacesContext.getCurrentInstance().getViewRoot().getLocale());
    olapModel.setServletContext(context.getSession().getServletContext());
    // olapModel.setServletContext((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext());

    // olapModel.
    olapModel.initialize();

    if (log.isDebugEnabled()) {
        java.util.Enumeration attributeNames = session.getAttributeNames();
        while (attributeNames.hasMoreElements()) {
            String name = (String) attributeNames.nextElement();
            log.debug("--- name: " + name + "; type:" + session.getAttribute(name).getClass() + " ---");
        }
    }

    // borramos de la sesion los datos que ha metido JPivot
    // y el model de la consulta que volveremos a meter
    // Esto es necesario porque los tags de JPivot no machacan los
    // valores si ya estn en sesin; por lo que al cambiar de informe
    // sigue mostrando el informe selecionado previamente
    session.removeAttribute(JPivotUtils.QUERY_SESSION_NAME);
    session.removeAttribute(JPivotUtils.TABLE_SESSION_NAME);
    session.removeAttribute(JPivotUtils.NAVI_SESSION_NAME);
    session.removeAttribute(JPivotUtils.SORTFORM_SESSION_NAME);
    session.removeAttribute(JPivotUtils.PRINT_SESSION_NAME);
    session.removeAttribute(JPivotUtils.PRINTFORM_SESSION_NAME);
    session.removeAttribute(JPivotUtils.CHART_SESSION_NAME);
    session.removeAttribute(JPivotUtils.CHARTFORM_SESSION_NAME);
    session.removeAttribute(JPivotUtils.TOOLBAR_SESSION_NAME);

    session.setAttribute(JPivotUtils.QUERY_SESSION_NAME, olapModel);
    return olapModel;
}

From source file:gov.nih.nci.ncicb.cadsr.common.security.LogoutServlet.java

private Set copyAllsessionKeys(HttpSession session) {
    log.error("LogoutServlet.copyAllsessionKeys end:" + TimeUtils.getEasternTime());
    HashSet set = new HashSet();
    Enumeration keys = session.getAttributeNames();
    for (; keys.hasMoreElements();) {
        String key = (String) keys.nextElement();
        set.add(key);/*  w  ww  .  j a  va2s  .  com*/
    }
    log.error("LogoutServlet.copyAllsessionKeys start:" + TimeUtils.getEasternTime());
    return set;
}