Search in sources :

Example 71 with OrganizationConfigManager

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);
        }
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) CollectionUtils.asSet(org.forgerock.openam.utils.CollectionUtils.asSet) LicenseSet(org.forgerock.openam.license.LicenseSet) HashSet(java.util.HashSet) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AttributeSchema(com.sun.identity.sm.AttributeSchema) DirUserObject(com.sun.identity.common.configuration.ServerConfigXML.DirUserObject) ServerObject(com.sun.identity.common.configuration.ServerConfigXML.ServerObject) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 72 with OrganizationConfigManager

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;
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) SSOException(com.iplanet.sso.SSOException) IdRepoException(com.sun.identity.idm.IdRepoException) SMSException(com.sun.identity.sm.SMSException) IOException(java.io.IOException) SessionException(com.iplanet.dpro.session.SessionException)

Example 73 with OrganizationConfigManager

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;
}
Also used : OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) SMSException(com.sun.identity.sm.SMSException)

Example 74 with OrganizationConfigManager

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

Example 75 with OrganizationConfigManager

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());
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator)

Aggregations

OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)144 SMSException (com.sun.identity.sm.SMSException)87 Set (java.util.Set)79 HashSet (java.util.HashSet)54 SSOException (com.iplanet.sso.SSOException)50 Map (java.util.Map)48 HashMap (java.util.HashMap)40 SSOToken (com.iplanet.sso.SSOToken)33 IdRepoException (com.sun.identity.idm.IdRepoException)32 Iterator (java.util.Iterator)28 AMIdentity (com.sun.identity.idm.AMIdentity)23 CLIException (com.sun.identity.cli.CLIException)21 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)20 ServiceConfig (com.sun.identity.sm.ServiceConfig)17 IOutput (com.sun.identity.cli.IOutput)15 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)15 List (java.util.List)10 ForbiddenException (org.forgerock.json.resource.ForbiddenException)9 BadRequestException (org.forgerock.json.resource.BadRequestException)8 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)8