Search in sources :

Example 46 with UpgradeException

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

the class AllowEvaluateForAgentsUpgradeStep 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);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) PolicyManager(com.sun.identity.policy.PolicyManager) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException)

Example 47 with UpgradeException

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

the class UpgradeEntitlementSubConfigsStep method addMissingResourceTypeUUIDs.

/**
     * Clears the resourceType UUIDs currently associated with an application, then replaces them with
     * the new set of resourceType UUIDs defined.
     *
     * @throws UpgradeException If there was an error while updating the application.
     */
private void addMissingResourceTypeUUIDs() throws UpgradeException {
    for (final Map.Entry<String, Set<String>> entry : changedResourceTypeUUIDs.entrySet()) {
        final String name = entry.getKey();
        final Set<String> resourceTypeUUIDs = entry.getValue();
        try {
            UpgradeProgress.reportStart(AUDIT_MODIFIED_UUID_START, name);
            if (DEBUG.messageEnabled()) {
                DEBUG.message("Modifying application " + name + ": adding resourceType UUIDs: " + resourceTypeUUIDs);
            }
            final Application application = getApplication(name);
            application.addAllResourceTypeUuids(resourceTypeUUIDs);
            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 48 with UpgradeException

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

the class UpgradeEntitlementSubConfigsStep method addMissingApplications.

/**
     * Adds missing applications.
     *
     * @throws UpgradeException
     *         should the processing of creating new applications fail
     */
private void addMissingApplications() throws UpgradeException {
    for (final Node applicationNode : missingApps) {
        final Map<String, Set<String>> keyValueMap = parseAttributeValuePairTags(applicationNode);
        final String name = getNodeAttributeValue(applicationNode, NAME);
        UpgradeProgress.reportStart(AUDIT_NEW_APPLICATION_START, name);
        keyValueMap.put(NAME, Collections.singleton(name));
        final String typeName = retrieveSingleValue(APPLICATION_TYPE, keyValueMap);
        final ApplicationType applicationType = getType(typeName);
        if (applicationType == null) {
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
            throw new UpgradeException("Unknown requested application type " + typeName);
        }
        try {
            DEBUG.message("Saving new entitlement application: " + name);
            entitlementService.storeApplication(createApplication(applicationType, name, keyValueMap));
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
        } catch (EntitlementException eE) {
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
            throw new UpgradeException(eE);
        } catch (InstantiationException ie) {
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
            throw new UpgradeException(ie);
        } catch (IllegalAccessException iae) {
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
            throw new UpgradeException(iae);
        }
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ApplicationType(com.sun.identity.entitlement.ApplicationType) EntitlementException(com.sun.identity.entitlement.EntitlementException) HashSet(java.util.HashSet) Set(java.util.Set) Node(org.w3c.dom.Node)

Example 49 with UpgradeException

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

the class UpgradeEntitlementSubConfigsStep method addMissingResourceTypes.

/**
     * Adds any missing ResourceTypes.
     *
     * @throws UpgradeException If there was an error while adding a ResourceType
     */
private void addMissingResourceTypes() throws UpgradeException {
    for (final Node typeNode : missingResourceTypes) {
        final Map<String, Set<String>> keyValueMap = parseAttributeValuePairTags(typeNode);
        final String uuid = getNodeAttributeValue(typeNode, NAME);
        final String name = retrieveSingleValue(NAME, keyValueMap);
        final ResourceType resourceType = resourceTypeFromMap(uuid, keyValueMap);
        UpgradeProgress.reportStart(AUDIT_NEW_RESOURCE_TYPE_START, name);
        try {
            DEBUG.message("Saving standard resource type {} with UUID {}", name, uuid);
            resourceTypeConfiguration.storeResourceType(getAdminSubject(), ROOT_REALM, resourceType);
            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) Node(org.w3c.dom.Node) ResourceType(org.forgerock.openam.entitlement.ResourceType)

Example 50 with UpgradeException

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

the class UpgradeEntitlementSubConfigsStep method addChangedCombiners.

/**
     * Alter EntitlementCombiner references.
     *
     * @throws UpgradeException
     */
private void addChangedCombiners() throws UpgradeException {
    for (final Map.Entry<String, String> entry : changedCombiners.entrySet()) {
        final String name = entry.getKey();
        final String combiner = entry.getValue();
        try {
            UpgradeProgress.reportStart(AUDIT_MODIFIED_COM_START, name);
            if (DEBUG.messageEnabled()) {
                DEBUG.message("Modifying application " + name + " ; setting combiner: " + combiner);
            }
            final Application application = getApplication(name);
            application.setEntitlementCombinerName(EntitlementUtils.getEntitlementCombiner(combiner));
            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) HashMap(java.util.HashMap) Map(java.util.Map) EntitlementUtils.resourceTypeFromMap(org.forgerock.openam.entitlement.utils.EntitlementUtils.resourceTypeFromMap) 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