Search in sources :

Example 86 with OrganizationConfigManager

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

the class ApplicationCacheAfterRealmChangeTest method setup.

@BeforeClass
public void setup() throws Exception {
    if (!migrated) {
        return;
    }
    OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
    String subRealm = SUB_REALM.substring(1);
    ocm.createSubOrganization(subRealm, Collections.EMPTY_MAP);
    setOrgAlias(true);
}
Also used : OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) BeforeClass(org.testng.annotations.BeforeClass)

Example 87 with OrganizationConfigManager

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

the class AMLoginModule method getOrgProfile.

/**
     * Returns the organization attributes for specified organization.
     *
     * @param orgDN Requested organization DN.
     * @return Map that contains all attribute key/value pairs defined
     *         in the organization.
     * @throws AuthLoginException if cannot get organization profile.
     * @supported.api
     */
public Map getOrgProfile(String orgDN) throws AuthLoginException {
    Map orgMap = null;
    if (orgDN == null || orgDN.length() == 0) {
        // get login state for this authentication session
        orgDN = getLoginState("getOrgProfile(String)").getOrgDN();
    }
    try {
        OrganizationConfigManager orgConfigMgr = AuthD.getAuth().getOrgConfigManager(orgDN);
        orgMap = orgConfigMgr.getAttributes(ISAuthConstants.IDREPO_SVC_NAME);
        if (debug.messageEnabled()) {
            debug.message("orgMap is : " + orgMap);
        }
    } catch (Exception ex) {
        debug.message("getOrgProfile", ex);
        throw new AuthLoginException(ex);
    }
    return orgMap;
}
Also used : OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Map(java.util.Map) HashMap(java.util.HashMap) LoginException(javax.security.auth.login.LoginException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) SSOException(com.iplanet.sso.SSOException) IdRepoException(com.sun.identity.idm.IdRepoException) IOException(java.io.IOException) AMException(com.iplanet.am.sdk.AMException) AuthException(com.sun.identity.authentication.service.AuthException)

Example 88 with OrganizationConfigManager

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

the class AMLoginModule method getOrgServiceTemplate.

/**
     * Returns service template attributes defined for the specified
     * organization.
     *
     * @param orgDN Organization DN.
     * @param serviceName Requested service name.
     * @return Map that contains all attribute key/value pairs defined in the
     *         organization service template.
     * @throws AuthLoginException if cannot get organization service
     *         template.
     * @supported.api
     */
public Map getOrgServiceTemplate(String orgDN, String serviceName) throws AuthLoginException {
    Map orgMap = null;
    if (orgDN == null || orgDN.length() == 0) {
        // get login state for this authentication session
        orgDN = getLoginState("getOrgServiceTemplate(String, String)").getOrgDN();
    }
    try {
        OrganizationConfigManager orgConfigMgr = AuthD.getAuth().getOrgConfigManager(orgDN);
        orgMap = orgConfigMgr.getServiceConfig(serviceName).getAttributes();
    } catch (Exception ex) {
        debug.message("getOrgServiceTemplate", ex);
        throw new AuthLoginException(ex);
    }
    return orgMap;
}
Also used : OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Map(java.util.Map) HashMap(java.util.HashMap) LoginException(javax.security.auth.login.LoginException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) SSOException(com.iplanet.sso.SSOException) IdRepoException(com.sun.identity.idm.IdRepoException) IOException(java.io.IOException) AMException(com.iplanet.am.sdk.AMException) AuthException(com.sun.identity.authentication.service.AuthException)

Example 89 with OrganizationConfigManager

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

the class EntitlementService method getSubjectAttributesCollectorConfiguration.

/**
     * Returns subject attributes collector configuration.
     *
     * @param name subject attributes collector name
     * @return subject attributes collector configuration.
     * @throws EntitlementException if subject attributes collector
     * configuration cannot be returned.
     */
