Search in sources :

Example 36 with OrganizationConfigManager

use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.

the class ServerConfigBase method existsInOrganizationAlias.

/*
     * Check if the server entry is listed in the organization
     * alias list
     *
     * @param ssoToken of the admin user
     * @param instanceName name of the server instance
     * @return <code>true</code> if server instance exists in org alias 
     */
protected boolean existsInOrganizationAlias(SSOToken ssoToken, String instanceName) throws SMSException {
    OrganizationConfigManager ocm = new OrganizationConfigManager(ssoToken, "/");
    Map attrMap = ocm.getAttributes(ServiceManager.REALM_SERVICE);
    Set values = (Set) attrMap.get(OrganizationConfigManager.SUNORG_ALIAS);
    return values.contains(instanceName);
}
Also used : Set(java.util.Set) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Map(java.util.Map)

Example 37 with OrganizationConfigManager

use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.

the class PolicyManager method getOrgAliasMappedResourceNames.

private Set getOrgAliasMappedResourceNames() throws PolicyException {
    if (debug.messageEnabled()) {
        debug.message("PolicyManager.getOrgAliasMappedResourceNames(): " + " entering:orgName = " + org);
    }
    Set managedResourceNames = new HashSet(3);
    if (ocm == null) {
        try {
            ocm = new OrganizationConfigManager(token, givenOrgName);
        } catch (SMSException sme) {
            String[] objs = { org };
            throw (new PolicyException(ResBundleUtils.rbName, "unable_to_get_org_config_manager_for_org", objs, sme));
        }
    }
    Set orgAliases = null;
    try {
        Map orgAttributes = ocm.getAttributes(ID_REPO_SERVICE);
        orgAliases = (Set) orgAttributes.get(ORG_ALIAS);
        if (debug.messageEnabled()) {
            debug.message("PolicyManager.getOrgAliasMappedResourceNames(): " + " orgName = " + org + ":orgAliases=" + orgAliases);
        }
    } catch (SMSException sme) {
        String[] objs = { org };
        throw (new PolicyException(ResBundleUtils.rbName, "unable_to_get_org_alias_for_org", objs, sme));
    }
    if (orgAliases != null) {
        Iterator iter = orgAliases.iterator();
        while (iter.hasNext()) {
            String orgAlias = (String) iter.next();
            managedResourceNames.add(ORG_ALIAS_URL_HTTP_PREFIX + orgAlias.trim() + ORG_ALIAS_URL_SUFFIX);
            managedResourceNames.add(ORG_ALIAS_URL_HTTPS_PREFIX + orgAlias.trim() + ORG_ALIAS_URL_SUFFIX);
        }
    }
    if (debug.messageEnabled()) {
        debug.message("PolicyManager.getOrgAliasMappedResourceNames(): " + " returning: orgName = " + org + ":orgAliases=" + orgAliases + ":managedResourceNames=" + managedResourceNames);
    }
    return managedResourceNames;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 38 with OrganizationConfigManager

use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.

the class ConfigureData method setRealmAttributes.

private void setRealmAttributes() throws SMSException {
    OrganizationConfigManager ocm = new OrganizationConfigManager(ssoToken, "/");
    Map map = new HashMap();
    Set set1 = new HashSet(2);
    set1.add("Active");
    map.put("sunOrganizationStatus", set1);
    Set set2 = new HashSet(2);
    Map defaultValues = ServicesDefaultValues.getDefaultValues();
    set2.add(DNToName((String) defaultValues.get(SetupConstants.CONFIG_VAR_ROOT_SUFFIX)));
    map.put("sunOrganizationAliases", set2);
    ocm.setAttributes("sunIdentityRepositoryService", map);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 39 with OrganizationConfigManager

use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.

the class ConfigureData method createRealm.

private void createRealm(String realmName) throws SMSException {
    String parentRealm = getParentRealm(realmName);
    String childRealm = getChildRealm(realmName);
    OrganizationConfigManager ocm = new OrganizationConfigManager(ssoToken, parentRealm);
    ocm.createSubOrganization(childRealm, null);
}
Also used : OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager)

Example 40 with OrganizationConfigManager

use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.

the class ConfigurationBase method updateOrganizationAlias.

protected static void updateOrganizationAlias(SSOToken ssoToken, String instanceName, boolean bAdd) throws SMSException {
    String hostName = null;
    try {
        URL url = new URL(instanceName);
        hostName = url.getHost();
    } catch (MalformedURLException e) {
        throw new RuntimeException(e.getMessage());
    }
    OrganizationConfigManager ocm = new OrganizationConfigManager(ssoToken, "/");
    Map allAttrs = ocm.getAttributes(ServiceManager.REALM_SERVICE);
    Set values = (Set) allAttrs.get(OrganizationConfigManager.SUNORG_ALIAS);
    if (bAdd) {
        if (!values.contains(hostName)) {
            values.add(hostName);
            ocm.setAttributes(ServiceManager.REALM_SERVICE, allAttrs);
        }
    } else {
        if (values.contains(hostName)) {
            values.remove(hostName);
            ocm.setAttributes(ServiceManager.REALM_SERVICE, allAttrs);
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Map(java.util.Map) URL(java.net.URL)

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