use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class UpgradeOAuth2AuthModulesStep method perform.
@Override
public void perform() throws UpgradeException {
try {
ServiceConfigManager scm = new ServiceConfigManager(SERVICE_NAME, getAdminToken());
for (Map.Entry<String, Set<String>> realm : affectedRealms.entrySet()) {
ServiceConfig realmConfig = scm.getOrganizationConfig(realm.getKey(), null);
for (String moduleName : realm.getValue()) {
ServiceConfig moduleConfig = realmConfig.getSubConfig(moduleName);
Map<String, Set<?>> attributes = getAttributes(moduleConfig);
if (attributes.get(ACCOUNT_MAPPER_PROPERTY).contains(DEFAULT_ACCOUNT_MAPPER)) {
moduleConfig.replaceAttributeValues(ACCOUNT_MAPPER_PROPERTY, asSet(DEFAULT_ACCOUNT_MAPPER), asSet(JSON_MAPPER));
}
if (attributes.get(ATTRIBUTE_MAPPER_PROPERTY).contains(DEFAULT_ATTRIBUTE_MAPPER)) {
moduleConfig.replaceAttributeValues(ATTRIBUTE_MAPPER_PROPERTY, asSet(DEFAULT_ATTRIBUTE_MAPPER), asSet(JSON_MAPPER));
}
moduleCount++;
}
}
} catch (Exception ex) {
DEBUG.error("An error occurred while trying to update OAuth2 auth modules", ex);
throw new UpgradeException("Unable to update OAuth2 modules", ex);
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class UpgradeOAuth2ClientStep method initialize.
@Override
public void initialize() throws UpgradeException {
try {
ServiceConfigManager scm = new ServiceConfigManager(IdConstants.AGENT_SERVICE, getAdminToken());
for (String realm : getRealmNames()) {
findUpgradableConfigs(realm, scm, AgentType.AGENT);
findUpgradableConfigs(realm, scm, AgentType.GROUP);
}
} catch (Exception ex) {
DEBUG.error("An error occurred while trying to look for upgradable OAuth2 client profiles", ex);
throw new UpgradeException("Unable to retrieve modified OAuth2 clients");
}
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class DataStore method getIndexCount.
private static int getIndexCount(String realm, boolean referral) {
int count = 0;
if (adminToken != null) {
try {
ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, adminToken);
ServiceConfig orgConf = mgr.getOrganizationConfig(realm, null);
if (orgConf != null) {
Map<String, Set<String>> map = orgConf.getAttributes();
Set<String> set = (referral) ? map.get(REFERRAL_INDEX_COUNT) : map.get(INDEX_COUNT);
if ((set != null) && !set.isEmpty()) {
String strCount = (String) set.iterator().next();
count = Integer.parseInt(strCount);
}
}
} catch (NumberFormatException ex) {
PolicyConstants.DEBUG.error("DataStore.getIndexCount", ex);
} catch (SMSException ex) {
PolicyConstants.DEBUG.error("DataStore.getIndexCount", ex);
} catch (SSOException ex) {
PolicyConstants.DEBUG.error("DataStore.getIndexCount", ex);
}
}
return count;
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class DataStore method getOrgConfig.
private ServiceConfig getOrgConfig(SSOToken adminToken, String realm) throws SMSException, SSOException {
ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, adminToken);
ServiceConfig orgConf = mgr.getOrganizationConfig(realm, null);
if (orgConf == null) {
mgr.createOrganizationConfig(realm, null);
}
return orgConf;
}
use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.
the class EntitlementService method getApplicationConfiguration.
/**
* Get the service config for registered applications.
* @param token The admin token for access to the Service Config.
* @param realm The realm from which to retrieve the service config.
* @return The application Service Config.
*/
private ServiceConfig getApplicationConfiguration(SSOToken token, String realm) {
try {
if (token != null) {
if (realm.startsWith(SMSEntry.SUN_INTERNAL_REALM_PREFIX) || realm.startsWith(SMSEntry.SUN_INTERNAL_REALM_PREFIX2)) {
realm = "/";
}
// TODO. Since applications for the hidden realms have to be
// the same as root realm mainly for delegation without any
// referrals, the hack is to use root realm for hidden realm.
String hackRealm = LDAPUtils.isDN(realm) ? DNMapper.orgNameToRealmName(realm) : realm;
ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, token);
ServiceConfig orgConfig = mgr.getOrganizationConfig(hackRealm, null);
if (orgConfig != null) {
return orgConfig.getSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS);
}
} else {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration, admin token is missing");
}
} catch (ClassCastException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration", ex);
} catch (SMSException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration", ex);
} catch (SSOException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration", ex);
}
return null;
}
Aggregations