public Map<String, Set<String>> getSubjectAttributesCollectorConfiguration(String name) throws EntitlementException {
    try {
        SSOToken token = getSSOToken();
        if (token != null) {
            OrganizationConfigManager ocm = new OrganizationConfigManager(token, realm);
            ServiceConfig orgConfig = ocm.getServiceConfig(SERVICE_NAME);
            if (orgConfig != null) {
                Set<String> subConfigNames = orgConfig.getSubConfigNames();
                if ((subConfigNames == null) || (!subConfigNames.contains(CONFIG_SUBJECT_ATTRIBUTES_COLLECTORS))) {
                    orgConfig.addSubConfig(CONFIG_SUBJECT_ATTRIBUTES_COLLECTORS, SCHEMA_SUBJECT_ATTRIBUTES_COLLECTORS, 0, Collections.EMPTY_MAP);
                }
                ServiceConfig conf = orgConfig.getSubConfig(CONFIG_SUBJECT_ATTRIBUTES_COLLECTORS);
                ServiceConfig subConfig = conf.getSubConfig(name);
                if (subConfig == null) {
                    Map<String, Set<String>> attrs = Collections.EMPTY_MAP;
                    // copy from parent sub config
                    OrganizationConfigManager pocm = ocm.getParentOrgConfigManager();
                    if (pocm != null) {
                        ServiceConfig porgConfig = pocm.getServiceConfig(SERVICE_NAME);
                        if (porgConfig != null) {
                            ServiceConfig pconf = porgConfig.getSubConfig(CONFIG_SUBJECT_ATTRIBUTES_COLLECTORS);
                            if (pconf != null) {
                                ServiceConfig psubConfig = pconf.getSubConfig(name);
                                if (psubConfig != null) {
                                    attrs = psubConfig.getAttributes();
                                }
                            }
                        }
                    }
                    conf.addSubConfig(name, SCHEMA_OPENSSO_SUBJECT_ATTRIBUTES_COLLECTOR, 0, attrs);
                    subConfig = conf.getSubConfig(name);
                }
                return subConfig.getAttributes();
            }
        } else {
            PolicyConstants.DEBUG.error("EntitlementService.getSubjectAttributesCollectorConfiguration:" + "admin sso token is absent");
            Object[] arg = { name };
            throw new EntitlementException(287, arg);
        }
    } catch (SMSException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getSubjectAttributesCollectorConfiguration", ex);
        Object[] arg = { name };
        throw new EntitlementException(288, arg, ex);
    } catch (SSOException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.getSubjectAttributesCollectorConfiguration", ex);
        Object[] arg = { name };
        throw new EntitlementException(288, arg, ex);
    }
    return null;
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) SSOException(com.iplanet.sso.SSOException)

Example 90 with OrganizationConfigManager

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

the class EntitlementService method setSubjectAttributesCollectorConfiguration.

/**
     * Sets subject attributes collector configuration.
     *
     * @param name subject attributes collector name
     * @param attrMap subject attributes collector configuration map.
     * @throws EntitlementException if subject attributes collector
     * configuration cannot be set.
     */
public void setSubjectAttributesCollectorConfiguration(String name, Map<String, Set<String>> attrMap) throws EntitlementException {
    try {
        SSOToken token = getSSOToken();
        if (token != null) {
            OrganizationConfigManager ocm = new OrganizationConfigManager(token, realm);
            ServiceConfig orgConfig = ocm.getServiceConfig(SERVICE_NAME);
            if (orgConfig != null) {
                Set<String> subConfigNames = orgConfig.getSubConfigNames();
                if ((subConfigNames == null) || (!subConfigNames.contains(CONFIG_SUBJECT_ATTRIBUTES_COLLECTORS))) {
                    orgConfig.addSubConfig(CONFIG_SUBJECT_ATTRIBUTES_COLLECTORS, SCHEMA_SUBJECT_ATTRIBUTES_COLLECTORS, 0, Collections.EMPTY_MAP);
                }
                ServiceConfig conf = orgConfig.getSubConfig(CONFIG_SUBJECT_ATTRIBUTES_COLLECTORS);
                ServiceConfig subConfig = conf.getSubConfig(name);
                if (subConfig == null) {
                    conf.addSubConfig(name, SCHEMA_OPENSSO_SUBJECT_ATTRIBUTES_COLLECTOR, 0, attrMap);
                } else {
                    subConfig.setAttributes(attrMap);
                }
            }
        } else {
            PolicyConstants.DEBUG.error("EntitlementService.setSubjectAttributesCollectorConfiguration:" + "admin sso token is absent");
            Object[] arg = { name };
            throw new EntitlementException(289, arg);
        }
    } catch (SMSException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.setSubjectAttributesCollectorConfiguration", ex);
        Object[] arg = { name };
        throw new EntitlementException(290, arg, ex);
    } catch (SSOException ex) {
        PolicyConstants.DEBUG.error("EntitlementService.setSubjectAttributesCollectorConfiguration", ex);
        Object[] arg = { name };
        throw new EntitlementException(290, arg, ex);
    }
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) SSOException(com.iplanet.sso.SSOException)

Aggregations

OrganizationConfigManager (com.sun.identity.sm.OrganizationConfigManager)144 SMSException (com.sun.identity.sm.SMSException)87 Set (java.util.Set)79 HashSet (java.util.HashSet)54 SSOException (com.iplanet.sso.SSOException)50 Map (java.util.Map)48 HashMap (java.util.HashMap)40 SSOToken (com.iplanet.sso.SSOToken)33 IdRepoException (com.sun.identity.idm.IdRepoException)32 Iterator (java.util.Iterator)28 AMIdentity (com.sun.identity.idm.AMIdentity)23 CLIException (com.sun.identity.cli.CLIException)21 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)20 ServiceConfig (com.sun.identity.sm.ServiceConfig)17 IOutput (com.sun.identity.cli.IOutput)15 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)15 List (java.util.List)10 ForbiddenException (org.forgerock.json.resource.ForbiddenException)9 BadRequestException (org.forgerock.json.resource.BadRequestException)8 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)8