/** * Binds a {@link Subject} and {@link org.apache.shiro.mgt.SecurityManager SecurityManager} to the * {@link ThreadContext} so they can be retrieved later by any * {@code SecurityUtils.}{@link org.apache.shiro.SecurityUtils#getSubject() getSubject()} calls that might occur * during the thread's execution. * <p/> * Prior to binding, the {@code ThreadContext}'s existing {@link ThreadContext#getResources() resources} are * retained so they can be restored later via the {@link #restore restore} call. */ public void bind() { SecurityManager securityManager = this.securityManager; if ( securityManager == null ) { //try just in case the constructor didn't find one at the time: securityManager = ThreadContext.getSecurityManager(); } this.originalResources = ThreadContext.getResources(); ThreadContext.remove(); ThreadContext.bind(this.subject); if (securityManager != null) { ThreadContext.bind(securityManager); } }
/** * Binds a {@link Subject} and {@link org.apache.shiro.mgt.SecurityManager SecurityManager} to the * {@link ThreadContext} so they can be retrieved later by any * {@code SecurityUtils.}{@link org.apache.shiro.SecurityUtils#getSubject() getSubject()} calls that might occur * during the thread's execution. * <p/> * Prior to binding, the {@code ThreadContext}'s existing {@link ThreadContext#getResources() resources} are * retained so they can be restored later via the {@link #restore restore} call. */ public void bind() { SecurityManager securityManager = this.securityManager; if ( securityManager == null ) { //try just in case the constructor didn't find one at the time: securityManager = ThreadContext.getSecurityManager(); } this.originalResources = ThreadContext.getResources(); ThreadContext.remove(); ThreadContext.bind(this.subject); if (securityManager != null) { ThreadContext.bind(securityManager); } }
/** * Binds a {@link Subject} and {@link org.apache.shiro.mgt.SecurityManager SecurityManager} to the * {@link ThreadContext} so they can be retrieved later by any * {@code SecurityUtils.}{@link org.apache.shiro.SecurityUtils#getSubject() getSubject()} calls that might occur * during the thread's execution. * <p/> * Prior to binding, the {@code ThreadContext}'s existing {@link ThreadContext#getResources() resources} are * retained so they can be restored later via the {@link #restore restore} call. */ public void bind() { SecurityManager securityManager = this.securityManager; if ( securityManager == null ) { //try just in case the constructor didn't find one at the time: securityManager = ThreadContext.getSecurityManager(); } this.originalResources = ThreadContext.getResources(); ThreadContext.remove(); ThreadContext.bind(this.subject); if (securityManager != null) { ThreadContext.bind(securityManager); } }