Example usage for org.apache.shiro.mgt RealmSecurityManager destroy

List of usage examples for org.apache.shiro.mgt RealmSecurityManager destroy

Introduction

In this page you can find the example usage for org.apache.shiro.mgt RealmSecurityManager destroy.

Prototype

public void destroy() 

Source Link

Usage

From source file:Global.java

License:Open Source License

@Override
public void onStop(Application application) {

    Logger.debug("DOING ON STOP");

    HibernateSessionFactory.closeSession();
    HibernateSessionFactory.unloadAll();
    DatabaseManager dbManager = DatabaseManager.getInstance();
    dbManager.initialize("default");
    dbManager.closeIfConnectionOpen();//from   ww w.  ja v a2 s .  c  o  m
    dbManager.unloadAll();

    RealmSecurityManager mgr = (RealmSecurityManager) SecurityUtils.getSecurityManager();

    Collection<Realm> realmCollection = mgr.getRealms();
    realmCollection.clear();

    /*
    Iterator<Realm> i = realmCollection.iterator();
            
    //There should be only one realm?
    while(i.hasNext()) {
            
    try {
        SampleRealm r = (SampleRealm) i.next();
            
        r.invalidateUser(SecurityUtils.getSubject().getPrincipals());
    } catch (Exception ee) {
            
    }
            
    }*/

    mgr.destroy();

    super.onStop(application);
}