Search in sources :

Example 76 with ServiceConfigManager

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

the class SMSConfigProvider method getAttributes.

Map<String, Set<String>> getAttributes(String source, String realm) {
    try {
        ServiceConfigManager configManager = getConfigManager(source);
        // Safe cast due to known legacy API
        @SuppressWarnings("unchecked") Map<String, Set<String>> attributes = configManager.getOrganizationConfig(realm, null).getAttributes();
        return attributes;
    } catch (SMSException | SSOException e) {
        throw new ConfigRetrievalException("Unable to retrieve organisation config", e);
    }
}
Also used : Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 77 with ServiceConfigManager

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

the class Dashboard method getDefinitions.

public static JsonValue getDefinitions(SSOToken token) {
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    JsonValue result = new JsonValue(new HashMap<String, Object>());
    try {
        ServiceConfigManager scm = new ServiceConfigManager("dashboardService", adminToken);
        ServiceConfig sc = scm.getGlobalConfig("default");
        Set<String> subNames = sc.getSubConfigNames();
        for (String s : subNames) {
            ServiceConfig sc1 = sc.getSubConfig(s);
            Map app = new LinkedHashMap<String, Object>();
            Map attrs = sc1.getAttributes();
            for (String s1 : (Set<String>) attrs.keySet()) {
                List<String> sList = new ArrayList((Set<String>) (attrs.get(s1)));
                app.put(s1, sList);
            }
            result.put(s.toLowerCase(), app);
        }
    } catch (SSOException ex) {
    // No need to do anything,  return empty object
    } catch (SMSException ex) {
    // No need to do anything,  return empty object
    }
    return result;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) JsonValue(org.forgerock.json.JsonValue) SSOException(com.iplanet.sso.SSOException) ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 78 with ServiceConfigManager

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

the class Dashboard method getAllowedDashboard.

public static JsonValue getAllowedDashboard(SSOToken token) {
    SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    JsonValue allApps = getDefinitions(token);
    JsonValue result = new JsonValue(new HashMap<String, Object>());
    try {
        ServiceConfigManager scm = new ServiceConfigManager("dashboardService", adminToken);
        ServiceConfig sc = scm.getOrganizationConfig(token.getProperty("Organization"), "default");
        Set<String> apps = (Set<String>) sc.getAttributes().get("assignedDashboard");
        for (String s : apps) {
            String sTemp = s.toLowerCase();
            JsonValue val = allApps.get(sTemp);
            if (val != null) {
                result.put(sTemp, val.getObject());
            }
        }
    } catch (SSOException ex) {
    // No need to do anything,  return empty object
    } catch (SMSException ex) {
    // No need to do anything,  return empty object
    }
    return result;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) JsonValue(org.forgerock.json.JsonValue) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 79 with ServiceConfigManager

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

the class SmsCollectionProvider method createInstance.

/**
     * Creates a new child instance of config. The parent config referenced by the request path is found, and
     * new config is created using the provided name property.
     * {@inheritDoc}
     */
@Override
public Promise<ResourceResponse, ResourceException> createInstance(Context context, CreateRequest request) {
    JsonValue content = request.getContent();
    final String realm = realmFor(context);
    try {
        Map<String, Set<String>> attrs = converter.fromJson(realm, content);
        ServiceConfigManager scm = getServiceConfigManager(context);
        ServiceConfig config = parentSubConfigFor(context, scm);
        String name = content.get("_id").asString();
        if (name == null) {
            name = request.getNewResourceId();
        } else if (request.getNewResourceId() != null && !name.equals(request.getNewResourceId())) {
            return new BadRequestException("name and URI's resource ID do not match").asPromise();
        }
        if (name == null) {
            return new BadRequestException("Invalid name").asPromise();
        }
        config.addSubConfig(name, lastSchemaNodeName(), 0, attrs);
        final ServiceConfig created = checkedInstanceSubConfig(context, name, config);
        return awaitCreation(context, name).then(new Function<Void, ResourceResponse, ResourceException>() {

            @Override
            public ResourceResponse apply(Void aVoid) {
                JsonValue result = getJsonValue(realm, created);
                return newResourceResponse(created.getName(), String.valueOf(result.hashCode()), result);
            }
        });
    } catch (ServiceAlreadyExistsException e) {
        debug.warning("::SmsCollectionProvider:: ServiceAlreadyExistsException on create", e);
        return new ConflictException("Unable to create SMS config: " + e.getMessage()).asPromise();
    } catch (SMSException e) {
        debug.warning("::SmsCollectionProvider:: SMSException on create", e);
        return new InternalServerErrorException("Unable to create SMS config: " + e.getMessage()).asPromise();
    } catch (SSOException e) {
        debug.warning("::SmsCollectionProvider:: SSOException on create", e);
        return new InternalServerErrorException("Unable to create SMS config: " + e.getMessage()).asPromise();
    } catch (ResourceException e) {
        return e.asPromise();
    }
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) ConflictException(org.forgerock.json.resource.ConflictException) SMSException(com.sun.identity.sm.SMSException) JsonValue(org.forgerock.json.JsonValue) SSOException(com.iplanet.sso.SSOException) ServiceAlreadyExistsException(com.sun.identity.sm.ServiceAlreadyExistsException) Responses.newResourceResponse(org.forgerock.json.resource.Responses.newResourceResponse) ResourceResponse(org.forgerock.json.resource.ResourceResponse) ServiceConfig(com.sun.identity.sm.ServiceConfig) BadRequestException(org.forgerock.json.resource.BadRequestException) InternalServerErrorException(org.forgerock.json.resource.InternalServerErrorException) ResourceException(org.forgerock.json.resource.ResourceException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 80 with ServiceConfigManager

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

the class ISLocaleContext method setOrgLocale.

/**
     * Update locale context based on org locale user locale takes precedence
     * over this locale
     * 
     * @param orgDN -
     *            Distinguished Name of Organization
     */
public void setOrgLocale(String orgDN) {
    if (localeLevel > CORE_AUTH_LOCALE) {
        return;
    }
    try {
        SSOToken token = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
        ServiceConfigManager scm = new ServiceConfigManager("iPlanetAMAuthService", token);
        ServiceConfig sc = scm.getOrganizationConfig(orgDN, null);
        Map attrs = sc.getAttributes();
        String locale = Misc.getMapAttr(attrs, "iplanet-am-auth-locale");
        if (locale != null && locale.length() > 0) {
            setLocale(CORE_AUTH_LOCALE, Locale.getLocale(locale));
        }
    } catch (SSOException ssoe) {
    // Problems in getting SSOToken which can be safely
    // ignored as we have a fallback locale
    } catch (SMSException amex) {
    // Problems in getting attribute from org
    // ignored as we have fallback locale
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) Map(java.util.Map) 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