Search in sources :

Example 56 with UpgradeException

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

the class TwoStepVerificationSettingUpgrade 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 2FA privilege for users 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 57 with UpgradeException

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

the class MigrateAgentGroups method initialize.

@Override
public void initialize() throws UpgradeException {
    try {
        final ServiceConfigManager scm = new ServiceConfigManager(getAdminToken(), IdConstants.AGENT_SERVICE, "1.0");
        for (final String realm : getRealmNames()) {
            final ServiceConfig orgConfig = scm.getOrganizationConfig(realm, null);
            final Set<String> agentNames = orgConfig.getSubConfigNames();
            for (final String agentName : agentNames) {
                final ServiceConfig agentConfig = orgConfig.getSubConfig(agentName);
                final String agentGroupName = agentConfig.getLabeledUri();
                if (DEBUG.messageEnabled()) {
                    DEBUG.message("Agent: \"" + agentName + "\" Group: \"" + agentGroupName + "\"");
                }
                if (agentGroupName != null && !agentGroupName.isEmpty()) {
                    Set<String> agents = upgradableAgents.get(realm);
                    if (agents == null) {
                        agents = new HashSet<String>();
                        upgradableAgents.put(realm, agents);
                    }
                    agents.add(agentName);
                }
            }
        }
        if (DEBUG.messageEnabled()) {
            DEBUG.message("The following agents needs to be migrated: " + upgradableAgents);
        }
    } catch (final SMSException smse) {
        throw new UpgradeException("Unable to initialize agent group migration", smse);
    } catch (final SSOException ssoe) {
        throw new UpgradeException("Unable to initialize agent group migration", ssoe);
    }
}
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 58 with UpgradeException

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

the class MigrateAgentGroups method perform.

@Override
public void perform() throws UpgradeException {
    try {
        final ServiceConfigManager scm = new ServiceConfigManager(getAdminToken(), IdConstants.AGENT_SERVICE, "1.0");
        for (final Map.Entry<String, Set<String>> entry : upgradableAgents.entrySet()) {
            final String realm = entry.getKey();
            final Set<String> agents = entry.getValue();
            final ServiceConfig orgConfig = scm.getOrganizationConfig(realm, null);
            for (final String agentName : agents) {
                UpgradeProgress.reportStart("upgrade.agent.group.start", agentName);
                final ServiceConfig agentConfig = orgConfig.getSubConfig(agentName);
                final String agentGroupName = agentConfig.getLabeledUri();
                agentConfig.setAttributes(getAgentGroupAttribute(agentGroupName));
                agentConfig.deleteLabeledUri(agentGroupName);
                UpgradeProgress.reportEnd("upgrade.success");
            }
        }
    } catch (final SMSException smse) {
        UpgradeProgress.reportEnd("upgrade.failed");
        throw new UpgradeException("Unable to perform agent group migration", smse);
    } catch (final SSOException ssoe) {
        UpgradeProgress.reportEnd("upgrade.failed");
        throw new UpgradeException("Unable to perform agent group migration", ssoe);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) Set(java.util.Set) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 59 with UpgradeException

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

the class UpgradeOAuth2ProviderStep method initialize.

@Override
public void initialize() throws UpgradeException {
    final SSOToken token = getAdminToken();
    try {
        scm = new ServiceConfigManager(OAUTH2_PROVIDER, token);
        ssm = new ServiceSchemaManager(OAUTH2_PROVIDER, token);
        findUpgradableProviders();
    } catch (ServiceNotFoundException e) {
        //When upgrading from 10.0.x and before there is no OAuth2 service, so we expect this exception in this case
        DEBUG.message("OAuth2Provider service not found. Nothing to upgrade", e);
    } catch (Exception e) {
        DEBUG.error("An error occurred while trying to create Service Config and Schema Managers.", e);
        throw new UpgradeException("Unable to create Service Config and Schema Managers.", e);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SSOToken(com.iplanet.sso.SSOToken) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException)

Example 60 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)

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