Search in sources :

Example 26 with UpgradeException

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);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) HashMap(java.util.HashMap) UpgradeException(org.forgerock.openam.upgrade.UpgradeException)

Example 27 with UpgradeException

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);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) Set(java.util.Set) CollectionUtils.asSet(org.forgerock.openam.utils.CollectionUtils.asSet) AMAuthenticationInstance(com.sun.identity.authentication.config.AMAuthenticationInstance) SMSException(com.sun.identity.sm.SMSException) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SSOException(com.iplanet.sso.SSOException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException) AMAuthenticationManager(com.sun.identity.authentication.config.AMAuthenticationManager)

Example 28 with UpgradeException

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());
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Example 29 with UpgradeException

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());
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) HashSet(java.util.HashSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Example 30 with UpgradeException

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);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) Application(com.sun.identity.entitlement.Application)

Aggregations

UpgradeException (org.forgerock.openam.upgrade.UpgradeException)81 SSOException (com.iplanet.sso.SSOException)29 HashMap (java.util.HashMap)27 SMSException (com.sun.identity.sm.SMSException)25 Set (java.util.Set)25 HashSet (java.util.HashSet)22 Map (java.util.Map)22 ServiceConfig (com.sun.identity.sm.ServiceConfig)21 EntitlementException (com.sun.identity.entitlement.EntitlementException)16 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)14 Application (com.sun.identity.entitlement.Application)10 IOException (java.io.IOException)10 PolicyManager (com.sun.identity.policy.PolicyManager)8 PolicyException (com.sun.identity.policy.PolicyException)6 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)6 EntitlementUtils.resourceTypeFromMap (org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap)6 Node (org.w3c.dom.Node)5 ServiceSchema (com.sun.identity.sm.ServiceSchema)4 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)4 Properties (java.util.Properties)4