1 2 package com.lutris.appserver.server.sessionContainerAdapter; 3 4 import java.util.Date ; 5 import java.util.Enumeration ; 6 7 import javax.servlet.http.HttpServletRequest ; 8 import javax.servlet.http.HttpSession ; 9 10 import com.lutris.appserver.server.StandardApplication; 11 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms; 12 import com.lutris.appserver.server.session.Session; 13 import com.lutris.appserver.server.session.SessionException; 14 import com.lutris.appserver.server.user.User; 15 16 17 29 public class ContainerAdapterSessionManager 30 implements com.lutris.appserver.server.session.SessionManager, java.io.Serializable { 31 44 protected static String defaultEncodeUrlState = "Auto"; 45 48 public static final String CFG_ENCODE_URL_STATE = "SessionEncodeUrlState"; 49 53 protected String encodeUrlState; 54 57 protected String SESSION = "session"; 58 59 69 protected static int defaultMaxSessionIdleTime = 30*60; 70 76 77 protected int maxSessionIdleTime; 78 86 public ContainerAdapterSessionManager (com.lutris.appserver.server.Application application, 87 com.lutris.util.Config config, com.lutris.logging.LogChannel logger) throws com.lutris.appserver.server.session.SessionException 88 { 89 90 91 try { 92 if (config.containsKey(CFG_ENCODE_URL_STATE)) { 94 encodeUrlState = config.getString(CFG_ENCODE_URL_STATE); 95 } 96 else if (config.containsKey("EncodeUrlState")) { 97 encodeUrlState = config.getString("EncodeUrlState"); 99 } 100 else { 101 encodeUrlState = defaultEncodeUrlState; 102 } 103 if (config.containsKey("MaxIdleTime")) { 104 maxSessionIdleTime = config.getInt("MaxIdleTime")*60; 106 } 107 else { 108 maxSessionIdleTime = defaultMaxSessionIdleTime; 109 } 110 115 } catch (com.lutris.util.ConfigException e) { 116 throw new com.lutris.appserver.server.session.SessionException(e); 117 } 118 ((StandardApplication)application).setCookieForNewSession(false); 119 } 120 121 126 public Session createSession () throws com.lutris.appserver.server.session.SessionException { 127 return new ContainerAdapterSession(this, null); 128 } 129 130 136 public Session createSession (String ipport) throws com.lutris.appserver.server.session.SessionException { 137 138 139 throw new java.lang.UnsupportedOperationException ("Method createSession() not implemented."); 140 } 141 142 148 public Session createSession (HttpPresentationComms comms) throws com.lutris.appserver.server.session.SessionException { 149 150 HttpServletRequest servletRequest = comms.request.getHttpServletRequest(); 151 HttpSession httpSession = servletRequest.getSession(); 152 httpSession.setMaxInactiveInterval(maxSessionIdleTime); 153 comms.session = new ContainerAdapterSession(this, httpSession); 154 httpSession.setAttribute(SESSION, comms.session); 155 return comms.session; 156 } 157 158 164 public void deleteSession (Session parm1) throws com.lutris.appserver.server.session.SessionException { 165 166 167 throw new java.lang.UnsupportedOperationException ("Method deleteSession() not implemented."); 168 } 169 170 176 public void deleteSession (String parm1) throws com.lutris.appserver.server.session.SessionException { 177 178 179 throw new java.lang.UnsupportedOperationException ("Method deleteSession() not implemented."); 180 } 181 182 188 public boolean sessionExists (String sessionId) throws com.lutris.appserver.server.session.SessionException { 189 return true; 190 } 191 192 198 public Session getSession (String sessionId) throws com.lutris.appserver.server.session.SessionException { 199 throw new java.lang.UnsupportedOperationException ("Method getSession (String sessionId) not implemented."); 201 } 202 209 public Session getSession (String sessionId, HttpServletRequest servletRequest) throws com.lutris.appserver.server.session.SessionException { 210 211 HttpSession httpSession = servletRequest.getSession(); 212 213 if (httpSession != null) { 214 Session session = null; 215 216 try{ 217 session= (ContainerAdapterSession)httpSession.getAttribute("session"); 218 }catch(IllegalStateException ise){ 219 return null; 220 } 221 222 if(session!=null) 223 { 224 if(session.getSessionManager ()==null) 225 { 226 ((ContainerAdapterSession)session).setSessionManager (this); 227 } 228 229 return session; 230 } 231 else 232 { 233 return null; 234 } 235 } 236 else { 237 return null; 238 } 239 } 240 241 248 public Session getSession (String sessionId, HttpPresentationComms comms) throws com.lutris.appserver.server.session.SessionException { 249 HttpServletRequest servletRequest = comms.request.getHttpServletRequest(); 250 HttpSession httpSession = servletRequest.getSession(); 251 252 if (httpSession != null) { 253 254 Session session = null; 255 256 try{ 257 session= (ContainerAdapterSession)httpSession.getAttribute("session"); 258 }catch(IllegalStateException ise){ 259 return null; 260 } 261 if(session!=null) 262 { 263 if(session.getSessionManager ()==null) 264 { 265 ((ContainerAdapterSession)session).setSessionManager (this); 266 } 267 268 return session; 269 } 270 else 271 { 272 return null; 273 } 274 } 275 else { 276 return null; 277 } 278 } 279 280 288 public Session getSession (Thread parm1, String sessionId, HttpPresentationComms comms) throws com.lutris.appserver.server.session.SessionException { 289 return getSession(sessionId, comms); 290 } 291 292 299 public Session getSession (Thread parm1, String sessionId) throws com.lutris.appserver.server.session.SessionException { 300 301 302 throw new java.lang.UnsupportedOperationException ("Method getSessionKeys() not implemented."); 303 } 304 305 311 public Enumeration getSessionKeys (User parm1) throws com.lutris.appserver.server.session.SessionException { 312 313 314 throw new java.lang.UnsupportedOperationException ("Method getSessionKeys() not implemented."); 315 } 316 317 324 public void passivateSession (Thread parm1, String parm2) throws com.lutris.appserver.server.session.SessionException { 325 return; 327 } 328 329 335 public int activeSessionCount () throws com.lutris.appserver.server.session.SessionException { 336 337 338 throw new java.lang.UnsupportedOperationException ("Method activeSessionCount() not implemented."); 339 } 340 341 345 public int maxSessionCount () { 346 347 348 throw new java.lang.UnsupportedOperationException ("Method maxSessionCount() not implemented."); 349 } 350 351 355 public Date maxSessionCountDate () { 356 357 358 throw new java.lang.UnsupportedOperationException ("Method maxSessionCountDate() not implemented."); 359 } 360 361 366 public void resetMaxSessionCount () throws com.lutris.appserver.server.session.SessionException { 367 368 369 throw new java.lang.UnsupportedOperationException ("Method resetMaxSessionCount() not implemented."); 370 } 371 372 377 public Enumeration getSessionKeys () throws com.lutris.appserver.server.session.SessionException { 378 379 380 throw new java.lang.UnsupportedOperationException ("Method getSessionKeys() not implemented."); 381 } 382 383 386 public void shutdown () {} 387 388 392 public String getEncodeUrlState () { 393 return encodeUrlState; 394 } 395 } 396 397 398 399 | Popular Tags |