Search in sources :

Example 46 with ServiceConfig

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

the class SchemaTest method getSubConfigurationValues.

private Map getSubConfigurationValues(String name) throws SMSException, SSOException {
    ServiceConfigManager scm = new ServiceConfigManager(TEST_SERVICE, getAdminSSOToken());
    ServiceConfig sc = scm.getGlobalConfig(null);
    sc = sc.getSubConfig("testConfig");
    return sc.getAttributes();
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 47 with ServiceConfig

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

the class DelegationManager method getConfiguredPrivilegeNames.

/**
     * Returns all the names of the delegation privileges that are configured
     * with the realm.
     *
     * @return <code>Set</code> of <code>DelegationPrivilege</code> names
     * configured with the realm.
     *
     * @throws DelegationException  for any abnormal condition
     */
public Set getConfiguredPrivilegeNames() throws DelegationException {
    Set privNames = null;
    Set globalPrivNames = null;
    Set orgPrivNames = null;
    ServiceConfig privsConfig;
    ServiceConfig sc;
    String subConfigName = null;
    int revisionNum = DelegationUtils.getRevisionNumber();
    if (revisionNum == DelegationUtils.AM70_DELEGATION_REVISION) {
        subConfigName = DelegationManager.PERMISSIONS;
    } else {
        subConfigName = DelegationManager.PRIVILEGES;
    }
    try {
        ServiceConfigManager scm = new ServiceConfigManager(DELEGATION_SERVICE, getAdminToken());
        // get the globally defined privilege names
        sc = scm.getGlobalConfig(null);
        if (sc != null) {
            privsConfig = sc.getSubConfig(subConfigName);
            if (privsConfig != null) {
                globalPrivNames = privsConfig.getSubConfigNames();
            }
        }
        try {
            // get the organizationally defined privilege names
            sc = scm.getOrganizationConfig(orgName, null);
            if (sc != null) {
                privsConfig = sc.getSubConfig(subConfigName);
                if (privsConfig != null) {
                    orgPrivNames = privsConfig.getSubConfigNames();
                }
            }
        } catch (SMSException ex) {
        //ignore if organization configuration is not present
        }
        // merge the privilege names
        if ((globalPrivNames != null) && (!globalPrivNames.isEmpty())) {
            privNames = globalPrivNames;
            if ((orgPrivNames != null) && (!orgPrivNames.isEmpty())) {
                privNames.addAll(orgPrivNames);
            }
        } else {
            privNames = orgPrivNames;
        }
    } catch (Exception e) {
        throw new DelegationException(e);
    }
    return privNames;
}
Also used : Set(java.util.Set) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException)

Example 48 with ServiceConfig

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

the class EntitlementService method storeApplicationType.

/**
     * Stores the application type to data store.
     *
     * @param applicationType Application type  object.
     * @throws EntitlementException if application type cannot be stored.
     */
public void storeApplicationType(ApplicationType applicationType) throws EntitlementException {
    try {
        SSOToken token = SubjectUtils.getSSOToken(getAdminSubject());
        if (token == null) {
            Object[] arg = { applicationType.getName() };
            throw new EntitlementException(246, arg);
        }
        ServiceConfig conf = getApplicationTypeCollectionConfig(token);
        if (conf != null) {
            ServiceConfig sc = conf.getSubConfig(applicationType.getName());
            if (sc == null) {
                conf.addSubConfig(applicationType.getName(), EntitlementUtils.APPLICATION_TYPE, 0, getApplicationTypeData(applicationType));
            } else {
                sc.setAttributes(getApplicationTypeData(applicationType));
            }
        }
    } catch (SMSException ex) {
        Object[] arg = { applicationType.getName() };
        throw new EntitlementException(241, arg, ex);
    } catch (SSOException ex) {
        Object[] arg = { applicationType.getName() };
        throw new EntitlementException(241, arg, ex);
    }
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Example 49 with ServiceConfig

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

the class EntitlementService method addSubjectAttributeNames.

/**
     * Returns subject attribute names.
     *
     * @param applicationName  Application name.
     * @param names subject attribute names.
     * @throws EntitlementException if subject attribute names cannot be
     * returned.
     */
public void addSubjectAttributeNames(String applicationName, Set<String> names) throws EntitlementException {
    if ((names == null) || names.isEmpty()) {
        return;
    }
    try {
        SSOToken token = getSSOToken();
        if (token == null) {
            throw new EntitlementException(225);
        }
        Application appl = ApplicationManager.getApplication(PolicyConstants.SUPER_ADMIN_SUBJECT, realm, applicationName);
        if (appl != null) {
            appl.addAttributeNames(names);
        }
        ServiceConfig applConf = getApplicationSubConfig(token, realm, applicationName);
        String parentRealm = realm;
        while (applConf == null) {
            parentRealm = getParentRealm(parentRealm);
            if (parentRealm == null) {
                break;
            }
            applConf = getApplicationSubConfig(token, parentRealm, applicationName);
        }
        if (applConf != null) {
            Set<String> orig = (Set<String>) applConf.getAttributes().get(ATTR_NAME_SUBJECT_ATTR_NAMES);
            if ((orig == null) || orig.isEmpty()) {
                orig = new HashSet<String>();
            }
            orig.addAll(names);
            Map<String, Set<String>> map = new HashMap<String, Set<String>>();
            map.put(ATTR_NAME_SUBJECT_ATTR_NAMES, orig);
            applConf.setAttributes(map);
        }
    } catch (SMSException ex) {
        throw new EntitlementException(220, ex);
    } catch (SSOException ex) {
        throw new EntitlementException(220, ex);
    }
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) Application(com.sun.identity.entitlement.Application)

Example 50 with ServiceConfig

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

the class EntitlementService method getApplicationSubConfig.

private ServiceConfig getApplicationSubConfig(SSOToken token, String realm, String appName) throws SMSException, SSOException {
    ServiceConfig applConf = null;
    ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, token);
    ServiceConfig orgConfig = mgr.getOrganizationConfig(realm, null);
    if (orgConfig != null) {
        ServiceConfig conf = orgConfig.getSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS);
        if (conf != null) {
            applConf = conf.getSubConfig(appName);
        }
    }
    return applConf;
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Aggregations

ServiceConfig (com.sun.identity.sm.ServiceConfig)285 SMSException (com.sun.identity.sm.SMSException)180 Set (java.util.Set)144 SSOException (com.iplanet.sso.SSOException)143 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)124 HashSet (java.util.HashSet)119 Map (java.util.Map)101 HashMap (java.util.HashMap)96 SSOToken (com.iplanet.sso.SSOToken)52 Iterator (java.util.Iterator)41 IdRepoException (com.sun.identity.idm.IdRepoException)27 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)22 EntitlementException (com.sun.identity.entitlement.EntitlementException)19 LinkedHashSet (java.util.LinkedHashSet)18 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)17 CLIException (com.sun.identity.cli.CLIException)16 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)16 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)13 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)13 ServiceSchema (com.sun.identity.sm.ServiceSchema)12