use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class MigrateValidGotoSetting method perform.
@Override
public void perform() throws UpgradeException {
try {
if (!changes.isEmpty()) {
final ServiceConfigManager validationService = new ServiceConfigManager(VALIDATION_SERVICE, getAdminToken());
final ServiceConfigManager authService = new ServiceConfigManager(ISAuthConstants.AUTH_SERVICE_NAME, getAdminToken());
for (final Map.Entry<String, Set<String>> entry : changes.entrySet()) {
final String realm = entry.getKey();
if (DEBUG.messageEnabled()) {
DEBUG.message("Starting to migrate goto domains for realm: " + realm);
}
UpgradeProgress.reportStart("upgrade.goto.migrate.start", realm);
validationService.createOrganizationConfig(realm, getAttrMap(GOTO_RESOURCES, entry.getValue()));
//The settings now are migrated, we should now clear up the legacy settings
if (DEBUG.messageEnabled()) {
DEBUG.message("Removing old goto domains from iPlanetAMAuthService");
}
final ServiceConfig organizationConfig = authService.getOrganizationConfig(realm, null);
organizationConfig.setAttributes(getAttrMap(LEGACY_GOTO_DOMAINS_SETTING, Collections.EMPTY_SET));
UpgradeProgress.reportEnd("upgrade.success");
}
}
if (DEBUG.messageEnabled()) {
DEBUG.message("Attempting to create the delegation policy in the hidden realm");
}
UpgradeProgress.reportStart("upgrade.goto.policy.start");
final PolicyManager pm = new PolicyManager(getAdminToken(), HIDDEN_REALM);
String policy = AMSetupServlet.readFile(DELEGATION_POLICY_FILE);
policy = ServicesDefaultValues.tagSwap(policy, true);
//Adding the delegation privileges to allow agent accounts to read the new validationService.
PolicyUtils.createPolicies(pm, new ByteArrayInputStream(policy.getBytes()));
if (DEBUG.messageEnabled()) {
DEBUG.message("Delegation policy successfully created under the hidden realm");
}
UpgradeProgress.reportEnd("upgrade.success");
} catch (final IOException ioe) {
UpgradeProgress.reportEnd("upgrade.failed");
throw new UpgradeException("An IO error occurred while reading the delegation policy", ioe);
} catch (final PolicyException pe) {
UpgradeProgress.reportEnd("upgrade.failed");
throw new UpgradeException("An unexpected error occurred while importing the delegation policy", pe);
} catch (final SMSException smse) {
UpgradeProgress.reportEnd("upgrade.failed");
throw new UpgradeException("An error occurred while migrating the valid goto domain setting", smse);
} catch (final SSOException ssoe) {
UpgradeProgress.reportEnd("upgrade.failed");
throw new UpgradeException("An error occurred while migrating the valid goto domain setting", ssoe);
}
}
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());
}
}
Aggregations