use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeExternalCTSConfigurationStep method perform.
@Override
public void perform() throws UpgradeException {
try {
DEBUG.message("External CTS Configuration upgrading: " + propertiesToModify);
UpgradeProgress.reportStart("upgrade.cts.property");
for (Entry<String, String> serverProperty : propertiesToModify.entrySet()) {
// get existing values
Map<String, String> existingServerProperties = new HashMap(ServerConfiguration.getServerInstance(getAdminToken(), serverProperty.getKey()));
// add new values to existing values
existingServerProperties.put(CoreTokenConstants.CTS_STORE_HOSTNAME, serverProperty.getValue());
existingServerProperties.keySet().remove(CTS_STORE_PORT);
ServerConfiguration.upgradeServerInstance(getAdminToken(), serverProperty.getKey(), null, existingServerProperties);
}
UpgradeProgress.reportEnd("upgrade.success");
} catch (Exception ex) {
DEBUG.error("Unable to upgrade External CTS properties", ex);
throw new UpgradeException(ex);
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class UpgradeLDAPAuthModulesStep method initialize.
@Override
public void initialize() throws UpgradeException {
String realmName = null;
String authInstanceName = null;
try {
for (final String realm : getRealmNames()) {
realmName = realm;
final AMAuthenticationManager mgr = new AMAuthenticationManager(getAdminToken(), realm);
final Set<AMAuthenticationInstance> moduleInstances = mgr.getAuthenticationInstances();
if (moduleInstances != null) {
for (final AMAuthenticationInstance moduleInstance : moduleInstances) {
if (moduleInstance.getType().equalsIgnoreCase("LDAP") || moduleInstance.getType().equalsIgnoreCase("AD")) {
authInstanceName = moduleInstance.getName();
if (DEBUG.messageEnabled()) {
DEBUG.message("ldap/ad auth module configuration found under realm: " + realm + " : " + authInstanceName);
}
final Map<String, Set<String>> configProperties = moduleInstance.getAttributeValues(asSet(SSL_ENABLED_PROPERTY));
if (configProperties != null && !configProperties.isEmpty()) {
final String sslEnabledProp = CollectionHelper.getMapAttr(configProperties, SSL_ENABLED_PROPERTY);
if (sslEnabledProp != null) {
if (DEBUG.messageEnabled()) {
DEBUG.message("ldap/ad auth module config " + authInstanceName + " in realm: " + realm + " " + SSL_ENABLED_PROPERTY + ":" + sslEnabledProp);
}
Map<String, Boolean> instanceMap = instances.get(realm);
if (instanceMap == null) {
instanceMap = new HashMap<String, Boolean>();
instances.put(realm, instanceMap);
}
instanceMap.put(authInstanceName, Boolean.parseBoolean(sslEnabledProp));
}
}
}
}
}
}
} catch (final Exception ex) {
DEBUG.error("Unable to identify the configuration for the old ldap/ad auth module instance " + authInstanceName + " in realm " + realmName, ex);
throw new UpgradeException("An error occurred while trying to identify the configuration for the old " + "ldap/ad auth module instance " + authInstanceName + " in realm " + realmName, ex);
}
}
use of org.forgerock.openam.upgrade.UpgradeException 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 org.forgerock.openam.upgrade.UpgradeException 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());
}
}
use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.
the class RemoveReferralsStep method instateReferredApplication.
private void instateReferredApplication(String applicationName, Set<String> destinationRealms) throws EntitlementException, UpgradeException {
String shallowestRealm = findShallowestRealm(destinationRealms);
String sourceRealm = shallowestRealm.substring(0, shallowestRealm.lastIndexOf('/') + 1);
Application application = applicationService.getApplication(getAdminSubject(), sourceRealm, applicationName);
if (application == null) {
throw new UpgradeException(format("Expected application %s in realm %s", applicationName, sourceRealm));
}
if (isEmpty(application.getResourceTypeUuids())) {
throw new UpgradeException(format("Expected application %s to have some resource types", applicationName));
}
if (application.getResourceTypeUuids().size() > 1) {
throw new UpgradeException(format("Expected application %s to have a single resource type", applicationName));
}
for (String destinationRealm : destinationRealms) {
enactRequiredPolicyModelChanges(application, sourceRealm, destinationRealm);
}
}
Aggregations