use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class UpgradeOAuth2ProviderStep method findUpgradableProviders.
private void findUpgradableProviders() throws UpgradeException {
try {
final ServiceSchema serviceSchema = ssm.getOrganizationSchema();
for (String realm : getRealmNames()) {
final ServiceConfig serviceConfig = scm.getOrganizationConfig(realm, null);
final Map<String, Set<String>> withDefaults = serviceConfig.getAttributesForRead();
final Map<String, Set<String>> withoutDefaults = serviceConfig.getAttributesWithoutDefaultsForRead();
final Map<String, Set<String>> withoutValidators = SMSUtils.removeValidators(withDefaults, serviceSchema);
if (isProviderRelyingOnDefaults(withoutDefaults, withoutValidators)) {
attributesToUpdate.put(realm, withoutValidators);
} else if (shouldUpgradeClaims(withDefaults)) {
attributesToUpdate.put(realm, withoutValidators);
} else if (shouldUpgradeAlgorithmName(withoutDefaults)) {
attributesToUpdate.put(realm, null);
}
}
} catch (Exception e) {
DEBUG.error("An error occurred while trying to look for upgradable OAuth2 Providers.", e);
throw new UpgradeException("Unable to retrieve OAuth2 Providers.", e);
}
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class UpgradeEntitlementsStep method perform.
@Override
public void perform() throws UpgradeException {
try {
ServiceConfig appType = getDefaultApplicationType();
Map<String, Set<String>> attrs = new HashMap<String, Set<String>>();
UpgradeProgress.reportStart("upgrade.apptype.start");
attrs.put(SEARCH_INDEX_IMPL, asSet(NEW_SEARCH_IMPL));
attrs.put(SAVE_INDEX_IMPL, asSet(NEW_SAVE_IMPL));
appType.setAttributes(attrs);
UpgradeProgress.reportEnd("upgrade.success");
DEBUG.message("Entitlement service is now using the new TreeSearchIndex/TreeSaveIndex implementations");
if (!upgradableConfigs.isEmpty()) {
for (Map.Entry<String, Map<PolicyType, Set<String>>> entry : upgradableConfigs.entrySet()) {
String realm = entry.getKey();
Map<PolicyType, Set<String>> changes = entry.getValue();
PolicyManager pm = new PolicyManager(getAdminToken(), realm);
Set<String> referrals = changes.get(PolicyType.REFERRAL);
// all set up
if (referrals != null) {
upgradeReferrals(pm, referrals);
}
}
//the entitlements are upgraded regardless of the realms
upgradeEntitlementIndexes();
}
} catch (Exception ex) {
UpgradeProgress.reportEnd("upgrade.failed");
DEBUG.error("An error occurred while upgrading entitlements data", ex);
throw new UpgradeException(ex);
}
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class UpgradeLegacySTSStep method populateToBeRemovedAgents.
private void populateToBeRemovedAgents(String realm) throws UpgradeException {
try {
ServiceConfig baseService = getOrganizationConfigForAgentService(realm);
Set<String> subConfigNames = baseService.getSubConfigNames();
for (String agentName : subConfigNames) {
final ServiceConfig agentInstance = baseService.getSubConfig(agentName);
if (TO_BE_REMOVED_SUB_SCHEMA_NAMES.contains(agentInstance.getSchemaID())) {
agentsRequiringRemoval.add(new ToBeRemovedAgentState(agentName, realm, agentInstance.getSchemaID()));
}
}
} catch (SMSException | SSOException e) {
throw new UpgradeException("Could not determine the legacy-sts-related agents to remove for realm " + realm + ". Exception: " + e.getMessage());
}
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class UpgradeLegacySTSStep method determineDefaultLegacySTSSharedAgentRemoval.
private void determineDefaultLegacySTSSharedAgentRemoval() throws UpgradeException {
try {
ServiceConfig baseService = getOrganizationConfigForAgentService(ROOT_REALM);
Set<String> subConfigNames = baseService.getSubConfigNames();
if (subConfigNames.contains(LEGACY_STS_RELATED_SHARED_AGENT_NAME)) {
final ServiceConfig agentInstance = baseService.getSubConfig(LEGACY_STS_RELATED_SHARED_AGENT_NAME);
if (SHARED_AGENT_SCHEMA_ID.equals(agentInstance.getSchemaID())) {
Map<String, Set<String>> attributes = agentInstance.getAttributesWithoutDefaultsForRead();
if (attributes != null) {
Set<String> sharedSet = attributes.get(AGENTS_ALLOWED_TO_READ_ATTRIBUTE);
if ((sharedSet != null) && Sets.symmetricDifference(sharedSet, DEFAULT_STS_SHARED_AGENT_SHARE_SET).isEmpty()) {
removeDefaultLegacySTSSharedAgent = true;
agentsRequiringRemoval.add(new ToBeRemovedAgentState(LEGACY_STS_RELATED_SHARED_AGENT_NAME, ROOT_REALM, SHARED_AGENT_SCHEMA_ID));
}
}
}
}
} catch (SMSException | SSOException e) {
throw new UpgradeException("Could not determine whether to remove the legacy-sts SharedAgent called " + LEGACY_STS_RELATED_SHARED_AGENT_NAME + " in the root realm. Exception: " + e.getMessage());
}
}
use of com.sun.identity.sm.ServiceConfig 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);
}
}
Aggregations