Search in sources :

Example 36 with ServiceConfigManager

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

the class UpgradeUtils method addSubConfig.

/**
     * Adds SubConfiguration to an existing subconfiguration in a service.
     *
     * @param serviceName the service name
     * @param parentConfigName the name of parent sub configuration.
     * @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 addSubConfig(String serviceName, String parentConfigName, String subConfigName, String subConfigID, Map attrValues, int priority) throws UpgradeException {
    String classMethod = "UpgradeUtils:addSubConfig";
    try {
        ServiceConfigManager scm = new ServiceConfigManager(serviceName, ssoToken);
        ServiceConfig sc = scm.getGlobalConfig(null);
        ServiceConfig sc1 = sc.getSubConfig(parentConfigName);
        if (sc != null) {
            sc1.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(classMethod + "invalid sso token");
    } catch (SMSException sm) {
        debug.error(classMethod + "Error loading subconfig", sm);
        throw new UpgradeException(classMethod + "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 37 with ServiceConfigManager

use of com.sun.identity.sm.ServiceConfigManager 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 38 with ServiceConfigManager

use of com.sun.identity.sm.ServiceConfigManager 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 39 with ServiceConfigManager

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

the class UpgradeUtils method getServiceConfigManager.

/**
     * Returns the <code>ServiceConfigManager</code> for a service.
     *
     * @param serviceName the service name
     * @param ssoToken the admin SSOToken.
     * @return the <code>ServiceConfigManager</code> of the service.
     */
protected static ServiceConfigManager getServiceConfigManager(String serviceName, SSOToken ssoToken) {
    String classMethod = "UpgradeUtils:getServiceConfigManager : ";
    ServiceConfigManager scm = null;
    if (serviceName != null) {
        try {
            scm = new ServiceConfigManager(serviceName, ssoToken);
        } catch (SSOException e) {
            debug.error(classMethod, e);
        } catch (SMSException e) {
            debug.error(classMethod, e);
        }
    }
    return scm;
}
Also used : SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ByteString(org.forgerock.opendj.ldap.ByteString) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 40 with ServiceConfigManager

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

the class IdRepoAttributeValidatorManager method initializeListeners.

private void initializeListeners() {
    // Add listeners to Service Schema and Config Managers
    if (debug.messageEnabled()) {
        debug.message("IdRepoAttributeValidatorManager." + "initializeListeners: setting up ServiceListener");
    }
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    try {
        // Initialize schema objects
        idRepoServiceConfigManager = new ServiceConfigManager(adminToken, IdConstants.REPO_SERVICE, "1.0");
        idRepoServiceConfigManager.addListener(this);
    } catch (SMSException smse) {
        debug.error("IdRepoAttributeValidatorManager.initializeListeners:", smse);
    } catch (SSOException ssoe) {
        debug.error("IdRepoAttributeValidatorManager.initializeListeners:", ssoe);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Aggregations

ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)163 ServiceConfig (com.sun.identity.sm.ServiceConfig)123 SMSException (com.sun.identity.sm.SMSException)116 SSOException (com.iplanet.sso.SSOException)107 SSOToken (com.iplanet.sso.SSOToken)53 Set (java.util.Set)50 Map (java.util.Map)31 HashMap (java.util.HashMap)29 HashSet (java.util.HashSet)28 CLIException (com.sun.identity.cli.CLIException)17 Iterator (java.util.Iterator)16 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)15 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)13 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)12 ByteString (org.forgerock.opendj.ldap.ByteString)12 JsonValue (org.forgerock.json.JsonValue)10 IOException (java.io.IOException)9 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)9 IOutput (com.sun.identity.cli.IOutput)8 PolicyException (com.sun.identity.policy.PolicyException)7