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