List of usage examples for org.apache.shiro.util ThreadContext unbindSecurityManager
public static SecurityManager unbindSecurityManager()
From source file:com.github.sdorra.shiro.ShiroRule.java
License:Open Source License
/** * Method description//w w w . j av a 2s . co m * */ private void tearDownShiro() { try { SecurityManager securityManager = SecurityUtils.getSecurityManager(); LifecycleUtils.destroy(securityManager); ThreadContext.unbindSecurityManager(); ThreadContext.unbindSubject(); ThreadContext.remove(); } catch (UnavailableSecurityManagerException e) { // we don't care about this when cleaning up the test environment // (for example, maybe the subclass is a unit test and it didn't // need a SecurityManager instance because it was using only mock Subject instances) } SecurityUtils.setSecurityManager(null); }
From source file:ddf.catalog.event.retrievestatus.AbstractDownloadsStatusEventPublisherTest.java
License:Open Source License
@After public void tearDownTest() { // Remove the security from the thread after every test ThreadContext.unbindSecurityManager(); ThreadContext.unbindSubject(); }
From source file:juzu.plugin.shiro.impl.ShiroPlugin.java
License:Open Source License
public void invoke(Request request) { if (descriptor != null) { try {/*from w ww . j av a2 s. co m*/ if (manager == null) { SecurityManagerProvider provider = new SecurityManagerProvider(descriptor.getConfig()); manager = provider.get(); } start(); descriptor.invoke(request); } catch (InvocationTargetException e) { throw new RuntimeException(e); } finally { ThreadContext.unbindSubject(); ThreadContext.unbindSecurityManager(); } } else { request.invoke(); } }
From source file:juzu.plugin.shiro.impl.ShiroService.java
License:Open Source License
@Override public Response handle(Stage.Handler stage) { if (descriptor != null) { try {/*w ww.ja v a 2 s .c o m*/ if (manager == null) { SecurityManagerProvider provider = new SecurityManagerProvider(descriptor.getConfig()); manager = provider.get(); } start(); return descriptor.invoke(stage); } catch (InvocationTargetException e) { throw new RuntimeException(e); } finally { ThreadContext.unbindSubject(); ThreadContext.unbindSecurityManager(); } } else { return stage.invoke(); } }
From source file:org.apache.aries.jax.rs.shiro.authc.impl.SecurityManagerAssociatingFilter.java
License:Apache License
/** * Clean up after the request/*from w w w . j a v a 2s . c om*/ */ @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { _LOG.debug("Cleaning up the Shiro Security Context"); Subject subject = ThreadContext.getSubject(); ThreadContext.unbindSecurityManager(); ThreadContext.unbindSubject(); if (subject != null && !subject.isAuthenticated()) { // Not authenticated. Check for incoming session cookie Cookie cookie = requestContext.getCookies().get(SESSION_COOKIE_NAME); // If we have a session cookie then it should be deleted if (cookie != null) { _LOG.debug( "The subject associated with this request is not authenticated, removing the session cookie"); responseContext.getHeaders().add(SET_COOKIE, getDeletionCookie(requestContext)); } } }
From source file:org.apache.batchee.shiro.ShiroTest.java
License:Apache License
@AfterClass public static void resetShiro() { ThreadContext.unbindSubject(); ThreadContext.unbindSecurityManager(); ThreadContext.remove(); }
From source file:org.atteo.moonshine.shiro.ShiroService.java
License:Apache License
@Override public void close() { SecurityUtils.setSecurityManager(null); ThreadContext.unbindSecurityManager(); ThreadContext.unbindSubject(); }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswEndpointTest.java
License:Open Source License
@org.junit.After public void tearDownClass() { if (csw != null) { csw.destroy(); } ThreadContext.unbindSubject(); ThreadContext.unbindSecurityManager(); }
From source file:org.killbill.billing.entitlement.EntitlementTestSuiteWithEmbeddedDB.java
License:Apache License
protected void configureShiro() { final Ini config = new Ini(); config.addSection("users"); config.getSection("users").put("EntitlementUser", "password, entitlement"); config.addSection("roles"); config.getSection("roles").put("entitlement", Permission.ACCOUNT_CAN_CREATE.toString() + "," + Permission.ENTITLEMENT_CAN_CREATE.toString() + "," + Permission.ENTITLEMENT_CAN_CHANGE_PLAN.toString() + "," + Permission.ENTITLEMENT_CAN_PAUSE_RESUME.toString() + "," + Permission.ENTITLEMENT_CAN_TRANSFER.toString() + "," + Permission.ENTITLEMENT_CAN_CANCEL.toString()); // Reset the security manager ThreadContext.unbindSecurityManager(); final Factory<SecurityManager> factory = new IniSecurityManagerFactory(config); final SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); }
From source file:org.killbill.billing.payment.dispatcher.CallableWithRequestData.java
License:Apache License
@Override public T call() throws Exception { try {/* ww w. j ava2 s .c om*/ Request.setPerThreadRequestData(requestData); UUIDs.setRandom(random); ThreadContext.bind(securityManager); ThreadContext.bind(subject); MDC.setContextMap(mdcContextMap); return delegate.call(); } finally { Request.resetPerThreadRequestData(); UUIDs.setRandom(null); ThreadContext.unbindSecurityManager(); ThreadContext.unbindSubject(); MDC.clear(); } }