Search in sources :

Example 31 with OrganizationConfigManager

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

the class IdServicesImpl method createRealmIdentity.

private AMIdentity createRealmIdentity(SSOToken token, IdType type, String name, Map attrMap, String orgName) throws IdRepoException, SSOException {
    try {
        OrganizationConfigManager orgMgr = new OrganizationConfigManager(token, orgName);
        Map<String, Set<String>> newAttrMap = new HashMap<>(attrMap);
        if (!newAttrMap.containsKey(IdConstants.ORGANIZATION_STATUS_ATTR)) {
            newAttrMap.put(IdConstants.ORGANIZATION_STATUS_ATTR, CollectionUtils.asSet("Active"));
        }
        Map serviceAttrsMap = new HashMap();
        serviceAttrsMap.put(IdConstants.REPO_SERVICE, newAttrMap);
        orgMgr.createSubOrganization(name, serviceAttrsMap);
        return getSubRealmIdentity(token, name, orgName);
    } catch (SMSException sme) {
        DEBUG.error("AMIdentityRepository.createIdentity() - " + "Error occurred while creating " + type.getName() + ":" + name, sme);
        throw new IdRepoException(sme.getMessage());
    }
}
Also used : Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) IdRepoException(com.sun.identity.idm.IdRepoException) Map(java.util.Map) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap)

Example 32 with OrganizationConfigManager

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

the class RealmRemovedTest method setup.

@BeforeClass
public void setup() throws Exception {
    if (!migrated) {
        return;
    }
    OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
    String subRealm = SUB_REALM1.substring(1);
    ocm.createSubOrganization(subRealm, Collections.EMPTY_MAP);
    subRealm = SUB_REALM2.substring(1);
    ocm.createSubOrganization(subRealm, Collections.EMPTY_MAP);
    createApplicationPrivilege();
}
Also used : OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) BeforeClass(org.testng.annotations.BeforeClass)

Example 33 with OrganizationConfigManager

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

the class TestEvaluator method cleanup.

@AfterClass
public void cleanup() throws Exception {
    if (!migrated) {
        return;
    }
    PrivilegeManager pm = PrivilegeManager.getInstance(SUB_REALM, adminSubject);
    pm.remove(PRIVILEGE1_NAME);
    Set<AMIdentity> identities = new HashSet<AMIdentity>();
    identities.add(user1);
    identities.add(user2);
    IdRepoUtils.deleteIdentities("/", identities);
    ApplicationManager.deleteApplication(adminSubject, "/", APPL_NAME);
    OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminToken, "/");
    orgMgr.deleteSubOrganization(SUB_REALM, true);
}
Also used : AMIdentity(com.sun.identity.idm.AMIdentity) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) HashSet(java.util.HashSet) AfterClass(org.testng.annotations.AfterClass)

Example 34 with OrganizationConfigManager

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

the class UpgradeUtils method createOrgAuthConfig.

/**
     * Creates auth configurations for auth modules configuration in
     * core auth service.
     */
private static void createOrgAuthConfig(String realmName) throws Exception {
    String classMethod = "UpgradeUtils:createOrgAuthConfig: ";
    OrganizationConfigManager org = new OrganizationConfigManager(ssoToken, realmName);
    ServiceConfig orgConfig = org.getServiceConfig(AUTH_SERVICE_NAME);
    if (orgConfig != null) {
        Map aa = orgConfig.getAttributes();
        if (debug.messageEnabled()) {
            debug.message(classMethod + "Org is :" + realmName);
            debug.message(classMethod + "Attribute Map is :" + aa);
        }
        String orgName = realmName;
        if (LDAPUtils.isDN(realmName)) {
            orgName = LDAPUtils.rdnValueFromDn(realmName);
        }
        String authConfigName = orgName + "-authconfig";
        String adminAuthConfigName = orgName + "-admin-authconfig";
        Set authConfigAttrValue = (Set) aa.get(ATTR_ORG_AUTH_MODULE);
        if (debug.messageEnabled()) {
            debug.message(classMethod + "authConfigAttrValue : " + authConfigAttrValue);
        }
        Set newVal = new HashSet();
        if (authConfigAttrValue.size() != 1 && !authConfigAttrValue.contains(authConfigName)) {
            newVal.add(authConfigName);
            orgConfig.replaceAttributeValues(ATTR_ORG_AUTH_MODULE, authConfigAttrValue, newVal);
        }
        Set adminConfigAttrValue = (Set) aa.get(ATTR_ADMIN_AUTH_MODULE);
        if (debug.messageEnabled()) {
            debug.message("adminauthConfigAttrValue : " + adminConfigAttrValue);
        }
        if (adminConfigAttrValue.size() != 1 && !adminConfigAttrValue.contains(adminAuthConfigName)) {
            newVal.clear();
            newVal.add(adminAuthConfigName);
            orgConfig.replaceAttributeValues(ATTR_ADMIN_AUTH_MODULE, adminConfigAttrValue, newVal);
        }
        aa = orgConfig.getAttributes();
        ServiceConfig s = org.getServiceConfig(AUTH_CONFIG_SERVICE);
        ServiceConfig authConfig = s.getSubConfig(NAMED_CONFIG);
        if (authConfig == null) {
            s.addSubConfig(NAMED_CONFIG, null, 0, null);
            authConfig = s.getSubConfig(NAMED_CONFIG);
        }
        Map aMap = new HashMap();
        aMap.put(ATTR_AUTH_CONFIG, authConfigAttrValue);
        authConfig.addSubConfig(authConfigName, SUB_NAMED_CONFIG, 0, aMap);
        aMap.clear();
        aMap.put(ATTR_AUTH_CONFIG, adminConfigAttrValue);
        authConfig.addSubConfig(adminAuthConfigName, SUB_NAMED_CONFIG, 0, aMap);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) HashMap(java.util.HashMap) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) ByteString(org.forgerock.opendj.ldap.ByteString) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 35 with OrganizationConfigManager

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

the class AbstractUpgradeStep method getRealmNames.

/**
     * Returns the names of the realms available in the OpenAM configuration. The returned set is ordered, so the realm
     * hierarchy maintained (i.e. subrealm precedes sub-subrealm).
     *
     * @return The set of realmnames available in OpenAM.
     * @throws UpgradeException In case retrieving the realmnames was not successful.
     */
protected final Set<String> getRealmNames() throws UpgradeException {
    try {
        OrganizationConfigManager ocm = new OrganizationConfigManager(getAdminToken(), "/");
        Set<String> realms = CollectionUtils.asOrderedSet("/");
        realms.addAll(ocm.getSubOrganizationNames("*", true));
        if (DEBUG.messageEnabled()) {
            DEBUG.message("Discovered realms in the configuration: " + realms);
        }
        return realms;
    } catch (SMSException smse) {
        DEBUG.error("An error occurred while trying to retrieve the list of realms", smse);
        throw new UpgradeException("Unable to retrieve realms from SMS");
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager)

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