Example usage for org.apache.shiro.realm AuthorizingRealm setName

List of usage examples for org.apache.shiro.realm AuthorizingRealm setName

Introduction

In this page you can find the example usage for org.apache.shiro.realm AuthorizingRealm setName.

Prototype

public void setName(String name) 

Source Link

Usage

From source file:juzu.plugin.shiro.impl.SecurityManagerProvider.java

License:Open Source License

private void injectRealms(JSON config, SecurityManager currentManager, InjectionContext manager)
        throws InvocationTargetException {

    JSON realmsJSON = config.getJSON("realms");

    Iterable beans = manager.resolveBeans(AuthorizingRealm.class);
    for (Object bean : beans) {
        Object instance = manager.createContext(bean);
        AuthorizingRealm realm = AuthorizingRealm.class.cast(manager.getInstance(bean, instance));
        JSON realmJSON = realmsJSON.getJSON(realm.getClass().getName());
        if (realmJSON != null) {
            if (realmJSON.get("name") != null) {
                realm.setName(realmJSON.getString("name"));
            }//from w  w w  .j  a  v a2s. c  om

            Collection<Realm> realms = ((RealmSecurityManager) currentManager).getRealms();
            if (realms == null) {
                ((RealmSecurityManager) currentManager).setRealm(realm);
            } else {
                ((RealmSecurityManager) currentManager).getRealms().add(realm);
            }
        }
    }
}