Search in sources :

Example 71 with ServiceConfig

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

the class UpgradeUtils method addSubConfiguration.

/**
     * Adds SubConfiguration to a service.
     *
     * @param serviceName the service name
     * @param svcConfigName the service config
     * @param subConfigName the subconfig name
     * @param subConfigID the subconfig id
     * @param attrValues a map of attribute value pairs to be added to the
     *        subconfig.
     * @param priority the priority value
     * @throws UpgradeException if there is an error.
     */
public static void addSubConfiguration(String serviceName, String svcConfigName, String subConfigName, String subConfigID, Map attrValues, int priority) throws UpgradeException {
    String classMethod = "UpgradeUtils:addSubConfiguration";
    try {
        ServiceConfigManager scm = new ServiceConfigManager(serviceName, ssoToken);
        ServiceConfig sc = scm.getGlobalConfig(null);
        if (sc != null) {
            sc.addSubConfig(subConfigName, subConfigID, priority, attrValues);
        } else {
            debug.error(classMethod + "Error adding sub cofiguration " + subConfigName);
            throw new UpgradeException("Error adding subconfig");
        }
    } catch (SSOException ssoe) {
        throw new UpgradeException("invalid sso token");
    } catch (SMSException sm) {
        debug.error(classMethod + "Error loading subconfig", sm);
        throw new UpgradeException("error adding subconfig");
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ByteString(org.forgerock.opendj.ldap.ByteString) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 72 with ServiceConfig

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

the class DelegationConfigUpgradeStep method initConfig.

/**
     * Cache gets cleared after #initialize is called but before #perform, so need to re-get the config options each
     * time.
     */
private void initConfig() throws SMSException, SSOException {
    final ServiceConfig delegationConfig = configManager.getGlobalConfig(null);
    permissionsConfig = delegationConfig.getSubConfig(PERMISSIONS);
    privilegesConfig = delegationConfig.getSubConfig(PRIVILEGES);
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig)

Example 73 with ServiceConfig

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

the class UpgradeUtils method addSubConfigAttributeDefaultValues.

/**
     * Adds defaults values to service sub-configuration
     *
     * @param serviceName the service name
     * @param sunServiceID set of sunservice identifiers for sub-configuration
     * @param realm the realm name
     * @param subConfigName the sub-configuration name
     * @param attributeName the attribute name
     * @param defaultValues set of default values to be updated.
     */
public static void addSubConfigAttributeDefaultValues(String serviceName, Set sunServiceID, String realm, String subConfigName, String attributeName, Set defaultValues) {
    String classMethod = "UpgradeUtils:addSubConfigAttributeDefaultValues : ";
    try {
        Set oldVal = new HashSet();
        ServiceConfigManager scm = getServiceConfigManager(serviceName);
        ServiceConfig sc = scm.getOrganizationConfig(realm, null);
        ServiceConfig subConfig = sc.getSubConfig(subConfigName);
        String serviceID = getSunServiceID(subConfig);
        if (sunServiceID.contains(serviceID)) {
            Set valSet = getExistingValues(subConfig, attributeName, defaultValues);
            defaultValues.removeAll(valSet);
            subConfig.replaceAttributeValues(attributeName, oldVal, defaultValues);
        }
    } catch (SSOException ssoe) {
        debug.error(classMethod + "Invalid SSOToken", ssoe);
    } catch (SMSException sme) {
        debug.error(classMethod + "Error adding values ", sme);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ByteString(org.forgerock.opendj.ldap.ByteString) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) HashSet(java.util.HashSet)

Example 74 with ServiceConfig

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

the class IdRepoAttributeValidatorManager method getIdRepoAttributeValidator.

/**
     * Returns an instance of <code>IdRepoAttributeValidator</code> for 
     * specified realm.
     * @param realm the realm
     * @return an instance of <code>IdRepoAttributeValidator</code>
     * @throws IdRepoException if there are repository related error conditions.
     */
public IdRepoAttributeValidator getIdRepoAttributeValidator(String realm) throws IdRepoException {
    IdRepoAttributeValidator validator = validatorCache.get(realm);
    if (validator != null) {
        return validator;
    }
    Map<String, Set<String>> configParams = new HashMap();
    synchronized (validatorCache) {
        try {
            ServiceConfig orgConfig = idRepoServiceConfigManager.getOrganizationConfig(realm, null);
            Map<String, Set<String>> attrMap = orgConfig.getAttributesForRead();
            Set<String> attrValues = attrMap.get(ATTR_IDREPO_ATTRIBUTE_VALIDATOR);
            String className = null;
            for (String attrValue : attrValues) {
                int index = attrValue.indexOf("=");
                if (index != -1) {
                    String name = attrValue.substring(0, index).trim();
                    String value = attrValue.substring(index + 1).trim();
                    if (name.equals("class")) {
                        className = value;
                    } else {
                        Set<String> values = configParams.get(name);
                        if (values == null) {
                            values = new HashSet();
                            configParams.put(name, values);
                        }
                        values.add(value);
                    }
                }
            }
            Class validatorClass = Class.forName(className);
            validator = (IdRepoAttributeValidator) validatorClass.newInstance();
        } catch (Exception ex) {
            if (debug.warningEnabled()) {
                debug.warning("IdRepoAttributeValidatorManager." + "initializeListeners:", ex);
            }
        }
        if (validator == null) {
            validator = new IdRepoAttributeValidatorImpl();
        }
        validator.initialize(configParams);
    }
    return validator;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) HashSet(java.util.HashSet)

Example 75 with ServiceConfig

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

the class OpenAMSettingsImpl method getSetting.

/**
     * {@inheritDoc}
     */
public Set<String> getSetting(String realm, String attributeName) throws SSOException, SMSException {
    final ServiceConfig serviceConfig = getServiceConfig(realm);
    final Map<String, Set<String>> attributes = serviceConfig.getAttributes();
    return attributes.get(attributeName);
}
Also used : Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig)

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