Search in sources :

Example 1 with UpgradeException

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

the class AbstractUpgradeStep method getRealmNames.

/**
     * Returns the names of the realms available in the OpenAM configuration. The returned set is ordered, so the realm
     * hierarchy maintained (i.e. subrealm precedes sub-subrealm).
     *
     * @return The set of realmnames available in OpenAM.
     * @throws UpgradeException In case retrieving the realmnames was not successful.
     */
protected final Set<String> getRealmNames() throws UpgradeException {
    try {
        OrganizationConfigManager ocm = new OrganizationConfigManager(getAdminToken(), "/");
        Set<String> realms = CollectionUtils.asOrderedSet("/");
        realms.addAll(ocm.getSubOrganizationNames("*", true));
        if (DEBUG.messageEnabled()) {
            DEBUG.message("Discovered realms in the configuration: " + realms);
        }
        return realms;
    } catch (SMSException smse) {
        DEBUG.error("An error occurred while trying to retrieve the list of realms", smse);
        throw new UpgradeException("Unable to retrieve realms from SMS");
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager)

Example 2 with UpgradeException

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

the class AllowEvaluateForAgentsUpgradeStep method perform.

@Override
public void perform() throws UpgradeException {
    try {
        UpgradeProgress.reportStart(AUDIT_NEW_POLICY_START);
        // Creates a new policy entry to represent the new agent privilege.
        DEBUG.message("Creating new default privilege for agents called " + EVALUATE_POLICY);
        String policy = AMSetupServlet.readFile(DELEGATION_POLICY_FILE);
        policy = ServicesDefaultValues.tagSwap(policy, true);
        PolicyUtils.createPolicies(manager, new ByteArrayInputStream(policy.getBytes()));
        UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
    } catch (IOException ioE) {
        UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
        throw new UpgradeException("Failed during the creation of a new privilege for agents", ioE);
    } catch (SSOException ssoE) {
        UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
        throw new UpgradeException("Failed during the creation of a new privilege for agents", ssoE);
    } catch (PolicyException pE) {
        UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
        throw new UpgradeException("Failed during the creation of a new privilege for agents", pE);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ByteArrayInputStream(java.io.ByteArrayInputStream) PolicyException(com.sun.identity.policy.PolicyException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException)

Example 3 with UpgradeException

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

the class DelegationConfigUpgradeStep method initialize.

@Override
public void initialize() throws UpgradeException {
    // Extract out all sub configurations from the delegation XML doc.
    final Document delegationDocument = getDelegationDocument();
    final NodeList configNodes = delegationDocument.getElementsByTagName(SMSUtils.SUB_CONFIG);
    try {
        initConfig();
        // Check each permission/privilege config node against the service model.
        for (int idx = 0; idx < configNodes.getLength(); idx++) {
            final Node configNode = configNodes.item(idx);
            final String id = getNodeAttributeValue(configNode, ID);
            final String name = getNodeAttributeValue(configNode, NAME);
            if (PERMISSION.equals(id)) {
                checkPermission(name, configNode, permissionsConfig);
            } else if (PRIVILEGE.equals(id)) {
                checkPrivilege(name, configNode, privilegesConfig);
            }
        }
    } catch (SSOException ssoE) {
        throw new UpgradeException("Failed analysing the delegation delta", ssoE);
    } catch (SMSException smsE) {
        throw new UpgradeException("Failed analysing the delegation delta", smsE);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SMSException(com.sun.identity.sm.SMSException) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) SSOException(com.iplanet.sso.SSOException) Document(org.w3c.dom.Document)

Example 4 with UpgradeException

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

the class ScriptingSchemaStep method perform.

@Override
public void perform() throws UpgradeException {
    try {
        ServiceConfigManager configManager = new ServiceConfigManager(SCRIPTING_SERVICE_NAME, getAdminToken());
        ServiceConfig globalConfig = configManager.getGlobalConfig(null);
        upgradeEngineConfiguration(globalConfig);
        upgradeScriptConfiguration(globalConfig);
    } catch (SMSException | SSOException e) {
        UpgradeProgress.reportEnd("upgrade.failed");
        DEBUG.error("An error occurred while trying to upgrade the Scripting global settings", e);
        throw new UpgradeException("Unable to upgrade Scripting global settings", e);
    }
}
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) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 5 with UpgradeException

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

the class ScriptingSchemaStep method initialize.

@Override
public void initialize() throws UpgradeException {
    try {
        captureScriptedAuthModuleConfiguration();
        captureDeviceIdMatchConfiguration();
    } catch (ServiceNotFoundException e) {
        DEBUG.message("Scripted auth modules not found. Nothing to upgrade", e);
    } catch (SMSException | SSOException e) {
        DEBUG.error("An error occurred while trying to look for upgradable global Scripting settings", e);
        throw new UpgradeException("Unable to retrieve global Scripting settings", e);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SMSException(com.sun.identity.sm.SMSException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) SSOException(com.iplanet.sso.SSOException)

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