Search in sources :

Example 1 with OrganizationConfigManager

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

the class DelegationPolicyImpl method initialize.

/**
     * Initialize (or configure) the <code>DelegationInterface</code>
     * object. Usually it will be initialized with the environmrnt
     * parameters set by the system administrator via Service management service.
     *
     * @param token <code>SSOToken</code> of an administrator
     * @param configParams configuration parameters as a <code>Map</code>.
     * The values in the <code>Map</code> is <code>java.util.Set</code>,
     * which contains one or more configuration parameters.
     *
     * @throws DelegationException if an error occurred during
     * initialization of <code>DelegationInterface</code> instance
     */
public void initialize(SSOToken token, Map configParams) throws DelegationException {
    this.appToken = token;
    try {
        maxCacheSize = SystemProperties.getAsInt(CONFIGURED_CACHE_SIZE, DEFAULT_CACHE_SIZE);
        // specifying cache size as 0 would virtually disable the delegation cache.
        if (maxCacheSize < 0) {
            maxCacheSize = DEFAULT_CACHE_SIZE;
        }
        delegationCache = new Cache(maxCacheSize);
        if (DelegationManager.debug.messageEnabled()) {
            DelegationManager.debug.message("DelegationPolicyImpl.initialize(): cache size=" + maxCacheSize);
        }
        pe = new PolicyEvaluator(POLICY_REPOSITORY_REALM, DelegationManager.DELEGATION_SERVICE);
        // listen on delegation policy changes. once there is 
        // delegation policy change, we need to update the cache.
        pe.addPolicyListener(this);
        // listen on root realm subject changes.
        AMIdentityRepository idRepo = new AMIdentityRepository(appToken, "/");
        idRepo.addEventListener(this);
        if (DelegationManager.debug.messageEnabled()) {
            DelegationManager.debug.message("DelegationPolicyImpl: IdRepo event listener added " + "for root realm.");
        }
        // listen on sub realm subject changes.     
        OrganizationConfigManager ocm = new OrganizationConfigManager(appToken, "/");
        Set orgNames = ocm.getSubOrganizationNames("*", true);
        if ((orgNames != null) && (!orgNames.isEmpty())) {
            Iterator it = orgNames.iterator();
            while (it.hasNext()) {
                String org = (String) it.next();
                AMIdentityRepository idr = new AMIdentityRepository(appToken, org);
                idr.addEventListener(this);
                idRepoListeners.put(org, idRepo);
                if (DelegationManager.debug.messageEnabled()) {
                    DelegationManager.debug.message("DelegationPolicyImpl: IdRepo event listener " + "added for realm (" + org + ").");
                }
            }
        }
        scm = new ServiceConfigManager(PolicyConfig.POLICY_CONFIG_SERVICE, token);
        //DelegationManager.DELEGATION_SERVICE, token);
        /**
             *  listen on org config changes. once there is realm added,
             * or removed, we need to add or remove listeners on the
             * affected realm accordingly.
             */
        scm.addListener(this);
    } catch (Exception e) {
        DelegationManager.debug.error("DelegationPolicyImpl: initialize() failed");
        throw new DelegationException(e);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) PolicyEvaluator(com.sun.identity.policy.PolicyEvaluator) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) AMIdentityRepository(com.sun.identity.idm.AMIdentityRepository) Iterator(java.util.Iterator) DelegationException(com.sun.identity.delegation.DelegationException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) DelegationException(com.sun.identity.delegation.DelegationException) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException) IdRepoException(com.sun.identity.idm.IdRepoException) Cache(com.iplanet.am.util.Cache) SubjectEvaluationCache(com.sun.identity.policy.SubjectEvaluationCache)

Example 2 with OrganizationConfigManager

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

the class PWResetModelImpl method getAttributeValues.

protected Set getAttributeValues(String realm, String attrName) throws SSOException, SMSException {
    OrganizationConfigManager mgr = new OrganizationConfigManager(ssoToken, realm);
    Map attributeValues = mgr.getServiceAttributes(PW_RESET_SERVICE);
    return (Set) attributeValues.get(attrName);
}
Also used : Set(java.util.Set) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Map(java.util.Map)

Example 3 with OrganizationConfigManager

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

the class SmsRealmProvider method getJsonValue.

private JsonValue getJsonValue(String realmPath, String parentPath) throws SMSException {
    OrganizationConfigManager realmManager = new OrganizationConfigManager(getSSOToken(), realmPath);
    String realmName = getRealmName(realmManager);
    return getJsonValue(realmManager, realmName, parentPath);
}
Also used : OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager)

Example 4 with OrganizationConfigManager

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

the class DefaultADFSPartnerAccountMapper method isDynamicalOrIgnoredProfile.

/**
     * Checks if dynamical profile creation or ignore profile is enabled.
     * @param realm realm to check the dynamical profile creation attributes.
     * @return true if dynamical profile creation or ignore profile is enabled,
     * false otherwise.
     */
protected boolean isDynamicalOrIgnoredProfile(String realm) {
    try {
        OrganizationConfigManager orgConfigMgr = AuthD.getAuth().getOrgConfigManager(realm);
        ServiceConfig svcConfig = orgConfigMgr.getServiceConfig(ISAuthConstants.AUTH_SERVICE_NAME);
        Map attrs = svcConfig.getAttributes();
        String tmp = CollectionHelper.getMapAttr(attrs, ISAuthConstants.DYNAMIC_PROFILE);
        if (debug.messageEnabled()) {
            debug.message("dynamicalCreationEnabled, attr=" + tmp);
        }
        if (tmp != null && (tmp.equalsIgnoreCase("createAlias") || tmp.equalsIgnoreCase("true") || tmp.equalsIgnoreCase("ignore"))) {
            return true;
        } else {
            return false;
        }
    } catch (Exception e) {
        debug.error("dynamicalCreationEnabled, unable to get attribute", e);
        return false;
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) HashMap(java.util.HashMap) Map(java.util.Map) WSFederationException(com.sun.identity.wsfederation.common.WSFederationException) WSFederationMetaException(com.sun.identity.wsfederation.meta.WSFederationMetaException)

Example 5 with OrganizationConfigManager

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

the class ApplicationCacheAfterRealmChangeTest method test.

@Test
public void test() throws Exception {
    if (!migrated) {
        return;
    }
    Application appl = ApplicationManager.getApplication(adminSubject, SUB_REALM, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME);
    // Test disabled, unable to fix model changes
    // Set<String> resources = appl.getResources();
    // if ((resources != null) && !resources.isEmpty()) {
    //     throw new Exception("ApplicationCacheAfterRealmChangeTest: " +
    //         "application resources should be empty");
    // }
    OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, SUB_REALM);
    Map<String, Set<String>> attributes = new HashMap<String, Set<String>>();
    Set<String> setAlias = new HashSet<String>();
    setAlias.add("www.ApplicationCacheAfterRealmChangeTest.com");
    attributes.put("sunOrganizationAliases", setAlias);
    Set<String> setStatus = new HashSet<String>();
    setStatus.add("Active");
    attributes.put("sunOrganizationStatus", setStatus);
    ocm.setAttributes(IdConstants.REPO_SERVICE, attributes);
    appl = ApplicationManager.getApplication(adminSubject, SUB_REALM, ApplicationTypeManager.URL_APPLICATION_TYPE_NAME);
// Test disabled, unable to fix model changes.
// resources = appl.getResources();
// if ((resources == null) || resources.isEmpty()) {
//     throw new Exception("ApplicationCacheAfterRealmChangeTest: " +
//         "application resources should NOT be empty");
// }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

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