use of com.sun.identity.sm.ServiceConfig 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.ServiceConfig 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.ServiceConfig 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.ServiceConfig in project OpenAM by OpenRock.
the class ServerInfoResource method getSocialAuthnImplementations.
/**
* Read out the data whose schema is defined in the file socialAuthN.xml. The enabled implementations value gives
* us the social authentication implementations we care about. We use the values there to index into the display
* names, auth chains and icons.
*
* @param realm
* The realm/organization name
*/
private List<SocialAuthenticationImplementation> getSocialAuthnImplementations(String realm) {
List<SocialAuthenticationImplementation> implementations = new ArrayList<>();
try {
final ServiceConfig serviceConfig = getSocialAuthenticationServiceConfig(realm);
Set<String> enabledImplementationSet = ServiceConfigUtils.getSetAttribute(serviceConfig, SocialAuthenticationImplementation.ENABLED_IMPLEMENTATIONS_ATTRIBUTE);
if (enabledImplementationSet != null) {
for (String name : enabledImplementationSet) {
SocialAuthenticationImplementation implementation = new SocialAuthenticationImplementation();
implementation.setDisplayName(getEntryForImplementation(serviceConfig, name, SocialAuthenticationImplementation.DISPLAY_NAME_ATTRIBUTE));
implementation.setAuthnChain(getEntryForImplementation(serviceConfig, name, SocialAuthenticationImplementation.CHAINS_ATTRIBUTE));
implementation.setIconPath(getEntryForImplementation(serviceConfig, name, SocialAuthenticationImplementation.ICONS_ATTRIBUTE));
if (implementation.isValid()) {
implementations.add(implementation);
}
}
}
} catch (SSOException sso) {
debug.error("Caught SSO Exception while trying to get the ServiceConfigManager", sso);
} catch (SMSException sms) {
debug.error("Caught SMS Exception while trying to get the ServiceConfigManager", sms);
} catch (Exception e) {
if (debug.errorEnabled()) {
debug.error("Caught exception while trying to get the attribute " + SocialAuthenticationImplementation.ENABLED_IMPLEMENTATIONS_ATTRIBUTE, e);
}
}
return implementations;
}
use of com.sun.identity.sm.ServiceConfig 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();
}
}
Aggregations