Search in sources :

Example 11 with ServiceConfig

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

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

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

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

the class ServerInfoResource method getSocialAuthnImplementations.

/**
     * Read out the data whose schema is defined in the file socialAuthN.xml. The enabled implementations value gives
     * us the social authentication implementations we care about.  We use the values there to index into the display
     * names, auth chains and icons.
     *
     * @param realm
     *         The realm/organization name
     */
private List<SocialAuthenticationImplementation> getSocialAuthnImplementations(String realm) {
    List<SocialAuthenticationImplementation> implementations = new ArrayList<>();
    try {
        final ServiceConfig serviceConfig = getSocialAuthenticationServiceConfig(realm);
        Set<String> enabledImplementationSet = ServiceConfigUtils.getSetAttribute(serviceConfig, SocialAuthenticationImplementation.ENABLED_IMPLEMENTATIONS_ATTRIBUTE);
        if (enabledImplementationSet != null) {
            for (String name : enabledImplementationSet) {
                SocialAuthenticationImplementation implementation = new SocialAuthenticationImplementation();
                implementation.setDisplayName(getEntryForImplementation(serviceConfig, name, SocialAuthenticationImplementation.DISPLAY_NAME_ATTRIBUTE));
                implementation.setAuthnChain(getEntryForImplementation(serviceConfig, name, SocialAuthenticationImplementation.CHAINS_ATTRIBUTE));
                implementation.setIconPath(getEntryForImplementation(serviceConfig, name, SocialAuthenticationImplementation.ICONS_ATTRIBUTE));
                if (implementation.isValid()) {
                    implementations.add(implementation);
                }
            }
        }
    } catch (SSOException sso) {
        debug.error("Caught SSO Exception while trying to get the ServiceConfigManager", sso);
    } catch (SMSException sms) {
        debug.error("Caught SMS Exception while trying to get the ServiceConfigManager", sms);
    } catch (Exception e) {
        if (debug.errorEnabled()) {
            debug.error("Caught exception while trying to get the attribute " + SocialAuthenticationImplementation.ENABLED_IMPLEMENTATIONS_ATTRIBUTE, e);
        }
    }
    return implementations;
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ArrayList(java.util.ArrayList) SSOException(com.iplanet.sso.SSOException) SSOException(com.iplanet.sso.SSOException) NotFoundException(org.forgerock.json.resource.NotFoundException) NotSupportedException(org.forgerock.json.resource.NotSupportedException) SMSException(com.sun.identity.sm.SMSException) ResourceException(org.forgerock.json.resource.ResourceException)

Example 15 with ServiceConfig

use of com.sun.identity.sm.ServiceConfig 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)

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