Search in sources :

Example 1 with SSOServerRealmInfo

use of com.sun.identity.monitoring.SSOServerRealmInfo in project OpenAM by OpenRock.

the class ConfigMonitoring method getAllRealms.

private void getAllRealms(String startRealm) {
    String classMethod = "ConfigMonitoring.getAllRealms: ";
    StringBuilder sb = new StringBuilder(classMethod);
    if (debug.messageEnabled()) {
        sb.append("orgnames starting from ").append(startRealm).append(":\n").append("  ").append(startRealm).append("\n");
    }
    try {
        OrganizationConfigManager orgMgr = new OrganizationConfigManager(ssoToken, startRealm);
        Set orgs = orgMgr.getSubOrganizationNames("*", true);
        /*
             *  the orgs Set of realms seems to have some sort of
             *  ordering to it, going through each of "/"'s realms.
             *  don't know that we need to count on it, but it's
             *  nice.
             */
        // do the top-level realm first
        HashMap authHM = getRealmAuthMods("/");
        /*
             *  get agent information... just for info, not processing
             */
        if (debug.messageEnabled()) {
            getAgentTypes();
        }
        SSOServerRealmInfo srInfo = new SSOServerRealmInfo.SSOServerRealmInfoBuilder("/").authModules(authHM).build();
        int i = Agent.realmConfigMonitoringAgent(srInfo);
        /*
             *  if realmConfigMonitoringAgent() had a problem with
             *  this realm, there's not much point in processing its
             *  subrealms...
             */
        if (i != 0) {
            debug.error(classMethod + "error processing root realm; " + "skip subrealms.");
            return;
        }
        // then all the subrealms; they have leading "/"
        for (Iterator it = orgs.iterator(); it.hasNext(); ) {
            String ss = "/" + (String) it.next();
            if (debug.messageEnabled()) {
                sb.append("  ").append(ss).append("\n");
            }
            /* get this realm's auth modules */
            try {
                AMIdentityRepository idRepo = new AMIdentityRepository(ssoToken, ss);
                AMIdentity thisRealmAMId = idRepo.getRealmIdentity();
                String currentRealmAMIdName = thisRealmAMId.getRealm();
                Set s1 = getAuthModules(currentRealmAMIdName);
                authHM = new HashMap();
                if (!s1.isEmpty()) {
                    for (Iterator it2 = s1.iterator(); it2.hasNext(); ) {
                        AMAuthenticationInstance ai = (AMAuthenticationInstance) it2.next();
                        String stname = ai.getName();
                        String sttype = ai.getType();
                        authHM.put(stname, sttype);
                    }
                    /*
                         *  all get an "Application" instance/type by default
                         */
                    authHM.put("Application", "Application");
                }
                /*
                     *  get agent information
                     *  don't need with the *Specific versions... just
                     *  needed to see what attributes there were (and values)
                     */
                srInfo = new SSOServerRealmInfo.SSOServerRealmInfoBuilder(ss).authModules(authHM).build();
                i = Agent.realmConfigMonitoringAgent(srInfo);
                /*
                     *  problem with this subrealm, but at least the
                     *  root realm was added.  just output error and do next
                     *  subrealm.
                     */
                if (i != 0) {
                    debug.error(classMethod + "error processing realm " + ss);
                }
            } catch (IdRepoException ire) {
                debug.error(classMethod + "IdRepoException getting AMIdentityRepository" + " object for realm: " + ss + ": " + ire.getMessage());
            } catch (SSOException ssoe) {
                debug.error(classMethod + "SSOException getting info for realm " + ss + ": " + ssoe.getMessage());
            }
        }
        if (debug.messageEnabled()) {
            debug.message(sb.toString());
        }
    } catch (SMSException e) {
        debug.error(classMethod + "SMSException getting OrgConfigMgr: " + e.getMessage());
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) SSOServerRealmInfo(com.sun.identity.monitoring.SSOServerRealmInfo) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMIdentity(com.sun.identity.idm.AMIdentity) Iterator(java.util.Iterator) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) AMAuthenticationInstance(com.sun.identity.authentication.config.AMAuthenticationInstance)

Aggregations

SSOException (com.iplanet.sso.SSOException)1 AMAuthenticationInstance (com.sun.identity.authentication.config.AMAuthenticationInstance)1 AMIdentity (com.sun.identity.idm.AMIdentity)1 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 SSOServerRealmInfo (com.sun.identity.monitoring.SSOServerRealmInfo)1 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)1 SMSException (com.sun.identity.sm.SMSException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1