Search in sources :

Example 71 with ServiceConfigManager

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

the class IDRepoModelImpl method editIDRepo.

/**
     * Edit ID Repo object.
     *
     * @param realmName Name of Realm.
     * @param idRepoName Name of ID Repo.
     * @param values Map of attribute name to set of values.
     * @throws AMConsoleException if object cannot be created.
     */
public void editIDRepo(String realmName, String idRepoName, Map values) throws AMConsoleException {
    String[] params = { realmName, idRepoName };
    logEvent("ATTEMPT_MODIFY_ID_REPO", params);
    values.remove("idRepoLoadSchema");
    try {
        ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, getUserSSOToken());
        ServiceConfig cfg = svcCfgMgr.getOrganizationConfig(realmName, null);
        ServiceConfig ss = cfg.getSubConfig(idRepoName);
        ss.setAttributes(values);
        logEvent("SUCCEED_MODIFY_ID_REPO", params);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, idRepoName, strError };
        logEvent("SMS_EXCEPTION_MODIFY_ID_REPO", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, idRepoName, strError };
        logEvent("SSO_EXCEPTION_MODIFY_ID_REPO", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 72 with ServiceConfigManager

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

the class IDRepoModelImpl method createIDRepo.

/**
     * Creates ID Repo object.
     *
     * @param realmName Name of Realm.
     * @param idRepoName Name of ID Repo.
     * @param idRepoType Type of ID Repo.
     * @param values Map of attribute name to set of values.
     * @throws AMConsoleException if object cannot be created.
     */
public void createIDRepo(String realmName, String idRepoName, String idRepoType, Map values) throws AMConsoleException {
    String[] params = { realmName, idRepoName, idRepoType };
    logEvent("ATTEMPT_CREATE_ID_REPO", params);
    values.remove("idRepoLoadSchema");
    try {
        ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, getUserSSOToken());
        ServiceConfig cfg = svcCfgMgr.getOrganizationConfig(realmName, null);
        if (cfg == null) {
            cfg = createOrganizationConfig(realmName, idRepoType);
        }
        cfg.addSubConfig(idRepoName, idRepoType, 0, values);
        logEvent("SUCCEED_CREATE_ID_REPO", params);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, idRepoName, idRepoType, strError };
        logEvent("SMS_EXCEPTION_CREATE_ID_REPO", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, idRepoName, idRepoType, strError };
        logEvent("SSO_EXCEPTION_CREATE_ID_REPO", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 73 with ServiceConfigManager

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

the class ServerInfoResource method getSocialAuthenticationServiceConfig.

private ServiceConfig getSocialAuthenticationServiceConfig(final String realm) throws SSOException, SMSException {
    ServiceConfig realmSocialAuthServiceConfig = realmSocialAuthServiceConfigMap.get(realm);
    if (realmSocialAuthServiceConfig == null || !realmSocialAuthServiceConfig.isValid()) {
        synchronized (realmSocialAuthServiceConfigMap) {
            realmSocialAuthServiceConfig = realmSocialAuthServiceConfigMap.get(realm);
            if (realmSocialAuthServiceConfig == null || !realmSocialAuthServiceConfig.isValid()) {
                SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
                ServiceConfigManager mgr = new ServiceConfigManager(SocialAuthenticationImplementation.SERVICE_NAME, token);
                realmSocialAuthServiceConfig = mgr.getOrganizationConfig(realm, null);
                realmSocialAuthServiceConfigMap.put(realm, realmSocialAuthServiceConfig);
            }
        }
    }
    return realmSocialAuthServiceConfig;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 74 with ServiceConfigManager

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

the class SmsCollectionProvider method updateInstance.

/**
     * Updates a child instance of config. The parent config referenced by the request path is found, and
     * the config is updated using the resourceId.
     * {@inheritDoc}
     */
@Override
public Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId, UpdateRequest request) {
    JsonValue content = request.getContent();
    String realm = realmFor(context);
    try {
        Map<String, Set<String>> attrs = converter.fromJson(realm, content);
        ServiceConfigManager scm = getServiceConfigManager(context);
        ServiceConfig config = parentSubConfigFor(context, scm);
        ServiceConfig node = checkedInstanceSubConfig(context, resourceId, config);
        node.setAttributes(attrs);
        JsonValue result = getJsonValue(realm, node);
        return newResultPromise(newResourceResponse(resourceId, String.valueOf(result.hashCode()), result));
    } catch (ServiceNotFoundException e) {
        debug.warning("::SmsCollectionProvider:: ServiceNotFoundException on update", e);
        return new NotFoundException("Unable to update SMS config: " + e.getMessage()).asPromise();
    } catch (SMSException e) {
        debug.warning("::SmsCollectionProvider:: SMSException on update", e);
        return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
    } catch (SSOException e) {
        debug.warning("::SmsCollectionProvider:: SSOException on update", e);
        return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
    } catch (ResourceException e) {
        return e.asPromise();
    }
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) JsonValue(org.forgerock.json.JsonValue) NotFoundException(org.forgerock.json.resource.NotFoundException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) SSOException(com.iplanet.sso.SSOException) ResourceException(org.forgerock.json.resource.ResourceException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 75 with ServiceConfigManager

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

the class BaseURLProviderFactory method addListener.

private void addListener() {
    try {
        final SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
        final ServiceConfigManager serviceConfigManager = new ServiceConfigManager(token, SERVICE_NAME, SERVICE_VERSION);
        if (serviceConfigManager.addListener(new SettingsChangeListener()) == null) {
            debug.error("Could not add listener. Base URLs will not be dynamically updated");
        }
    } catch (SMSException e) {
        debug.error("Unable to construct ServiceConfigManager", e);
        throw new IllegalStateException(e);
    } catch (SSOException e) {
        debug.error("Unable to construct ServiceConfigManager", e);
        throw new IllegalStateException(e);
    }
}
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