Search in sources :

Example 21 with UpgradeException

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

the class UpgradeOAuth2ProviderStep method findUpgradableProviders.

private void findUpgradableProviders() throws UpgradeException {
    try {
        final ServiceSchema serviceSchema = ssm.getOrganizationSchema();
        for (String realm : getRealmNames()) {
            final ServiceConfig serviceConfig = scm.getOrganizationConfig(realm, null);
            final Map<String, Set<String>> withDefaults = serviceConfig.getAttributesForRead();
            final Map<String, Set<String>> withoutDefaults = serviceConfig.getAttributesWithoutDefaultsForRead();
            final Map<String, Set<String>> withoutValidators = SMSUtils.removeValidators(withDefaults, serviceSchema);
            if (isProviderRelyingOnDefaults(withoutDefaults, withoutValidators)) {
                attributesToUpdate.put(realm, withoutValidators);
            } else if (shouldUpgradeClaims(withDefaults)) {
                attributesToUpdate.put(realm, withoutValidators);
            } else if (shouldUpgradeAlgorithmName(withoutDefaults)) {
                attributesToUpdate.put(realm, null);
            }
        }
    } catch (Exception e) {
        DEBUG.error("An error occurred while trying to look for upgradable OAuth2 Providers.", e);
        throw new UpgradeException("Unable to retrieve OAuth2 Providers.", e);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException)

Example 22 with UpgradeException

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

the class UpgradeEntitlementSubConfigsStep method addMissingActions.

/**
     * Adds the missing actions to their corresponding application type's.
     *
     * @throws UpgradeException If there was an error while updating the application type.
     */
private void addMissingActions() throws UpgradeException {
    for (final Map.Entry<String, Map<String, Boolean>> entry : missingActions.entrySet()) {
        final String name = entry.getKey();
        final Map<String, Boolean> actions = entry.getValue();
        try {
            UpgradeProgress.reportStart(AUDIT_MODIFIED_TYPE_START, name);
            if (DEBUG.messageEnabled()) {
                DEBUG.message("Modifying application type " + name + " ; adding actions: " + actions);
            }
            final ApplicationType type = getType(name);
            type.getActions().putAll(actions);
            entitlementService.storeApplicationType(type);
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
        } catch (EntitlementException ee) {
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
            throw new UpgradeException(ee);
        }
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ApplicationType(com.sun.identity.entitlement.ApplicationType) EntitlementException(com.sun.identity.entitlement.EntitlementException) HashMap(java.util.HashMap) Map(java.util.Map) EntitlementUtils.resourceTypeFromMap(org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap)

Example 23 with UpgradeException

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

the class UpgradeEntitlementSubConfigsStep method addChangedSubjects.

/**
     * Clears the subjects currently associated with an application, then replaces them with
     * the new set of conditions defined.
     *
     * @throws UpgradeException If there was an error while updating the application.
     */
private void addChangedSubjects() throws UpgradeException {
    for (final Map.Entry<String, Set<String>> entry : changedSubjects.entrySet()) {
        final String name = entry.getKey();
        final Set<String> subjects = entry.getValue();
        try {
            UpgradeProgress.reportStart(AUDIT_MODIFIED_SUB_START, name);
            if (DEBUG.messageEnabled()) {
                DEBUG.message("Modifying application " + name + " ; adding subjects: " + subjects);
            }
            final Application application = getApplication(name);
            application.setSubjects(subjects);
            entitlementService.storeApplication(application);
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
        } catch (EntitlementException ee) {
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
            throw new UpgradeException(ee);
        }
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) EntitlementException(com.sun.identity.entitlement.EntitlementException) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Map(java.util.Map) EntitlementUtils.resourceTypeFromMap(org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap) Application(com.sun.identity.entitlement.Application)

Example 24 with UpgradeException

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

the class UpgradeEntitlementsStep method perform.

@Override
public void perform() throws UpgradeException {
    try {
        ServiceConfig appType = getDefaultApplicationType();
        Map<String, Set<String>> attrs = new HashMap<String, Set<String>>();
        UpgradeProgress.reportStart("upgrade.apptype.start");
        attrs.put(SEARCH_INDEX_IMPL, asSet(NEW_SEARCH_IMPL));
        attrs.put(SAVE_INDEX_IMPL, asSet(NEW_SAVE_IMPL));
        appType.setAttributes(attrs);
        UpgradeProgress.reportEnd("upgrade.success");
        DEBUG.message("Entitlement service is now using the new TreeSearchIndex/TreeSaveIndex implementations");
        if (!upgradableConfigs.isEmpty()) {
            for (Map.Entry<String, Map<PolicyType, Set<String>>> entry : upgradableConfigs.entrySet()) {
                String realm = entry.getKey();
                Map<PolicyType, Set<String>> changes = entry.getValue();
                PolicyManager pm = new PolicyManager(getAdminToken(), realm);
                Set<String> referrals = changes.get(PolicyType.REFERRAL);
                //  all set up
                if (referrals != null) {
                    upgradeReferrals(pm, referrals);
                }
            }
            //the entitlements are upgraded regardless of the realms
            upgradeEntitlementIndexes();
        }
    } catch (Exception ex) {
        UpgradeProgress.reportEnd("upgrade.failed");
        DEBUG.error("An error occurred while upgrading entitlements data", ex);
        throw new UpgradeException(ex);
    }
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) HashSet(java.util.HashSet) Set(java.util.Set) CollectionUtils.asSet(org.forgerock.openam.utils.CollectionUtils.asSet) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceConfig(com.sun.identity.sm.ServiceConfig) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) EnumMap(java.util.EnumMap)

Example 25 with UpgradeException

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

the class UpgradeExternalCTSConfigurationStep method initialize.

@Override
public void initialize() throws UpgradeException {
    try {
        // get server instances config
        Set<String> serverNames = ServerConfiguration.getServers(getAdminToken());
        // get the default server values and store values
        Properties props = ServerConfiguration.getServerInstance(getAdminToken(), ServerConfiguration.DEFAULT_SERVER_CONFIG);
        setDefaultValues(props);
        checkCTSStoreConnections(ServerConfiguration.DEFAULT_SERVER_CONFIG, props);
        // check values for each instance
        for (String serverName : serverNames) {
            checkCTSStoreConnections(serverName, ServerConfiguration.getServerInstance(getAdminToken(), serverName));
        }
    } catch (Exception ex) {
        DEBUG.error("Unable to upgrade External CTS Configuration", ex);
        throw new UpgradeException(ex);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) Properties(java.util.Properties) UpgradeException(org.forgerock.openam.upgrade.UpgradeException)

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