use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class IDRepoModelImpl method editIDRepo.
/**
* Edit ID Repo object.
*
* @param realmName Name of Realm.
* @param idRepoName Name of ID Repo.
* @param values Map of attribute name to set of values.
* @throws AMConsoleException if object cannot be created.
*/
public void editIDRepo(String realmName, String idRepoName, Map values) throws AMConsoleException {
String[] params = { realmName, idRepoName };
logEvent("ATTEMPT_MODIFY_ID_REPO", params);
values.remove("idRepoLoadSchema");
try {
ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, getUserSSOToken());
ServiceConfig cfg = svcCfgMgr.getOrganizationConfig(realmName, null);
ServiceConfig ss = cfg.getSubConfig(idRepoName);
ss.setAttributes(values);
logEvent("SUCCEED_MODIFY_ID_REPO", params);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, idRepoName, strError };
logEvent("SMS_EXCEPTION_MODIFY_ID_REPO", paramsEx);
throw new AMConsoleException(strError);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, idRepoName, strError };
logEvent("SSO_EXCEPTION_MODIFY_ID_REPO", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class IDRepoModelImpl method createIDRepo.
/**
* Creates ID Repo object.
*
* @param realmName Name of Realm.
* @param idRepoName Name of ID Repo.
* @param idRepoType Type of ID Repo.
* @param values Map of attribute name to set of values.
* @throws AMConsoleException if object cannot be created.
*/
public void createIDRepo(String realmName, String idRepoName, String idRepoType, Map values) throws AMConsoleException {
String[] params = { realmName, idRepoName, idRepoType };
logEvent("ATTEMPT_CREATE_ID_REPO", params);
values.remove("idRepoLoadSchema");
try {
ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, getUserSSOToken());
ServiceConfig cfg = svcCfgMgr.getOrganizationConfig(realmName, null);
if (cfg == null) {
cfg = createOrganizationConfig(realmName, idRepoType);
}
cfg.addSubConfig(idRepoName, idRepoType, 0, values);
logEvent("SUCCEED_CREATE_ID_REPO", params);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, idRepoName, idRepoType, strError };
logEvent("SMS_EXCEPTION_CREATE_ID_REPO", paramsEx);
throw new AMConsoleException(strError);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, idRepoName, idRepoType, strError };
logEvent("SSO_EXCEPTION_CREATE_ID_REPO", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class ServerInfoResource method getSocialAuthenticationServiceConfig.
private ServiceConfig getSocialAuthenticationServiceConfig(final String realm) throws SSOException, SMSException {
ServiceConfig realmSocialAuthServiceConfig = realmSocialAuthServiceConfigMap.get(realm);
if (realmSocialAuthServiceConfig == null || !realmSocialAuthServiceConfig.isValid()) {
synchronized (realmSocialAuthServiceConfigMap) {
realmSocialAuthServiceConfig = realmSocialAuthServiceConfigMap.get(realm);
if (realmSocialAuthServiceConfig == null || !realmSocialAuthServiceConfig.isValid()) {
SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
ServiceConfigManager mgr = new ServiceConfigManager(SocialAuthenticationImplementation.SERVICE_NAME, token);
realmSocialAuthServiceConfig = mgr.getOrganizationConfig(realm, null);
realmSocialAuthServiceConfigMap.put(realm, realmSocialAuthServiceConfig);
}
}
}
return realmSocialAuthServiceConfig;
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class SmsCollectionProvider method updateInstance.
/**
* Updates a child instance of config. The parent config referenced by the request path is found, and
* the config is updated using the resourceId.
* {@inheritDoc}
*/
@Override
public Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId, UpdateRequest request) {
JsonValue content = request.getContent();
String realm = realmFor(context);
try {
Map<String, Set<String>> attrs = converter.fromJson(realm, content);
ServiceConfigManager scm = getServiceConfigManager(context);
ServiceConfig config = parentSubConfigFor(context, scm);
ServiceConfig node = checkedInstanceSubConfig(context, resourceId, config);
node.setAttributes(attrs);
JsonValue result = getJsonValue(realm, node);
return newResultPromise(newResourceResponse(resourceId, String.valueOf(result.hashCode()), result));
} catch (ServiceNotFoundException e) {
debug.warning("::SmsCollectionProvider:: ServiceNotFoundException on update", e);
return new NotFoundException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (SMSException e) {
debug.warning("::SmsCollectionProvider:: SMSException on update", e);
return new InternalServerErrorException("Unable to update SMS config: " + e.getMessage()).asPromise();
} catch (SSOException e) {
debug.warning("::SmsCollectionProvider:: SSOException on update", e);
return new InternalServerErrorException("Unable to update 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 BaseURLProviderFactory method addListener.
private void addListener() {
try {
final SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
final ServiceConfigManager serviceConfigManager = new ServiceConfigManager(token, SERVICE_NAME, SERVICE_VERSION);
if (serviceConfigManager.addListener(new SettingsChangeListener()) == null) {
debug.error("Could not add listener. Base URLs will not be dynamically updated");
}
} catch (SMSException e) {
debug.error("Unable to construct ServiceConfigManager", e);
throw new IllegalStateException(e);
} catch (SSOException e) {
debug.error("Unable to construct ServiceConfigManager", e);
throw new IllegalStateException(e);
}
}
Aggregations