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());
}
}
Aggregations