Search in sources :

Example 51 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class DelegationConfigUpgradeStep method perform.

@Override
public void perform() throws UpgradeException {
    try {
        initConfig();
        if (!newPermissions.isEmpty()) {
            UpgradeProgress.reportStart(AUDIT_PERM_NEW_START);
            handleNewPermissions();
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
        }
        if (!newPrivileges.isEmpty()) {
            UpgradeProgress.reportStart(AUDIT_PRIV_NEW_START);
            handleNewPrivileges();
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
        }
        if (!privilegeUpdates.isEmpty()) {
            UpgradeProgress.reportStart(AUDIT_PRIV_UPDATE_START);
            handlePrivilegeUpdates();
            UpgradeProgress.reportEnd(AUDIT_UPGRADE_SUCCESS);
        }
    } catch (SSOException ssoE) {
        UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
        throw new UpgradeException("Failed performing the upgrade of delegation", ssoE);
    } catch (SMSException smsE) {
        UpgradeProgress.reportEnd(AUDIT_UPGRADE_FAIL);
        throw new UpgradeException("Failed performing the upgrade of delegation", smsE);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Example 52 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class MigrateValidGotoSetting method initialize.

@Override
public void initialize() throws UpgradeException {
    try {
        final PolicyManager pm = new PolicyManager(getAdminToken(), HIDDEN_REALM);
        if (pm.getPolicyNames(DELEGATION_POLICY_NAME).isEmpty()) {
            if (DEBUG.messageEnabled()) {
                DEBUG.message("Unable to find the delegation policy in the hidden realm, looking for existing goto" + " domain values.");
            }
            //The delegation policy is not defined yet in the configuration, we need to migrate the goto domains.
            final ServiceConfigManager scm = new ServiceConfigManager(ISAuthConstants.AUTH_SERVICE_NAME, getAdminToken());
            for (final String realm : getRealmNames()) {
                if (DEBUG.messageEnabled()) {
                    DEBUG.message("Looking for valid goto URLs in realm " + realm);
                }
                final ServiceConfig organizationConfig = scm.getOrganizationConfig(realm, null);
                final Map<String, Set<String>> attrs = organizationConfig.getAttributesWithoutDefaults();
                final Set<String> validDomains = attrs.get(LEGACY_GOTO_DOMAINS_SETTING);
                if (validDomains != null && !validDomains.isEmpty()) {
                    changes.put(realm, validDomains);
                }
            }
            if (DEBUG.messageEnabled()) {
                DEBUG.message("Found the following existing goto URL domains in realms: " + changes);
            }
        } else {
            delegationPolicyFound = true;
        }
    } catch (final NameNotFoundException nnfe) {
        throw new UpgradeException("Unable to find hidden realm", nnfe);
    } catch (final PolicyException pe) {
        throw new UpgradeException("Unexpected error occurred while retrieving policies from the hidden realm", pe);
    } catch (final SMSException smse) {
        throw new UpgradeException("An error occurred while checking for old valid goto domains", smse);
    } catch (final SSOException ssoe) {
        throw new UpgradeException("An error occurred while checking for old valid goto domains", ssoe);
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) NameNotFoundException(com.sun.identity.policy.NameNotFoundException) PolicyException(com.sun.identity.policy.PolicyException) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 53 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class MigrateValidGotoSetting method perform.

@Override
public void perform() throws UpgradeException {
    try {
        if (!changes.isEmpty()) {
            final ServiceConfigManager validationService = new ServiceConfigManager(VALIDATION_SERVICE, getAdminToken());
            final ServiceConfigManager authService = new ServiceConfigManager(ISAuthConstants.AUTH_SERVICE_NAME, getAdminToken());
            for (final Map.Entry<String, Set<String>> entry : changes.entrySet()) {
                final String realm = entry.getKey();
                if (DEBUG.messageEnabled()) {
                    DEBUG.message("Starting to migrate goto domains for realm: " + realm);
                }
                UpgradeProgress.reportStart("upgrade.goto.migrate.start", realm);
                validationService.createOrganizationConfig(realm, getAttrMap(GOTO_RESOURCES, entry.getValue()));
                //The settings now are migrated, we should now clear up the legacy settings
                if (DEBUG.messageEnabled()) {
                    DEBUG.message("Removing old goto domains from iPlanetAMAuthService");
                }
                final ServiceConfig organizationConfig = authService.getOrganizationConfig(realm, null);
                organizationConfig.setAttributes(getAttrMap(LEGACY_GOTO_DOMAINS_SETTING, Collections.EMPTY_SET));
                UpgradeProgress.reportEnd("upgrade.success");
            }
        }
        if (DEBUG.messageEnabled()) {
            DEBUG.message("Attempting to create the delegation policy in the hidden realm");
        }
        UpgradeProgress.reportStart("upgrade.goto.policy.start");
        final PolicyManager pm = new PolicyManager(getAdminToken(), HIDDEN_REALM);
        String policy = AMSetupServlet.readFile(DELEGATION_POLICY_FILE);
        policy = ServicesDefaultValues.tagSwap(policy, true);
        //Adding the delegation privileges to allow agent accounts to read the new validationService.
        PolicyUtils.createPolicies(pm, new ByteArrayInputStream(policy.getBytes()));
        if (DEBUG.messageEnabled()) {
            DEBUG.message("Delegation policy successfully created under the hidden realm");
        }
        UpgradeProgress.reportEnd("upgrade.success");
    } catch (final IOException ioe) {
        UpgradeProgress.reportEnd("upgrade.failed");
        throw new UpgradeException("An IO error occurred while reading the delegation policy", ioe);
    } catch (final PolicyException pe) {
        UpgradeProgress.reportEnd("upgrade.failed");
        throw new UpgradeException("An unexpected error occurred while importing the delegation policy", pe);
    } catch (final SMSException smse) {
        UpgradeProgress.reportEnd("upgrade.failed");
        throw new UpgradeException("An error occurred while migrating the valid goto domain setting", smse);
    } catch (final SSOException ssoe) {
        UpgradeProgress.reportEnd("upgrade.failed");
        throw new UpgradeException("An error occurred while migrating the valid goto domain setting", ssoe);
    }
}
Also used : PolicyManager(com.sun.identity.policy.PolicyManager) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ServiceConfig(com.sun.identity.sm.ServiceConfig) ByteArrayInputStream(java.io.ByteArrayInputStream) PolicyException(com.sun.identity.policy.PolicyException) HashMap(java.util.HashMap) Map(java.util.Map) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 54 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class UpgradeLegacySTSStep method populateToBeRemovedAgents.

private void populateToBeRemovedAgents(String realm) throws UpgradeException {
    try {
        ServiceConfig baseService = getOrganizationConfigForAgentService(realm);
        Set<String> subConfigNames = baseService.getSubConfigNames();
        for (String agentName : subConfigNames) {
            final ServiceConfig agentInstance = baseService.getSubConfig(agentName);
            if (TO_BE_REMOVED_SUB_SCHEMA_NAMES.contains(agentInstance.getSchemaID())) {
                agentsRequiringRemoval.add(new ToBeRemovedAgentState(agentName, realm, agentInstance.getSchemaID()));
            }
        }
    } catch (SMSException | SSOException e) {
        throw new UpgradeException("Could not determine the legacy-sts-related agents to remove for realm " + realm + ". Exception: " + e.getMessage());
    }
}
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)

Example 55 with SMSException

use of com.sun.identity.sm.SMSException in project OpenAM by OpenRock.

the class UpgradeLegacySTSStep method determineDefaultLegacySTSSharedAgentRemoval.

private void determineDefaultLegacySTSSharedAgentRemoval() throws UpgradeException {
    try {
        ServiceConfig baseService = getOrganizationConfigForAgentService(ROOT_REALM);
        Set<String> subConfigNames = baseService.getSubConfigNames();
        if (subConfigNames.contains(LEGACY_STS_RELATED_SHARED_AGENT_NAME)) {
            final ServiceConfig agentInstance = baseService.getSubConfig(LEGACY_STS_RELATED_SHARED_AGENT_NAME);
            if (SHARED_AGENT_SCHEMA_ID.equals(agentInstance.getSchemaID())) {
                Map<String, Set<String>> attributes = agentInstance.getAttributesWithoutDefaultsForRead();
                if (attributes != null) {
                    Set<String> sharedSet = attributes.get(AGENTS_ALLOWED_TO_READ_ATTRIBUTE);
                    if ((sharedSet != null) && Sets.symmetricDifference(sharedSet, DEFAULT_STS_SHARED_AGENT_SHARE_SET).isEmpty()) {
                        removeDefaultLegacySTSSharedAgent = true;
                        agentsRequiringRemoval.add(new ToBeRemovedAgentState(LEGACY_STS_RELATED_SHARED_AGENT_NAME, ROOT_REALM, SHARED_AGENT_SCHEMA_ID));
                    }
                }
            }
        }
    } catch (SMSException | SSOException e) {
        throw new UpgradeException("Could not determine whether to remove the legacy-sts SharedAgent called " + LEGACY_STS_RELATED_SHARED_AGENT_NAME + " in the root realm. Exception: " + e.getMessage());
    }
}
Also used : UpgradeException(org.forgerock.openam.upgrade.UpgradeException) HashSet(java.util.HashSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Aggregations

SMSException (com.sun.identity.sm.SMSException)704 SSOException (com.iplanet.sso.SSOException)525 Set (java.util.Set)272 HashSet (java.util.HashSet)200 SSOToken (com.iplanet.sso.SSOToken)185 Map (java.util.Map)166 ServiceConfig (com.sun.identity.sm.ServiceConfig)164 HashMap (java.util.HashMap)158 CLIException (com.sun.identity.cli.CLIException)149 ServiceSchema (com.sun.identity.sm.ServiceSchema)138 Iterator (java.util.Iterator)133 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)104 IOutput (com.sun.identity.cli.IOutput)96 IdRepoException (com.sun.identity.idm.IdRepoException)86 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)84 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)83 AttributeSchema (com.sun.identity.sm.AttributeSchema)66 IOException (java.io.IOException)55 List (java.util.List)51