1 23 24 package org.infoglue.cms.applications.common; 25 26 import java.util.Locale ; 27 import java.util.Map ; 28 29 import javax.servlet.http.HttpSession ; 30 31 import org.infoglue.cms.entities.management.SystemUser; 32 import org.infoglue.cms.security.InfoGlueAuthenticationFilter; 33 import org.infoglue.cms.security.InfoGluePrincipal; 34 35 import webwork.action.ActionContext; 36 import webwork.action.factory.SessionMap; 37 38 39 47 public class Session 48 { 49 public static final String LOCALE = "locale"; 51 private static final String USER = "user"; 52 private static final String IG_PRINCIPAL = InfoGlueAuthenticationFilter.INFOGLUE_FILTER_USER; 53 public static final String TOOL_ID = "toolId"; 54 55 56 private Map sessionDelegate; 57 58 public Session() 59 { 60 this(ActionContext.getSession()); 61 } 62 63 public Session(Map session) 64 { 65 this.sessionDelegate = session; 66 } 67 68 public Session(HttpSession httpSession) 69 { 70 this.sessionDelegate = new SessionMap(httpSession); 71 } 72 73 76 public final Locale getLocale() 77 { 78 if(sessionDelegate.get(LOCALE) == null) 80 { 81 setLocale(java.util.Locale.ENGLISH); 82 } 83 84 return (Locale ) sessionDelegate.get(LOCALE); 85 } 86 87 90 public final Integer getToolId() 91 { 92 if(sessionDelegate.get(TOOL_ID) == null) 94 { 95 setToolId(new Integer (0)); 96 } 97 98 return (Integer ) sessionDelegate.get(TOOL_ID); 99 } 100 101 106 public final void setLocale(Locale locale) 107 { 108 sessionDelegate.put(LOCALE, locale); 109 } 110 111 116 public final void setToolId(Integer toolId) 117 { 118 sessionDelegate.put(TOOL_ID, toolId); 119 } 120 121 126 public final SystemUser getUser() 127 { 128 return (SystemUser) sessionDelegate.get(USER); 129 } 130 131 136 public final void setSystemUser(SystemUser systemUser) 137 { 138 sessionDelegate.put(USER, systemUser); 140 } 141 142 147 public InfoGluePrincipal getInfoGluePrincipal() 148 { 149 return (InfoGluePrincipal)sessionDelegate.get(IG_PRINCIPAL); 150 } 151 152 156 public void setInfoGluePrincipal(InfoGluePrincipal p) 157 { 158 sessionDelegate.put(IG_PRINCIPAL, p); 159 } 160 161 public String toString() 162 { 163 StringBuffer sb = new StringBuffer ("<Session>\n"); 164 sb.append(" locale=[" + getLocale() + "]\n"); 165 sb.append(" user=[" + getUser() + "]\n"); 166 return sb.toString(); 167 } 168 169 } | Popular Tags |