Example usage for org.apache.shiro.util LifecycleUtils destroy

List of usage examples for org.apache.shiro.util LifecycleUtils destroy

Introduction

In this page you can find the example usage for org.apache.shiro.util LifecycleUtils destroy.

Prototype

public static void destroy(Collection c) 

Source Link

Document

Calls #destroy(Object) destroy for each object in the collection.

Usage

From source file:com.github.sdorra.shiro.ShiroRule.java

License:Open Source License

/**
 * Method description//from w  w  w  . j  a v a2s. 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:com.github.zbiljic.shiro.cache.infinispan.InfinispanManagerTest.java

License:Open Source License

@After
public void tearDown() {
    LifecycleUtils.destroy(cacheManager);
}

From source file:com.thesett.util.security.shiro.ShiroUtils.java

License:Apache License

/**
 * Performs a more complete tear down of shiro, removing the subject from the current thread and closing the
 * security manager./*from  w w  w  .  ja  v a2  s.  c  o  m*/
 */
public static void tearDownShiro() {
    clearSubject();

    try {
        SecurityManager securityManager = getSecurityManager();
        LifecycleUtils.destroy(securityManager);
    } catch (UnavailableSecurityManagerException e) {
        // This can be ignored as it only happens when there is no security manager.
    }

    setSecurityManager(null);
}

From source file:net.maritimecloud.common.infrastructure.shiro.AbstractShiroResourceTest.java

License:Apache License

@AfterClass
public static void tearDownShiro() {
    doClearSubject();/*from   w  w w  .  j a v  a 2  s  .  com*/
    try {
        SecurityManager securityManager = getSecurityManager();
        LifecycleUtils.destroy(securityManager);
    } 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)
    }
    setSecurityManager(null);
}

From source file:org.apache.usergrid.security.CustomResolverTest.java

License:Apache License

@AfterClass
public static void tearDownShiro() {
    doClearSubject();/*  w ww. ja  va  2  s.co  m*/

    try {
        org.apache.shiro.mgt.SecurityManager securityManager = SecurityUtils.getSecurityManager();
        LifecycleUtils.destroy(securityManager);
    } 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:org.commonjava.auth.shiro.couch.test.CouchShiroTestFixture.java

License:Apache License

public static void teardownSecurityManager() {
    clearSubject();/*  ww w . j  av  a2 s . c om*/

    try {
        org.apache.shiro.mgt.SecurityManager securityManager = SecurityUtils.getSecurityManager();

        LifecycleUtils.destroy(securityManager);
    } catch (UnavailableSecurityManagerException e) {
        // we don't care about this when cleaning up the test environment
    }

    SecurityUtils.setSecurityManager(null);
}

From source file:org.obiba.agate.security.SecurityManagerFactory.java

License:Open Source License

@PreDestroy
public void destroySecurityManager() {
    log.debug("Shutdown SecurityManager");
    // Destroy the security manager.
    SecurityUtils.setSecurityManager(null);
    LifecycleUtils.destroy(securityManager);
    securityManager = null;//from w w  w.  ja  v  a 2 s. c  om
}

From source file:org.obiba.opal.core.runtime.security.OpalSecurityManagerFactory.java

License:Open Source License

@PreDestroy
public void destroySecurityManager() {
    // Destroy the security manager.
    SecurityUtils.setSecurityManager(null);
    LifecycleUtils.destroy(securityManager);
    securityManager = null;//  w w  w.ja v a2  s  . co  m
}

From source file:uk.co.q3c.v7.base.shiro.AbstractShiroTest.java

License:Apache License

@AfterClass
public static void tearDownShiro() {
    doClearSubject();//from ww w . j av a2s .  c  o  m
    try {
        SecurityManager securityManager = getSecurityManager();
        LifecycleUtils.destroy(securityManager);
    } 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)
    }
    setSecurityManager(null);
}