001package bradleyross.j2ee.beans; 002// import java.util.Map; 003import java.util.Enumeration; 004import javax.faces.context.FacesContext; 005 006import javax.servlet.http.HttpSession; 007import javax.faces.bean.SessionScoped; 008import javax.faces.bean.ManagedBean; 009/** 010 * This bean covers the session properties for 011 * the application. 012 * @author Bradley Ross 013 * 014 */ 015@ManagedBean 016@SessionScoped 017public class SessionProperties { 018 public SessionProperties() { 019 testValue = 0; 020 } 021 /** 022 * True if user has logged in with a valid username 023 * and password. False otherwise. 024 */ 025 protected boolean authorized = false; 026 public boolean getAuthorized() { 027 return authorized; 028 } 029 public void setAuthorized(boolean value) { 030 authorized = value; 031 } 032 /** 033 * Account name for user. 034 */ 035 protected String userName = new String(); 036 public String getUserName() { 037 return userName; 038 } 039 public void setUserName(String value) { 040 userName = value; 041 } 042 public Enumeration<String> getSessionAttributes() { 043 HttpSession session = 044 (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true); 045 046 Enumeration<String> attributes = 047 session.getAttributeNames(); 048 return attributes; 049 } 050 private int testValue; 051 public int getTestValue() { 052 testValue++; 053 return testValue; 054 } 055}