- Timestamp:
- 07/05/08 22:16:04 (5 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/server/src/ome/services/sessions/SessionManagerImpl.java
r2388 r2592 73 73 74 74 // Injected 75 OmeroContext context;76 Roles roles;77 SessionCache cache;78 Executor executor;79 long defaultTimeToIdle;80 long defaultTimeToLive;75 protected OmeroContext context; 76 protected Roles roles; 77 protected SessionCache cache; 78 protected Executor executor; 79 protected long defaultTimeToIdle; 80 protected long defaultTimeToLive; 81 81 82 82 /** … … 84 84 * {@link Executor} 85 85 */ 86 Principal asroot;87 SessionContext sc;86 protected Principal asroot; 87 protected SessionContext sc; 88 88 89 89 // ~ Injectors … … 155 155 SessionContext context = cache.getSessionContext(credentials); 156 156 if (context != null) { 157 context.increment(); 157 158 return context.getSession(); // EARLY EXIT! 158 159 } … … 161 162 } 162 163 163 boolean ok = executeCheckPassword(_principal, credentials); 164 // Though trusted values, if we receive a null principal, not ok; 165 boolean ok = _principal == null ? false : executeCheckPassword( 166 _principal, credentials); 164 167 165 168 if (!ok) { … … 179 182 .getName()); 180 183 if (context != null) { 184 context.increment(); 181 185 return context.getSession(); // EARLY EXIT! 182 186 } … … 205 209 throw re; 206 210 } 211 212 // All successful, increment and return. 213 ctx.increment(); 207 214 return session; 208 215 } … … 294 301 } 295 302 303 public int getReferenceCount(String uuid) { 304 SessionContext ctx = cache.getSessionContext(uuid); 305 return ctx.refCount(); 306 } 307 308 public int detach(String uuid) { 309 SessionContext ctx = cache.getSessionContext(uuid); 310 return ctx.decrement(); 311 } 312 296 313 /* 297 314 */ … … 302 319 ctx = cache.getSessionContext(uuid); 303 320 } catch (SessionException se) { 304 ctx = null; 305 } 306 307 if (ctx == null) { 308 return; 309 } 310 311 Session s = ctx.getSession(); 312 s.setClosed(new Timestamp(System.currentTimeMillis())); 313 update(s); 314 315 try { 316 context.publishEvent(new DestroySessionMessage(this, s.getUuid())); 317 } catch (RuntimeException re) { 318 log.warn("Session destruction cancelled by event listener", re); 319 throw re; 320 } 321 // This the publishEvent returns successfully, then we update our cache 322 // since ehcache is not tx-friendly. 323 cache.removeSession(uuid); 321 return; // EARLY EXIT! 322 } 323 324 int refCount = ctx.decrement(); 325 if (refCount < 1) { 326 327 Session s = ctx.getSession(); 328 s.setClosed(new Timestamp(System.currentTimeMillis())); 329 update(s); 330 331 try { 332 context.publishEvent(new DestroySessionMessage(this, s 333 .getUuid())); 334 } catch (RuntimeException re) { 335 log.warn("Session destruction cancelled by event listener", re); 336 throw re; 337 } 338 // This the publishEvent returns successfully, then we update our 339 // cache 340 // since ehcache is not tx-friendly. 341 cache.removeSession(uuid); 342 } 324 343 } 325 344
