lifetime = cache.getDefaultLifetime(); DomainInfo info = new DomainInfo(lifetime); info.loginCtx = lc; info.subject = new Subject();
/** * This */ public void destroy() { if( trace ) { log.trace("destroy, subject="+subject+", this="+this +", activeUsers="+activeUsers); } synchronized( this ) { if( activeUsers == 0 ) logout(); else { if( trace ) log.trace("destroy saw activeUsers="+activeUsers); needsDestroy = true; } } } public Object getValue()
tmp.append(info.toString()); tmp.append(";credential.class="); if (credential != null)
tmp.append(info.toString()); tmp.append(";credential.class="); if( credential != null )
lifetime = cache.getDefaultLifetime(); DomainInfo info = new DomainInfo(lifetime); info.loginCtx = lc; info.subject = new Subject();
/** Map the argument principal from the deployment environment principal to the developer environment. This is called by the EJB context getCallerPrincipal() to return the Principal as described by the EJB developer domain. @return a Principal object that is valid in the deployment environment if one exists. If no Subject exists or the Subject has no principals then the argument principal is returned. */ public Principal getPrincipal(Principal principal) { if(domainCache == null) return principal; Principal result = principal; // Get the CallerPrincipal group member synchronized( domainCache ) { DomainInfo info = getCacheInfo(principal, false); if( trace ) log.trace("getPrincipal, cache info: "+info); if( info != null ) { result = info.callerPrincipal; // If the mapping did not have a callerPrincipal just use principal if( result == null ) result = principal; info.release(); } } return result; }
cacheInfo.release();
/** An accessor method that synchronizes access on the domainCache to avoid a race condition that can occur when the cache entry expires in the presence of multi-threaded access. The allowRefresh flag should be true for authentication accesses and false for other accesses. Previously the other accesses included authorization and caller principal mapping. Now the only use of the @param principal - the caller identity whose cached credentials are to be accessed. @param allowRefresh - a flag indicating if the cache access should flush any expired entries. */ private DomainInfo getCacheInfo(Principal principal, boolean allowRefresh) { if( domainCache == null ) return null; DomainInfo cacheInfo = null; synchronized( domainCache ) { if( allowRefresh == true ) cacheInfo = (DomainInfo) domainCache.get(principal); else cacheInfo = (DomainInfo) domainCache.peek(principal); if( cacheInfo != null ) cacheInfo.acquire(); } return cacheInfo; }
/** Map the argument principal from the deployment environment principal to the developer environment. This is called by the EJB context getCallerPrincipal() to return the Principal as described by the EJB developer domain. @return a Principal object that is valid in the deployment environment if one exists. If no Subject exists or the Subject has no principals then the argument principal is returned. */ public Principal getPrincipal(Principal principal) { if (domainCache == null) return principal; Principal result = principal; // Get the CallerPrincipal group member synchronized (domainCache) { DomainInfo info = getCacheInfo(principal, false); if (trace) log.trace("getPrincipal, cache info: " + info); if (info != null) { result = info.callerPrincipal; // If the mapping did not have a callerPrincipal just use principal if (result == null) result = principal; info.release(); } } return result; }
/** An accessor method that synchronizes access on the domainCache to avoid a race condition that can occur when the cache entry expires in the presence of multi-threaded access. The allowRefresh flag should be true for authentication accesses and false for other accesses. Previously the other accesses included authorization and caller principal mapping. Now the only use of the @param principal - the caller identity whose cached credentials are to be accessed. @param allowRefresh - a flag indicating if the cache access should flush any expired entries. */ private DomainInfo getCacheInfo(Principal principal, boolean allowRefresh) { if (domainCache == null) return null; DomainInfo cacheInfo = null; synchronized (domainCache) { if (allowRefresh == true) cacheInfo = (DomainInfo) domainCache.get(principal); else cacheInfo = (DomainInfo) domainCache.peek(principal); if (cacheInfo != null) cacheInfo.acquire(); } return cacheInfo; }
synchronized int release() { int users = activeUsers --; if( needsDestroy == true && users == 0 ) { if( trace ) log.trace("needsDestroy is true, doing logout"); logout(); } return users; } synchronized void logout()