Search in sources :

Example 61 with UpgradeException

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

Example 62 with UpgradeException

use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.

the class UpgradeServerDefaultsStep method perform.

@Override
public void perform() throws UpgradeException {
    try {
        UpgradeProgress.reportStart("upgrade.platformupdate");
        existingDefaults = new HashMap(ServerConfiguration.getServerInstance(getAdminToken(), ServerConfiguration.DEFAULT_SERVER_CONFIG));
        Map<String, String> upgradedValues = new HashMap<String, String>(existingDefaults);
        upgradedValues.putAll(addedAttrs);
        upgradedValues.putAll(modifiedAttrs);
        upgradedValues.keySet().removeAll(deletedAttrs);
        ServerConfiguration.upgradeServerInstance(getAdminToken(), DEFAULT_SERVER_CONFIG, DEFAULT_SERVER_ID, upgradedValues);
        UpgradeProgress.reportEnd("upgrade.success");
    } catch (Exception ex) {
        UpgradeUtils.debug.error("Unable to upgrade server default 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 63 with UpgradeException

use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.

the class UpgradeServerDefaultsStep method getUpdatedDefaults.

/**
     * Gets the current server default values to see if any updates in previous upgrade steps need to be re-applied.
     * @return the key value pairs of attributes that will need to be re-applied
     * @throws UpgradeException
     */
private Map<String, String> getUpdatedDefaults() throws UpgradeException {
    HashMap<String, String> modifiedValues = new HashMap<String, String>();
    try {
        Map<String, String> currentDefaults = new HashMap(ServerConfiguration.getServerInstance(getAdminToken(), ServerConfiguration.DEFAULT_SERVER_CONFIG));
        String currentDefault = currentDefaults.get(CoreTokenConstants.CTS_STORE_HOSTNAME);
        String existingDefault = existingDefaults.get(CoreTokenConstants.CTS_STORE_HOSTNAME);
        if (DEBUG.messageEnabled()) {
            DEBUG.message("currentDefault: " + currentDefault + "existingDefault: " + existingDefault);
        }
        if (currentDefault != null && existingDefault != null && !existingDefault.equals(currentDefault)) {
            modifiedValues.put(CoreTokenConstants.CTS_STORE_HOSTNAME, currentDefault);
        }
    } catch (Exception ex) {
        DEBUG.error("An error occurred trying to get current configuration.", ex);
        throw new UpgradeException(ex);
    }
    return modifiedValues;
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) HashMap(java.util.HashMap) UpgradeException(org.forgerock.openam.upgrade.UpgradeException)

Example 64 with UpgradeException

use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.

the class UpgradeIdRepoSubConfigs method perform.

@Override
public void perform() throws UpgradeException {
    for (Map.Entry<String, Set<String>> entry : repos.entrySet()) {
        try {
            String realm = entry.getKey();
            OrganizationConfigManager ocm = new OrganizationConfigManager(getAdminToken(), realm);
            for (String subConfig : entry.getValue()) {
                UpgradeProgress.reportStart("upgrade.data.store.start", subConfig);
                Map<String, Set<String>> newValues = new HashMap<String, Set<String>>(2);
                ServiceConfig sc = ocm.getServiceConfig(IdConstants.REPO_SERVICE);
                ServiceConfig repoConfig = sc.getSubConfig(subConfig);
                Map<String, Set<String>> attributes = repoConfig.getAttributes();
                String className = CollectionHelper.getMapAttr(attributes, IdConstants.ID_REPO);
                if (OLD_IDREPO_CLASS.equals(className)) {
                    newValues.put(IdConstants.ID_REPO, asSet(NEW_IDREPO_CLASS));
                }
                String newFilter = getModifiedFilter(attributes);
                if (newFilter != null) {
                    if (DEBUG.messageEnabled()) {
                        DEBUG.message("Upgrading psearch filter for datastore: " + subConfig + " to: " + newFilter);
                    }
                    newValues.put(PSEARCH_FILTER, asSet(newFilter));
                }
                Map<String, String> sslModes = oldConnectionModeRepos.get(realm);
                String sslMode = (sslModes == null) ? null : sslModes.get(subConfig);
                if (sslMode != null) {
                    if (DEBUG.messageEnabled()) {
                        DEBUG.message("Upgrading connection mode for datastore: " + subConfig + " to: " + sslMode);
                    }
                    newValues.put(NEW_CONNECTION_MODE, asSet(sslMode));
                }
                //There is no need to remove the obsolete attributes here, because once we set an attribute, the SMS
                //framework will automagically remove those that do not adhere to the schema.
                repoConfig.setAttributes(newValues);
                UpgradeProgress.reportEnd("upgrade.success");
            }
        } catch (Exception ex) {
            UpgradeProgress.reportEnd("upgrade.failed");
            DEBUG.error("An error occurred while upgrading service config ", ex);
            throw new UpgradeException("Unable to upgrade IdRepo configuration");
        }
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ServiceConfig(com.sun.identity.sm.ServiceConfig) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) HashMap(java.util.HashMap) Map(java.util.Map) UpgradeException(org.forgerock.openam.upgrade.UpgradeException)

Example 65 with UpgradeException

use of org.forgerock.openam.upgrade.UpgradeException in project OpenAM by OpenRock.

the class UpgradeLDAPAuthModulesStep method perform.

@Override
public void perform() throws UpgradeException {
    UpgradeProgress.reportStart("upgrade.auth.instances.ldap.start");
    for (final Map.Entry<String, Map<String, Boolean>> entry : instances.entrySet()) {
        final String realm = entry.getKey();
        final Map<String, Boolean> instanceMap = entry.getValue();
        try {
            updateAttributes(realm, instanceMap);
        } catch (final Exception ex) {
            UpgradeProgress.reportEnd("upgrade.failed");
            DEBUG.error("An error occurred while upgrading service configs for auth module instances " + " in realm " + realm, ex);
            throw new UpgradeException("Unable to upgrade ldap/ad auth module instance configurations " + " in realm " + realm, ex);
        }
    }
    UpgradeProgress.reportEnd("upgrade.success");
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) HashMap(java.util.HashMap) Map(java.util.Map) SMSException(com.sun.identity.sm.SMSException) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SSOException(com.iplanet.sso.SSOException) AMConfigurationException(com.sun.identity.authentication.config.AMConfigurationException)

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