Search in sources :

Example 51 with ServiceConfig

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

the class EntitlementService method getApplications.

/**
     * Returns a set of registered applications.
     *
     * @return a set of registered applications.
     */
public Set<Application> getApplications() {
    final Set<Application> results = new HashSet<Application>();
    try {
        SSOToken token = getSSOToken();
        final ServiceConfig appConfig = getApplicationConfiguration(token, realm);
        if (appConfig != null) {
            final Set<String> names = appConfig.getSubConfigNames();
            for (String name : names) {
                results.add(createApplication(appConfig, name));
            }
        }
    } catch (EntitlementException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
    } catch (ClassCastException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
    } catch (InstantiationException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
    } catch (IllegalAccessException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
    } catch (SMSException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
    } catch (SSOException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getRawApplications", ex);
    }
    return results;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) EntitlementException(com.sun.identity.entitlement.EntitlementException) ServiceConfig(com.sun.identity.sm.ServiceConfig) Application(com.sun.identity.entitlement.Application) HashSet(java.util.HashSet)

Example 52 with ServiceConfig

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

the class EntitlementService method getApplication.

/**
     * {@inheritDoc}
     */
public Application getApplication(String name) {
    try {
        final ServiceConfig appConfig = getApplicationConfiguration(getSSOToken(), realm);
        final Set<String> names = appConfig.getSubConfigNames();
        if (appConfig != null && names.contains(name)) {
            return createApplication(appConfig, name);
        }
    } catch (EntitlementException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
    } catch (ClassCastException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
    } catch (InstantiationException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
    } catch (IllegalAccessException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
    } catch (SMSException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
    } catch (SSOException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getApplication", ex);
    }
    return null;
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException)

Example 53 with ServiceConfig

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

the class EntitlementService method createApplicationCollectionConfig.

private ServiceConfig createApplicationCollectionConfig(String realm) throws SMSException, SSOException {
    ServiceConfig sc = null;
    SSOToken token = SubjectUtils.getSSOToken(getAdminSubject());
    ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, token);
    ServiceConfig orgConfig = mgr.getOrganizationConfig(realm, null);
    if (orgConfig != null) {
        sc = orgConfig.getSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS);
    }
    if (sc == null) {
        orgConfig.addSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS, SCHEMA_APPLICATIONS, 0, Collections.EMPTY_MAP);
        sc = orgConfig.getSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS);
    }
    return sc;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 54 with ServiceConfig

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

the class PolicyManager method getPolicyNames.

/**
     * Gets a set of selected policy names matching the
     * pattern in the given organization. The pattern
     * accepts "*" as the wild card for searching policy names.
     * For example if the pattern is "co*", it returns policies
     * starting with "co". Similarly, if the pattern is "*net", it returns
     * policies ending with "net". The wildcard can be anywhere in the
     * the string. If there are no policies that match the provided filter,
     * this method returns an empty set (not null).
     *
     * @param pattern search pattern that will be used to select policy names
     *
     * @return <code>Set</code> of policy names that satisfy the pattern
     *
     * @throws SSOException invalid or expired single-sign-on token
     * @throws NoPermissionException user does not have sufficient
     *          privileges to get policy names
     * @throws PolicyException for any other abnormal condition
     *
     * @supported.api
     */
public Set getPolicyNames(String pattern) throws SSOException, NoPermissionException, PolicyException {
    try {
        ServiceConfig oConfig = scm.getOrganizationConfig(org, null);
        ServiceConfig namedPolicy = (oConfig == null) ? null : oConfig.getSubConfig(NAMED_POLICY);
        if (namedPolicy == null) {
            return (Collections.EMPTY_SET);
        } else {
            if (pattern.equals("*")) {
                return (namedPolicy.getSubConfigNames());
            } else {
                return (namedPolicy.getSubConfigNames(pattern));
            }
        }
    } catch (SMSException se) {
        debug.error("Unable to get named policies for organization: " + org);
        // Check for permission exception
        String[] objs = { org };
        if (se.getExceptionCode() == SMSException.STATUS_NO_PERMISSION) {
            throw (new NoPermissionException(ResBundleUtils.rbName, "insufficient_access_rights", null));
        } else {
            // Throw generic policy exception
            throw (new PolicyException(ResBundleUtils.rbName, "unable_to_get_policies_for_organization", objs, se));
        }
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException)

Example 55 with ServiceConfig

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

the class AMSetupServlet method updateEmbeddedIdRepo.

/**
      * Update Embedded Idrepo instance with new embedded opends isntance.
      */
private static void updateEmbeddedIdRepo(String orgName, String configName, String entry) throws SMSException, SSOException {
    SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
    ServiceConfigManager scm = new ServiceConfigManager(token, IdConstants.REPO_SERVICE, "1.0");
    ServiceConfig sc = scm.getOrganizationConfig(orgName, null);
    if (sc != null) {
        ServiceConfig subConfig = sc.getSubConfig(configName);
        if (subConfig != null) {
            Map<String, Object> configMap = subConfig.getAttributes();
            Set<String> vals = (Set<String>) configMap.get("sun-idrepo-ldapv3-config-ldap-server");
            vals.add(entry);
            HashMap<String, Set<String>> mp = new HashMap<String, Set<String>>(2);
            mp.put("sun-idrepo-ldapv3-config-ldap-server", vals);
            subConfig.setAttributes(mp);
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) CollectionUtils.asSet(org.forgerock.openam.utils.CollectionUtils.asSet) LicenseSet(org.forgerock.openam.license.LicenseSet) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) HashMap(java.util.HashMap) DirUserObject(com.sun.identity.common.configuration.ServerConfigXML.DirUserObject) ServerObject(com.sun.identity.common.configuration.ServerConfigXML.ServerObject) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Aggregations

ServiceConfig (com.sun.identity.sm.ServiceConfig)285 SMSException (com.sun.identity.sm.SMSException)180 Set (java.util.Set)144 SSOException (com.iplanet.sso.SSOException)143 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)124 HashSet (java.util.HashSet)119 Map (java.util.Map)101 HashMap (java.util.HashMap)96 SSOToken (com.iplanet.sso.SSOToken)52 Iterator (java.util.Iterator)41 IdRepoException (com.sun.identity.idm.IdRepoException)27 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)22 EntitlementException (com.sun.identity.entitlement.EntitlementException)19 LinkedHashSet (java.util.LinkedHashSet)18 OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)17 CLIException (com.sun.identity.cli.CLIException)16 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)16 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)13 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)13 ServiceSchema (com.sun.identity.sm.ServiceSchema)12