Search in sources :

Example 26 with ServiceConfig

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

the class AuthIdHelperTest method mockGetSigningKey.

private void mockGetSigningKey(String orgName, boolean nullKeyAlias) throws SMSException, SSOException {
    SSOToken adminToken = mock(SSOToken.class);
    ServiceConfigManager serviceConfigManager = mock(ServiceConfigManager.class);
    ServiceConfig serviceConfig = mock(ServiceConfig.class);
    Map<String, Set<String>> orgConfigAttributes = new HashMap<String, Set<String>>();
    Set<String> orgConfigSet = new HashSet<String>();
    if (!nullKeyAlias) {
        orgConfigSet.add(SIGNING_KEY);
    }
    orgConfigAttributes.put("iplanet-am-auth-hmac-signing-shared-secret", orgConfigSet);
    given(coreServicesWrapper.getAdminToken()).willReturn(adminToken);
    given(coreServicesWrapper.getServiceConfigManager("iPlanetAMAuthService", adminToken)).willReturn(serviceConfigManager);
    given(serviceConfigManager.getOrganizationConfig(orgName, null)).willReturn(serviceConfig);
    given(serviceConfig.getAttributes()).willReturn(orgConfigAttributes);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) JwtClaimsSet(org.forgerock.json.jose.jwt.JwtClaimsSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) HashMap(java.util.HashMap) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) HashSet(java.util.HashSet)

Example 27 with ServiceConfig

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

the class SmsResourceProvider method parentSubConfigFor.

/**
     * Gets the ServiceConfig parent of the parent of the config being addressed by the current request.
     * @param context The request context, from which the path variables can be retrieved.
     * @param scm The {@link com.sun.identity.sm.ServiceConfigManager}. See {@link #getServiceConfigManager(Context)}.
     * @return The ServiceConfig that was found.
     * @throws SMSException From downstream service manager layer.
     * @throws SSOException From downstream service manager layer.
     */
protected ServiceConfig parentSubConfigFor(Context context, ServiceConfigManager scm) throws SMSException, SSOException {
    String name = null;
    Map<String, String> uriTemplateVariables = context.asContext(UriRouterContext.class).getUriTemplateVariables();
    if (hasInstanceName) {
        name = uriTemplateVariables.get("name");
    }
    ServiceConfig config = type == SchemaType.GLOBAL ? scm.getGlobalConfig(name) : scm.getOrganizationConfig(realmFor(context), null);
    for (int i = 0; i < subSchemaPath.size() - 1; i++) {
        ServiceSchema schema = subSchemaPath.get(i);
        String pathFragment = schema.getResourceName();
        if (pathFragment == null || "USE-PARENT".equals(pathFragment)) {
            pathFragment = schema.getName();
        }
        if (uriPath.contains("{" + pathFragment + "}")) {
            pathFragment = uriTemplateVariables.get(pathFragment);
        }
        config = config.getSubConfig(pathFragment);
    }
    return config;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) ServiceConfig(com.sun.identity.sm.ServiceConfig) UriRouterContext(org.forgerock.http.routing.UriRouterContext)

Example 28 with ServiceConfig

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

the class ConfigurationBase method getServerConfigurationId.

protected static Set getServerConfigurationId(ServiceConfig svc) throws SMSException, SSOException {
    Set currentIds = new HashSet();
    Set names = svc.getSubConfigNames("*");
    if ((names != null) && !names.isEmpty()) {
        for (Iterator i = names.iterator(); i.hasNext(); ) {
            String name = (String) i.next();
            ServiceConfig sc = svc.getSubConfig(name);
            Map map = sc.getAttributes();
            Set set = (Set) map.get(ATTR_SERVER_ID);
            if ((set != null) && !set.isEmpty()) {
                currentIds.add(set.iterator().next());
            }
        }
    }
    return currentIds;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) Iterator(java.util.Iterator) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 29 with ServiceConfig

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

the class ConfigurationBase method getSiteConfigurationIds.

protected static Set getSiteConfigurationIds(SSOToken ssoToken, ServiceConfig rootNode, String name, boolean bPrimaryOnly) throws SMSException, SSOException {
    if (rootNode == null) {
        rootNode = getRootSiteConfig(ssoToken);
    }
    ServiceConfig sc = rootNode.getSubConfig(name);
    if (sc == null) {
        return Collections.EMPTY_SET;
    }
    Set currentIds = new LinkedHashSet();
    ServiceConfig accessPoint = sc.getSubConfig(SUBCONFIG_ACCESS_URL);
    Map map = accessPoint.getAttributes();
    Set set = (Set) map.get(ATTR_PRIMARY_SITE_ID);
    currentIds.add(set.iterator().next());
    if (!bPrimaryOnly) {
        Set failovers = accessPoint.getSubConfigNames("*");
        if ((failovers != null) && !failovers.isEmpty()) {
            for (Iterator i = failovers.iterator(); i.hasNext(); ) {
                String foName = (String) i.next();
                ServiceConfig s = accessPoint.getSubConfig(foName);
                Map mapValues = s.getAttributes();
                set = (Set) mapValues.get(ATTR_SEC_ID);
                if ((set != null) && !set.isEmpty()) {
                    currentIds.add(set.iterator().next());
                }
            }
        }
    }
    return currentIds;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) Iterator(java.util.Iterator) Map(java.util.Map)

Example 30 with ServiceConfig

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

the class ConfigurationBase method getRootServerConfig.

protected static ServiceConfig getRootServerConfig(SSOToken ssoToken) throws SMSException, SSOException {
    ServiceConfigManager scm = new ServiceConfigManager(Constants.SVC_NAME_PLATFORM, ssoToken);
    ServiceConfig globalSvcConfig = scm.getGlobalConfig(null);
    return (globalSvcConfig != null) ? globalSvcConfig.getSubConfig(CONFIG_SERVERS) : null;
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) 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