1 28 29 package org.objectweb.security.context; 30 31 35 public class SecurityCurrent { 36 37 40 private static InheritableThreadLocal threadCtx; 41 42 45 private static SecurityContext sctx = null; 46 47 50 static { 51 threadCtx = new InheritableThreadLocal (); 52 threadCtx.set(new SecurityContext()); 53 } 54 55 58 private static SecurityCurrent current = new SecurityCurrent(); 59 60 64 public static SecurityCurrent getCurrent() { 65 return current; 66 } 67 68 72 public void setSecurityContext(SecurityContext ctx) { 73 threadCtx.set(ctx); 74 } 75 76 80 public void setGlobalSecurityContext(SecurityContext ctx) { 81 sctx = ctx; 82 } 83 84 89 public SecurityContext getSecurityContext() { 90 if (sctx != null) { 91 return sctx; 92 } else { 93 return (SecurityContext) threadCtx.get(); 94 } 95 } 96 97 } | Popular Tags |