use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class TwoStepVerificationSettingUpgrade method perform.
@Override
public void perform() throws UpgradeException {
try {
UpgradeProgress.reportStart(AUDIT_NEW_POLICY_START);
// Creates a new policy entry to represent the new agent privilege.
DEBUG.message("Creating new 2FA privilege for users called " + EVALUATE_POLICY);
String policy = AMSetupServlet.readFile(DELEGATION_POLICY_FILE);
policy = ServicesDefaultValues.tagSwap(policy, true);
PolicyUtils.createPolicies(manager, new ByteArrayInputStream(policy.getBytes()));
UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
} catch (IOException ioE) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException("Failed during the creation of a new privilege for agents", ioE);
} catch (SSOException ssoE) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException("Failed during the creation of a new privilege for agents", ssoE);
} catch (PolicyException pE) {
UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
throw new UpgradeException("Failed during the creation of a new privilege for agents", pE);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class MigrateAgentGroups method initialize.
@Override
public void initialize() throws UpgradeException {
try {
final ServiceConfigManager scm = new ServiceConfigManager(getAdminToken(), IdConstants.AGENT_SERVICE, "1.0");
for (final String realm : getRealmNames()) {
final ServiceConfig orgConfig = scm.getOrganizationConfig(realm, null);
final Set<String> agentNames = orgConfig.getSubConfigNames();
for (final String agentName : agentNames) {
final ServiceConfig agentConfig = orgConfig.getSubConfig(agentName);
final String agentGroupName = agentConfig.getLabeledUri();
if (DEBUG.messageEnabled()) {
DEBUG.message("Agent: \"" + agentName + "\" Group: \"" + agentGroupName + "\"");
}
if (agentGroupName != null && !agentGroupName.isEmpty()) {
Set<String> agents = upgradableAgents.get(realm);
if (agents == null) {
agents = new HashSet<String>();
upgradableAgents.put(realm, agents);
}
agents.add(agentName);
}
}
}
if (DEBUG.messageEnabled()) {
DEBUG.message("The following agents needs to be migrated: " + upgradableAgents);
}
} catch (final SMSException smse) {
throw new UpgradeException("Unable to initialize agent group migration", smse);
} catch (final SSOException ssoe) {
throw new UpgradeException("Unable to initialize agent group migration", ssoe);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class MigrateAgentGroups method perform.
@Override
public void perform() throws UpgradeException {
try {
final ServiceConfigManager scm = new ServiceConfigManager(getAdminToken(), IdConstants.AGENT_SERVICE, "1.0");
for (final Map.Entry<String, Set<String>> entry : upgradableAgents.entrySet()) {
final String realm = entry.getKey();
final Set<String> agents = entry.getValue();
final ServiceConfig orgConfig = scm.getOrganizationConfig(realm, null);
for (final String agentName : agents) {
UpgradeProgress.reportStart("upgrade.agent.group.start", agentName);
final ServiceConfig agentConfig = orgConfig.getSubConfig(agentName);
final String agentGroupName = agentConfig.getLabeledUri();
agentConfig.setAttributes(getAgentGroupAttribute(agentGroupName));
agentConfig.deleteLabeledUri(agentGroupName);
UpgradeProgress.reportEnd("upgrade.success");
}
}
} catch (final SMSException smse) {
UpgradeProgress.reportEnd("upgrade.failed");
throw new UpgradeException("Unable to perform agent group migration", smse);
} catch (final SSOException ssoe) {
UpgradeProgress.reportEnd("upgrade.failed");
throw new UpgradeException("Unable to perform agent group migration", ssoe);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeOAuth2ProviderStep method initialize.
@Override
public void initialize() throws UpgradeException {
final SSOToken token = getAdminToken();
try {
scm = new ServiceConfigManager(OAUTH2_PROVIDER, token);
ssm = new ServiceSchemaManager(OAUTH2_PROVIDER, token);
findUpgradableProviders();
} catch (ServiceNotFoundException e) {
//When upgrading from 10.0.x and before there is no OAuth2 service, so we expect this exception in this case
DEBUG.message("OAuth2Provider service not found. Nothing to upgrade", e);
} catch (Exception e) {
DEBUG.error("An error occurred while trying to create Service Config and Schema Managers.", e);
throw new UpgradeException("Unable to create Service Config and Schema Managers.", e);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeServerDefaultsStep method initialize.
@Override
public void initialize() throws UpgradeException {
try {
existingDefaults = new HashMap(ServerConfiguration.getServerInstance(getAdminToken(), ServerConfiguration.DEFAULT_SERVER_CONFIG));
Map<String, String> newDefaults = ServerConfiguration.getNewServerDefaults(getAdminToken());
Properties validProperties = new Properties();
validProperties.load(getClass().getResourceAsStream(VALID_SERVER_CONFIG_PROPERTIES));
Map<String, String> validServerProperties = new HashMap(validProperties);
Set<String> attrsToUpgrade = ServerUpgrade.getAttrsToUpgrade();
addedAttrs = calculateAddedServerDefaults(newDefaults, existingDefaults);
modifiedAttrs = calculateModifiedServerDefaults(newDefaults, existingDefaults, attrsToUpgrade);
deletedAttrs = calculateDeletedServerDefaults(existingDefaults, validServerProperties);
} catch (Exception ex) {
throw new UpgradeException(ex);
}
}
Aggregations