/** * Completely {@link ThreadContext#remove removes} the {@code ThreadContext} state. Typically this method should * only be called in special cases - it is more 'correct' to {@link #restore restore} a thread to its previous * state than to clear it entirely. */ public void clear() { ThreadContext.remove(); } }
/** * Convenience method that simplifies removal of the application's SecurityManager instance from the thread. * <p/> * The implementation just helps reduce casting and remembering of the ThreadContext key name, i.e it is * merely a convenient wrapper for the following: * <p/> * <code>return (SecurityManager)remove( SECURITY_MANAGER_KEY );</code> * <p/> * If you wish to just retrieve the object from the thread without removing it (so it can be retrieved later * during thread execution), use the {@link #getSecurityManager() getSecurityManager()} method instead. * * @return the application's SecurityManager instance previously bound to the thread, or <tt>null</tt> if there * was none bound. * @since 0.9 */ public static SecurityManager unbindSecurityManager() { return (SecurityManager) remove(SECURITY_MANAGER_KEY); }
/** * Convenience method that simplifies removal of a thread-local Subject from the thread. * <p/> * The implementation just helps reduce casting and remembering of the ThreadContext key name, i.e it is * merely a convenient wrapper for the following: * <p/> * <code>return (Subject)remove( SUBJECT_KEY );</code> * <p/> * If you wish to just retrieve the object from the thread without removing it (so it can be retrieved later during * thread execution), you should use the {@link #getSubject() getSubject()} method for that purpose. * * @return the Subject object previously bound to the thread, or <tt>null</tt> if there was none bound. * @since 0.2 */ public static Subject unbindSubject() { return (Subject) remove(SUBJECT_KEY); }
/** * {@link ThreadContext#remove Remove}s all thread-state that was bound by this instance. If any previous * thread-bound resources existed prior to the {@link #bind bind} call, they are restored back to the * {@code ThreadContext} to ensure the thread state is exactly as it was before binding. */ public void restore() { ThreadContext.remove(); if (!CollectionUtils.isEmpty(this.originalResources)) { ThreadContext.setResources(this.originalResources); } }
@Before public void setUp() { ThreadContext.remove(); }
@After public void teardown() { ThreadContext.remove(); } }
@After public void tearDown() { ThreadContext.remove(); }
@Before public void setup() { ThreadContext.remove(); }
@After public void tearDown() { ThreadContext.remove(); }
@After public void tearDown() { ThreadContext.remove(); }
@Override public void close() { if (this.securityManager != null) { this.securityManager.close(); } if (this.postProcessor != null) { this.postProcessor.close(); } ThreadContext.remove(); SecurityUtils.setSecurityManager(null); }
@Override public void logout() { Subject currentUser = getSubject(); try { logger.debug("Logging out " + currentUser.getPrincipal()); currentUser.logout(); } catch (ShiroException e) { logger.info("error logging out: " + currentUser.getPrincipal()); throw new GemFireSecurityException(e.getMessage(), e); } // clean out Shiro's thread local content ThreadContext.remove(); }
@After public void tearDown() { sm.destroy(); ThreadContext.remove(); }
@Before public void setup() { ThreadContext.remove(); sm = new DefaultSessionManager(); }
@After public void tearDown() { sm.destroy(); ThreadContext.remove(); }
@After public void tearDown() { SecurityUtils.setSecurityManager(null); securityManager.destroy(); ThreadContext.remove(); }
@Before public void setup() { ThreadContext.remove(); realm = new TestActiveDirectoryRealm(); securityManager = new DefaultSecurityManager(realm); SecurityUtils.setSecurityManager(securityManager); }
@After public void tearDown() { final String testName = name.getMethodName(); shutDown(testName); SecurityUtils.setSecurityManager(null); securityManager.destroy(); ThreadContext.remove(); }
@Before public void setup() { ThreadContext.remove(); sm = new DefaultSessionManager(); this.session = new DelegatingSession(sm, new DefaultSessionKey(sm.start(null).getId())); }
@Before public void setup() { ThreadContext.remove(); Ini config = new Ini(); config.setSectionProperty("main", "myRealm", "org.apache.shiro.realm.jdbc.JdbcRealm"); config.setSectionProperty("main", "myRealmCredentialsMatcher", "org.apache.shiro.authc.credential.Sha256CredentialsMatcher"); config.setSectionProperty("main", "myRealm.credentialsMatcher", "$myRealmCredentialsMatcher"); config.setSectionProperty("main", "securityManager.sessionManager.sessionValidationSchedulerEnabled", "false"); IniSecurityManagerFactory factory = new IniSecurityManagerFactory(config); securityManager = (DefaultSecurityManager) factory.createInstance(); SecurityUtils.setSecurityManager(securityManager); // Create a database and realm for the test createRealm(name.getMethodName()); }