use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class AMSetupServlet method updatePlatformServerList.
/**
* Update platform server list and Organization alias
*/
private static void updatePlatformServerList(String serverURL, String hostName) throws SMSException, SSOException {
SSOToken token = getAdminSSOToken();
ServiceSchemaManager ssm = new ServiceSchemaManager("iPlanetAMPlatformService", token);
ServiceSchema ss = ssm.getGlobalSchema();
AttributeSchema as = ss.getAttributeSchema("iplanet-am-platform-server-list");
Set<String> values = as.getDefaultValues();
if (!isInPlatformList(values, serverURL)) {
String instanceName = getNextAvailableServerId(values);
values.add(serverURL + "|" + instanceName);
as.setDefaultValues(values);
// Update Organization Aliases
OrganizationConfigManager ocm = new OrganizationConfigManager(token, "/");
Map<String, Object> attrs = ocm.getAttributes("sunIdentityRepositoryService");
Set<String> origValues = (Set<String>) attrs.get("sunOrganizationAliases");
if (!origValues.contains(hostName)) {
values = new HashSet<String>();
values.add(hostName);
ocm.addAttributeValues("sunIdentityRepositoryService", "sunOrganizationAliases", values);
}
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class AuthD method getOrgConfiguredAuthenticationChain.
/**
* Returns the authentication service or chain configured for the
* given organization.
*
* @param orgDN organization DN.
* @return the authentication service or chain configured for the
* given organization.
*/
public String getOrgConfiguredAuthenticationChain(String orgDN) {
String orgAuthConfig = null;
try {
OrganizationConfigManager orgConfigMgr = getOrgConfigManager(orgDN);
ServiceConfig svcConfig = orgConfigMgr.getServiceConfig(ISAuthConstants.AUTH_SERVICE_NAME);
Map attrs = svcConfig.getAttributes();
orgAuthConfig = Misc.getMapAttr(attrs, ISAuthConstants.AUTHCONFIG_ORG);
} catch (Exception e) {
debug.error("Error in getOrgConfiguredAuthenticationChain : ", e);
}
return orgAuthConfig;
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class AllowedModulesChoiceValues method getOrgConfigManager.
/**
* Returns the OrganizationConfigManager Object for an organization.
* @param orgDN name of the org
* @param adminToken administrator Single Sign On Token.
* @return OrganizationConfigManager object
*/
private OrganizationConfigManager getOrgConfigManager(String orgDN, SSOToken adminToken) {
OrganizationConfigManager orgConfigMgr = null;
try {
if ((orgMap != null) && (!orgMap.isEmpty())) {
orgConfigMgr = (OrganizationConfigManager) orgMap.get(orgDN);
}
synchronized (orgMap) {
if (orgConfigMgr == null) {
orgConfigMgr = new OrganizationConfigManager(adminToken, orgDN);
orgMap.put(orgDN, orgConfigMgr);
}
}
} catch (Exception id) {
// do nothing
}
return orgConfigMgr;
}
use of com.sun.identity.sm.OrganizationConfigManager 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());
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class ConfigMonitoring method getRealmsList.
private void getRealmsList(String startRealm) {
String classMethod = "ConfigMonitoring.getRealmsList: ";
try {
// for startRealm
int rlmCnt = 1;
OrganizationConfigManager orgMgr = new OrganizationConfigManager(ssoToken, startRealm);
Set orgs = orgMgr.getSubOrganizationNames("*", true);
rlmCnt += orgs.size();
realmList = new ArrayList<String>(rlmCnt);
realmList.add(startRealm);
for (Iterator it = orgs.iterator(); it.hasNext(); ) {
String ss = "/" + (String) it.next();
realmList.add(ss);
}
} catch (SMSException e) {
debug.error(classMethod + "SMSException getting OrgConfigMgr: " + e.getMessage());
}
}
Aggregations