use of org.forgerock.openam.upgrade.UpgradeException 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 org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeEntitlementSubConfigsStep method addMissingActions.
/**
* Adds the missing actions to their corresponding application type's.
*
* @throws UpgradeException If there was an error while updating the application type.
*/
private void addMissingActions() throws UpgradeException {
for (final Map.Entry<String, Map<String, Boolean>> entry : missingActions.entrySet()) {
final String name = entry.getKey();
final Map<String, Boolean> actions = entry.getValue();
try {
UpgradeProgress.reportStart(AUDIT_MODIFIED_TYPE_START, name);
if (DEBUG.messageEnabled()) {
DEBUG.message("Modifying application type " + name + " ; adding actions: " + actions);
}
final ApplicationType type = getType(name);
type.getActions().putAll(actions);
entitlementService.storeApplicationType(type);
UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
} catch (EntitlementException ee) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException(ee);
}
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeEntitlementSubConfigsStep method addChangedSubjects.
/**
* Clears the subjects currently associated with an application, then replaces them with
* the new set of conditions defined.
*
* @throws UpgradeException If there was an error while updating the application.
*/
private void addChangedSubjects() throws UpgradeException {
for (final Map.Entry<String, Set<String>> entry : changedSubjects.entrySet()) {
final String name = entry.getKey();
final Set<String> subjects = entry.getValue();
try {
UpgradeProgress.reportStart(AUDIT_MODIFIED_SUB_START, name);
if (DEBUG.messageEnabled()) {
DEBUG.message("Modifying application " + name + " ; adding subjects: " + subjects);
}
final Application application = getApplication(name);
application.setSubjects(subjects);
entitlementService.storeApplication(application);
UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
} catch (EntitlementException ee) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException(ee);
}
}
}
use of org.forgerock.openam.upgrade.UpgradeException 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 org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeExternalCTSConfigurationStep method initialize.
@Override
public void initialize() throws UpgradeException {
try {
// get server instances config
Set<String> serverNames = ServerConfiguration.getServers(getAdminToken());
// get the default server values and store values
Properties props = ServerConfiguration.getServerInstance(getAdminToken(), ServerConfiguration.DEFAULT_SERVER_CONFIG);
setDefaultValues(props);
checkCTSStoreConnections(ServerConfiguration.DEFAULT_SERVER_CONFIG, props);
// check values for each instance
for (String serverName : serverNames) {
checkCTSStoreConnections(serverName, ServerConfiguration.getServerInstance(getAdminToken(), serverName));
}
} catch (Exception ex) {
DEBUG.error("Unable to upgrade External CTS Configuration", ex);
throw new UpgradeException(ex);
}
}
Aggregations