use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeLegacySTSStep method perform.
@Override
public void perform() throws UpgradeException {
try {
UpgradeProgress.reportStart("upgrade.legacy.sts.start");
removeAgentInstances(agentsRequiringRemoval);
performDefaultLegacySTSSharedAgentRemoval();
performAgentSubSchemaRemoval();
UpgradeProgress.reportEnd("upgrade.success");
} catch (Exception e) {
DEBUG.error("Unexpected exception caught in UpgradeLegacySTSStep#perform: " + e.getMessage(), e);
UpgradeProgress.reportEnd("upgrade.failed");
throw new UpgradeException("Upgrade of Legacy STS failed: " + e.getMessage(), e);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeLegacySTSStep method performAgentSubSchemaRemoval.
private void performAgentSubSchemaRemoval() throws UpgradeException {
final String nullSubSchema = null;
//I want to obtain the AgentService Schema, so a null SubSchema identifier is passed to getServiceSchema.
final ServiceSchema serviceSchema = UpgradeUtils.getServiceSchema(IdConstants.AGENT_SERVICE, nullSubSchema, UpgradeUtils.SCHEMA_TYPE_ORGANIZATION, getAdminToken());
if (serviceSchema == null) {
throw new UpgradeException("Could not obtain ServiceSchema for AgentService. Legacy STS AgentService SubSchema elements cannot be removed.");
}
for (String subSchemaName : subSchemasRequiringRemoval) {
UpgradeUtils.removeSubSchema(IdConstants.AGENT_SERVICE, subSchemaName, serviceSchema);
removedSubSchemas.add(subSchemaName);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeLegacySTSStep method performDefaultLegacySTSSharedAgentRemoval.
private void performDefaultLegacySTSSharedAgentRemoval() throws UpgradeException {
try {
if (removeDefaultLegacySTSSharedAgent) {
final ServiceConfig baseService = getOrganizationConfigForAgentService(ROOT_REALM);
if (baseService != null) {
baseService.removeSubConfig(LEGACY_STS_RELATED_SHARED_AGENT_NAME);
removedAgents.add(new ToBeRemovedAgentState(LEGACY_STS_RELATED_SHARED_AGENT_NAME, ROOT_REALM, SHARED_AGENT_SCHEMA_ID));
} else {
errorMessages.add("When attempting to remove the shared agent associated with the legacy sts named " + LEGACY_STS_RELATED_SHARED_AGENT_NAME + " no ServiceConfig could be obtained. Removal failed.");
}
}
} catch (SMSException | SSOException e) {
String message = "Exception caught removing the shared agent associated with the legacy sts named " + LEGACY_STS_RELATED_SHARED_AGENT_NAME + ". Exception: " + e;
DEBUG.error(message, e);
throw new UpgradeException(message);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class PolicyConditionUpgrader method migrateSubjectConditions.
private void migrateSubjectConditions(Privilege privilege, MigrationReport migrationReport) throws UpgradeException, EntitlementException {
if (privilege.getSubject() == null) {
return;
}
if (privilege.getSubject() instanceof NoSubject) {
return;
}
if (privilege.getSubject() instanceof LogicalSubject) {
LogicalSubject logicalSubject = (LogicalSubject) privilege.getSubject();
Set<EntitlementSubject> subjects = logicalSubject.getESubjects();
Set<EntitlementSubject> migratedSubjects = new HashSet<EntitlementSubject>();
for (EntitlementSubject subject : subjects) {
if (subject instanceof NoSubject) {
//pass this through directly
migratedSubjects.add(subject);
} else if (!(subject instanceof PolicySubject)) {
//This should never happen due to check in initialise
throw new UpgradeException("Cannot upgrade a subject condition that is not of PolicySubject type!");
} else {
migratedSubjects.add(migrateSubjectCondition((PolicySubject) subject, migrationReport));
}
}
logicalSubject.setESubjects(migratedSubjects);
} else if (privilege.getSubject() instanceof PolicySubject) {
privilege.setSubject(migrateSubjectCondition((PolicySubject) privilege.getSubject(), migrationReport));
} else {
//This should never happen due to check in initialise
throw new UpgradeException("Cannot upgrade a subject condition that is not of PolicySubject type!");
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeOAuth2AuthModulesStep method initialize.
@Override
public void initialize() throws UpgradeException {
try {
ServiceConfigManager scm = new ServiceConfigManager(SERVICE_NAME, getAdminToken());
for (String realm : getRealmNames()) {
ServiceConfig realmConfig = scm.getOrganizationConfig(realm, null);
for (String moduleName : (Set<String>) realmConfig.getSubConfigNames()) {
ServiceConfig moduleConfig = realmConfig.getSubConfig(moduleName);
Map<String, Set<?>> attributes = getAttributes(moduleConfig);
check(attributes, ACCOUNT_MAPPER_PROPERTY, DEFAULT_ACCOUNT_MAPPER, realm, moduleName);
check(attributes, ATTRIBUTE_MAPPER_PROPERTY, DEFAULT_ATTRIBUTE_MAPPER, realm, moduleName);
}
}
} catch (ServiceNotFoundException e) {
// When upgrading from 9.5.x and before there is no OAuth2 auth modules, so we expect this exception in this case
DEBUG.message("OAuth2 auth modules not found. Nothing to upgrade", e);
} catch (Exception ex) {
DEBUG.error("An error occurred while trying to look for upgradable OAuth2 auth modules", ex);
throw new UpgradeException("Unable to retrieve OAuth2 auth modules", ex);
}
}
Aggregations