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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations