Example usage for javax.servlet.http HttpSessionBindingEvent getName

List of usage examples for javax.servlet.http HttpSessionBindingEvent getName

Introduction

In this page you can find the example usage for javax.servlet.http HttpSessionBindingEvent getName.

Prototype

public String getName() 

Source Link

Document

Returns the name with which the attribute is bound to or unbound from the session.

Usage

From source file:com.gcrm.security.AuthenticationSuccessListener.java

public void attributeAdded(HttpSessionBindingEvent se) {
    String sessionName = se.getName();
    if (sessionName.equals("SPRING_SECURITY_CONTEXT")) {
        SecurityContext securityContext = (SecurityContext) se.getSession()
                .getAttribute("SPRING_SECURITY_CONTEXT");
        Authentication authentication = securityContext.getAuthentication();
        UserDetailsImpl userDetails = (UserDetailsImpl) authentication.getPrincipal();
        se.getSession().setAttribute(LOGIN_USER, userDetails.getUser());
    }//from w  w  w  . j ava 2 s.c  o  m
}

From source file:com.gcrm.security.AuthenticationSuccessListener.java

public void attributeReplaced(HttpSessionBindingEvent se) {
    String sessionName = se.getName();
    if (sessionName.equals("SPRING_SECURITY_CONTEXT")) {
        SecurityContext securityContext = (SecurityContext) se.getSession()
                .getAttribute("SPRING_SECURITY_CONTEXT");
        Authentication authentication = securityContext.getAuthentication();
        UserDetailsImpl userDetails = (UserDetailsImpl) authentication.getPrincipal();
        se.getSession().setAttribute(LOGIN_USER, userDetails.getUser());
    }//w  w  w  .j  av  a 2s.c o  m
}

From source file:MyServlet.java

public void valueBound(HttpSessionBindingEvent event) {
    context.log("[" + new Date() + "] BOUND as " + event.getName() + " to " + event.getSession().getId());
}

From source file:MyServlet.java

public void valueUnbound(HttpSessionBindingEvent event) {
    context.log("[" + new Date() + "] UNBOUND as " + event.getName() + " from " + event.getSession().getId());
}

From source file:Binder.java

public void valueBound(HttpSessionBindingEvent event) {
    context.log("" + (new java.util.Date()) + " Binding " + event.getName() + " to session "
            + event.getSession().getId());
}

From source file:Binder.java

public void valueUnbound(HttpSessionBindingEvent event) {
    context.log("" + (new java.util.Date()) + " Unbinding " + event.getName() + " from session "
            + event.getSession().getId());
}

From source file:SessionBindListen.java

public void valueBound(HttpSessionBindingEvent be) {

    HttpSession session = be.getSession();
    String id = session.getId();//from   w  w w  . java  2 s  .c o  m
    String name = be.getName();
    Object value = be.getValue();
    String source = be.getSource().getClass().getName();
    String message = new StringBuffer("Attribute bound to session in ").append(source)
            .append("\nThe attribute name: ").append(name).append("\n").append("The attribute value: ")
            .append(value).append("\n").append("The session id: ").append(id).toString();

    System.out.println(message);
}

From source file:SessionBindListen.java

public void valueUnbound(HttpSessionBindingEvent be) {

    HttpSession session = be.getSession();
    String id = session.getId();//from w  w  w .jav  a  2  s.  com
    String name = be.getName();
    if (name == null)
        name = "Unknown";
    String source = be.getSource().getClass().getName();
    String message = new StringBuffer("Attribute unbound from session in ").append(source)
            .append("\nThe attribute name: ").append(name).append("\n").append("The session id: ").append(id)
            .toString();
    //clear Map; send message
    info.clear();
    System.out.println(message + "\nThe size of the HashMap is: " + info.size());
}

From source file:org.musicrecital.webapp.listener.UserCounterListener.java

/**
 * This method is designed to catch when user's login and record their name
 *
 * @param event the event to process/*  w w  w .j a va2s  .co  m*/
 * @see javax.servlet.http.HttpSessionAttributeListener#attributeAdded(javax.servlet.http.HttpSessionBindingEvent)
 */
public void attributeAdded(HttpSessionBindingEvent event) {
    if (event.getName().equals(EVENT_KEY) && !isAnonymous()) {
        SecurityContext securityContext = (SecurityContext) event.getValue();
        if (securityContext != null && securityContext.getAuthentication().getPrincipal() instanceof User) {
            User user = (User) securityContext.getAuthentication().getPrincipal();
            addUsername(user);
        }
    }
}

From source file:org.musicrecital.webapp.listener.UserCounterListener.java

/**
 * When user's logout, remove their name from the hashMap
 *
 * @param event the session binding event
 * @see javax.servlet.http.HttpSessionAttributeListener#attributeRemoved(javax.servlet.http.HttpSessionBindingEvent)
 *//*www .  j  ava2  s .co m*/
public void attributeRemoved(HttpSessionBindingEvent event) {
    if (event.getName().equals(EVENT_KEY) && !isAnonymous()) {
        SecurityContext securityContext = (SecurityContext) event.getValue();
        Authentication auth = securityContext.getAuthentication();
        if (auth != null && (auth.getPrincipal() instanceof User)) {
            User user = (User) auth.getPrincipal();
            removeUsername(user);
        }
    }
}