use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class SchemaResourceNamesStep method initialize.
@Override
public void initialize() throws UpgradeException {
if (VersionUtils.isCurrentVersionLessThan(AM_13, true)) {
Map<String, Document> serviceXmlContent = UpgradeServiceUtils.getServiceDefinitions(getAdminToken());
serviceModifications = new HashMap<>();
for (Map.Entry<String, Document> service : serviceXmlContent.entrySet()) {
try {
DEBUG.message("Finding resource names in {}", service.getKey());
ServiceModifier modifier = new ServiceModifier();
NodeList nodes = (NodeList) xpath.evaluate("//*[@" + RESOURCE_NAME + "]", service.getValue().getDocumentElement(), XPathConstants.NODESET);
for (int i = 0; i < nodes.getLength(); i++) {
Element element = (Element) nodes.item(i);
ElementModifier target = buildPath(element, modifier);
target.resourceNameModifier = new ResourceNameModifier(element.getAttribute(RESOURCE_NAME));
}
if (!modifier.modifiers.isEmpty()) {
serviceModifications.put(service.getKey(), modifier);
}
} catch (XPathExpressionException e) {
throw new UpgradeException(e);
}
}
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class TwoStepVerificationSettingUpgrade method initialize.
@Override
public void initialize() throws UpgradeException {
try {
// Does the policy already exist...
manager = new PolicyManager(getAdminToken(), HIDDEN_REALM);
applicable = manager.getPolicyNames(EVALUATE_POLICY).isEmpty();
} catch (SSOException ssoE) {
throw new UpgradeException("Failed to identify existing privileges", ssoE);
} catch (PolicyException pE) {
throw new UpgradeException("Failed to identify existing privileges", pE);
}
}
use of org.forgerock.openam.upgrade.UpgradeException 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);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeOAuth2ClientStep method initialize.
@Override
public void initialize() throws UpgradeException {
try {
ServiceConfigManager scm = new ServiceConfigManager(IdConstants.AGENT_SERVICE, getAdminToken());
for (String realm : getRealmNames()) {
findUpgradableConfigs(realm, scm, AgentType.AGENT);
findUpgradableConfigs(realm, scm, AgentType.GROUP);
}
} catch (Exception ex) {
DEBUG.error("An error occurred while trying to look for upgradable OAuth2 client profiles", ex);
throw new UpgradeException("Unable to retrieve modified OAuth2 clients");
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class ServiceSchemaModifications method getAttributesModified.
private Set<AttributeSchemaImpl> getAttributesModified(Set<AttributeSchemaImpl> newAttrs, Set<AttributeSchemaImpl> existingAttrs) throws UpgradeException {
Set<AttributeSchemaImpl> attrMods = new HashSet<AttributeSchemaImpl>();
for (AttributeSchemaImpl newAttr : newAttrs) {
// skip attributes that are not explicitly named for upgrade
if (ServerUpgrade.getServiceHelper(serviceName) == null || !ServerUpgrade.getServiceHelper(serviceName).getAttributes().contains(newAttr.getName())) {
continue;
}
for (AttributeSchemaImpl existingAttr : existingAttrs) {
if (!existingAttr.getName().equals(newAttr.getName())) {
continue;
}
try {
UpgradeHelper helper = ServerUpgrade.getServiceHelper(serviceName);
AttributeSchemaImpl upgradedAttr = helper.upgradeAttribute(existingAttr, newAttr);
if (upgradedAttr != null) {
attrMods.add(upgradedAttr);
}
} catch (UpgradeException ue) {
UpgradeUtils.debug.error("Unable to process upgrade helper", ue);
throw ue;
}
}
}
return attrMods;
}
Aggregations