Search in sources :

Example 46 with SMSException

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

the class ResourceTypeConfigurationImpl method getResourceTypesData.

@Override
public Map<String, Map<String, Set<String>>> getResourceTypesData(Subject subject, String realm) throws EntitlementException {
    final Map<String, Map<String, Set<String>>> configData = new HashMap<String, Map<String, Set<String>>>();
    try {
        final ServiceConfig subOrgConfig = resourceTypeServiceConfig.getOrgConfig(subject, realm).getSubConfig(CONFIG_RESOURCE_TYPES);
        if (subOrgConfig == null) {
            return configData;
        }
        final Set<String> uuids = subOrgConfig.getSubConfigNames();
        for (String uuid : uuids) {
            configData.put(uuid, subOrgConfig.getSubConfig(uuid).getAttributesForRead());
        }
    } catch (SMSException ex) {
        PrivilegeManager.debug.error("ResourceTypeConfiguration.getResourceTypesData", ex);
        throw new EntitlementException(RESOURCE_TYPE_RETRIEVAL_ERROR, ex, realm);
    } catch (SSOException ex) {
        PrivilegeManager.debug.error("ResourceTypeConfiguration.getResourceTypesData", ex);
        throw new EntitlementException(RESOURCE_TYPE_RETRIEVAL_ERROR, ex, realm);
    }
    return configData;
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) Set(java.util.Set) HashSet(java.util.HashSet) EntitlementUtils.getActionSet(org.forgerock.openam.entitlement.utils.EntitlementUtils.getActionSet) HashMap(java.util.HashMap) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map) HashMap(java.util.HashMap) EntitlementUtils.resourceTypeFromMap(org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap)

Example 47 with SMSException

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

the class ResourceTypeServiceConfig method getOrgConfig.

/**
     * Get the organization configuration for the sunEntitlementService service.
     * @param subject The subject used to retrieve the SSO token.
     * @param realm The realm from which to retrieve it.
     * @return The organization configuration, which is guaranteed to not be null.
     * @throws SMSException If the sub configuration could not be read.
     * @throws SSOException If the Admin token could not be found.
     */
ServiceConfig getOrgConfig(Subject subject, String realm) throws SMSException, SSOException {
    final SSOToken token = getSSOToken(subject);
    if (token == null) {
        throw new SSOException("Could not find Admin token.");
    }
    ServiceConfig orgConfig = new ServiceConfigManager(SERVICE_NAME, token).getOrganizationConfig(realm, null);
    if (orgConfig == null) {
        throw new SMSException("Configuration '" + SERVICE_NAME + "' in realm '" + realm + "' could not be retrieved.");
    }
    return orgConfig;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 48 with SMSException

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

the class ScriptConfigurationDataStore method get.

@Override
public Set<ScriptConfiguration> get(QueryFilter<String> queryFilter) throws ScriptException {
    final Set<ScriptConfiguration> scriptConfigurations = new LinkedHashSet<>();
    try {
        ServiceConfig config = getSubOrgConfig();
        Set<String> uuids = config.getSubConfigNames();
        for (String uuid : uuids) {
            if (queryFilter.accept(new ServiceConfigQueryFilterVisitor(), config.getSubConfig(uuid))) {
                scriptConfigurations.add(get(uuid));
            }
        }
        config = getSubGlobalConfig();
        uuids = config.getSubConfigNames();
        for (String uuid : uuids) {
            if (queryFilter.accept(new ServiceConfigQueryFilterVisitor(), config.getSubConfig(uuid))) {
                scriptConfigurations.add(get(uuid));
            }
        }
    } catch (SMSException | SSOException e) {
        throw createAndLogError(logger, RETRIEVE_ALL_FAILED, e, realm);
    } catch (UnsupportedOperationException e) {
        throw createAndLogError(logger, ScriptErrorCode.valueOf(e.getMessage()), e);
    }
    return scriptConfigurations;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ServiceConfigQueryFilterVisitor(org.forgerock.openam.sm.ServiceConfigQueryFilterVisitor) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ScriptConfiguration(org.forgerock.openam.scripting.service.ScriptConfiguration) SSOException(com.iplanet.sso.SSOException)

Example 49 with SMSException

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

the class ScriptConfigurationDataStore method getAll.

@Override
public Set<ScriptConfiguration> getAll() throws ScriptException {
    final Set<ScriptConfiguration> scriptConfigurations = new LinkedHashSet<>();
    try {
        ServiceConfig config = getSubOrgConfig();
        Set<String> uuids = config.getSubConfigNames();
        for (String uuid : uuids) {
            scriptConfigurations.add(scriptConfigurationFromMap(uuid, config.getSubConfig(uuid).getAttributesForRead()));
        }
        config = getSubGlobalConfig();
        uuids = config.getSubConfigNames();
        for (String uuid : uuids) {
            scriptConfigurations.add(scriptConfigurationFromMap(uuid, config.getSubConfig(uuid).getAttributesForRead()));
        }
    } catch (SSOException | SMSException e) {
        throw createAndLogError(logger, RETRIEVE_ALL_FAILED, e, realm);
    }
    return scriptConfigurations;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ScriptConfiguration(org.forgerock.openam.scripting.service.ScriptConfiguration) SSOException(com.iplanet.sso.SSOException)

Example 50 with SMSException

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

the class ScriptConfigurationDataStore method get.

@Override
public ScriptConfiguration get(String uuid) throws ScriptException {
    try {
        ServiceConfig config = getSubOrgConfig();
        if (config.getSubConfigNames().contains(uuid)) {
            return scriptConfigurationFromMap(uuid, config.getSubConfig(uuid).getAttributesForRead());
        }
        config = getSubGlobalConfig();
        if (config.getSubConfigNames().contains(uuid)) {
            return scriptConfigurationFromMap(uuid, config.getSubConfig(uuid).getAttributesForRead());
        }
    } catch (SSOException | SMSException e) {
        throw createAndLogError(logger, RETRIEVE_FAILED, e, uuid, realm);
    }
    throw createAndLogError(logger, SCRIPT_UUID_NOT_FOUND, uuid, realm);
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Aggregations

SMSException (com.sun.identity.sm.SMSException)704 SSOException (com.iplanet.sso.SSOException)525 Set (java.util.Set)272 HashSet (java.util.HashSet)200 SSOToken (com.iplanet.sso.SSOToken)185 Map (java.util.Map)166 ServiceConfig (com.sun.identity.sm.ServiceConfig)164 HashMap (java.util.HashMap)158 CLIException (com.sun.identity.cli.CLIException)149 ServiceSchema (com.sun.identity.sm.ServiceSchema)138 Iterator (java.util.Iterator)133 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)104 IOutput (com.sun.identity.cli.IOutput)96 IdRepoException (com.sun.identity.idm.IdRepoException)86 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)84 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)83 AttributeSchema (com.sun.identity.sm.AttributeSchema)66 IOException (java.io.IOException)55 List (java.util.List)51