Search in sources :

Example 61 with ServiceConfig

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

the class AuthPropertiesModelImpl method setValues.

public void setValues(Map modifiedValues) throws AMConsoleException {
    String[] params = { currentRealm, CORE_AUTH_SERVICE };
    logEvent("ATTEMPT_MODIFY_AUTH_INSTANCE", params);
    try {
        ServiceConfig sc = getCoreAuthServiceConfig();
        sc.setAttributes(modifiedValues);
        logEvent("SUCCEED_MODIFY_AUTH_INSTANCE", params);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { currentRealm, CORE_AUTH_SERVICE, strError };
        logEvent("SMS_EXCEPTION_MODIFY_AUTH_INSTANCE", paramsEx);
        throw new AMConsoleException(strError);
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { currentRealm, CORE_AUTH_SERVICE, strError };
        logEvent("SSO_EXCEPTION_MODIFY_AUTH_INSTANCE", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException)

Example 62 with ServiceConfig

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

the class CoreAttributesModelImpl method getAttributeValues.

/**
     * Returns attributes values.
     *
     * @return attributes values.
     */
public Map getAttributeValues() {
    Map attrs = null;
    String[] param = { currentRealm };
    logEvent("ATTEMPT_GET_AUTH_PROFILE_IN_REALM", param);
    try {
        OrganizationConfigManager scm = new OrganizationConfigManager(getUserSSOToken(), currentRealm);
        ServiceConfig config = scm.getServiceConfig(AUTH_SERVICE_NAME);
        attrs = config.getAttributes();
        if ((attrs == null) || attrs.isEmpty()) {
            debug.warning("no attributes were returned for Core Auth ...");
        }
        logEvent("SUCCEED_GET_AUTH_PROFILE_IN_REALM", param);
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { currentRealm, strError };
        logEvent("SMS_CONFIGURATION_EXCEPTION_GET_AUTH_PROFILE_IN_REALM", paramsEx);
        debug.error("CoreAttributesModelImpl.getAttributeValues", e);
    }
    return (attrs == null) ? Collections.EMPTY_MAP : attrs;
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Map(java.util.Map)

Example 63 with ServiceConfig

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

the class EntitiesModelImpl method repoExists.

public boolean repoExists(String realmName) {
    try {
        ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, getUserSSOToken());
        ServiceConfig cfg = svcCfgMgr.getOrganizationConfig(realmName, null);
        if (cfg == null) {
            return false;
        }
        Set names = cfg.getSubConfigNames();
        if (names == null || names.isEmpty()) {
            return false;
        }
        return true;
    } catch (SMSException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, strError };
        logEvent("SMS_EXCEPTION_GET_ID_REPO_NAMES", paramsEx);
        return false;
    } catch (SSOException e) {
        String strError = getErrorString(e);
        String[] paramsEx = { realmName, strError };
        logEvent("SSO_EXCEPTION_GET_ID_REPO_NAMES", paramsEx);
        return false;
    }
}
Also used : 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) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 64 with ServiceConfig

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

the class AMServiceUtils method getOrgConfig.

/**
     * Get organization config for the service
     * 
     * @param token
     *            SSOToken
     * @param orgDN
     *            DN of the org or org unit
     * @param serviceName
     *            Service Name
     * @return ServiceConfig of the organization for the service
     */
public static ServiceConfig getOrgConfig(SSOToken token, String orgDN, String serviceName) throws SSOException, AMException {
    try {
        ServiceConfigManager scm = new ServiceConfigManager(serviceName, token);
        ServiceConfig sc = scm.getOrganizationConfig(orgDN, null);
        DN theOrgDN = DN.valueOf(orgDN);
        if (theOrgDN.equals(DN.valueOf(SMSEntry.getAMSdkBaseDN())) && sc != null) {
            Map avPair = sc.getAttributes();
            Set subConfigs = sc.getSubConfigNames();
            if (avPair.isEmpty() && (subConfigs == null || subConfigs.isEmpty())) {
                return null;
            }
        }
        return sc;
    } catch (ServiceNotFoundException ex) {
        Object[] args = { serviceName };
        String locale = AMCommonUtils.getUserLocale(token);
        throw new AMException(AMSDKBundle.getString("481", args, locale), "481", args);
    } catch (ServiceAlreadyExistsException ex) {
        Object[] args = { serviceName };
        String locale = AMCommonUtils.getUserLocale(token);
        throw new AMException(AMSDKBundle.getString("479", args, locale), "479", args);
    } catch (SMSException ex) {
        Object[] args = { serviceName };
        String locale = AMCommonUtils.getUserLocale(token);
        throw new AMException(AMSDKBundle.getString("482", args, locale), "482", args);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ServiceNotFoundException(com.sun.identity.sm.ServiceNotFoundException) DN(org.forgerock.opendj.ldap.DN) Map(java.util.Map) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) ServiceAlreadyExistsException(com.sun.identity.sm.ServiceAlreadyExistsException)

Example 65 with ServiceConfig

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

the class CoreTokenConfigService method initServiceConfig.

private synchronized void initServiceConfig() {
    try {
        SSOToken dsameUserToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
        ServiceConfigManager mgr = new ServiceConfigManager(CoreTokenConstants.CORE_TOKEN_CONFIG_SERVICE_NAME, dsameUserToken);
        ServiceConfig globalConf = mgr.getGlobalConfig(null);
        if (globalConf != null) {
            Map<String, Set<String>> map = globalConf.getAttributes();
            if (map != null) {
                Set<String> set = map.get(IMPL_CLASS_ATTR);
                if ((set != null) && !set.isEmpty()) {
                    implClassName = set.iterator().next();
                }
                set = map.get(SEARCHABLE_ATTR);
                Set<String> tmpSet = new HashSet<String>();
                if ((set != null) && !set.isEmpty()) {
                    Iterator<String> it = set.iterator();
                    while (it.hasNext()) {
                        tmpSet.add(it.next().toLowerCase());
                    }
                }
                searchableAttrs = tmpSet;
                set = map.get(CLEANUP_INTERVAL);
                if ((set != null) && !set.isEmpty()) {
                    String tmp = set.iterator().next();
                    try {
                        cleanupInt = Integer.parseInt(tmp) * 1000;
                    } catch (NumberFormatException ne) {
                        CoreTokenUtils.debug.error("CoreTokenConfigService" + ".init. invalid interval : " + tmp, ne);
                        cleanupInt = DEFAULT_CLEANUP_INTERVAL;
                    }
                }
                set = map.get(TYPES_WITHOUT_ETAG_ENFORCE);
                tmpSet = new HashSet<String>();
                if ((set != null) && !set.isEmpty()) {
                    Iterator<String> it = set.iterator();
                    while (it.hasNext()) {
                        tmpSet.add(it.next().toLowerCase());
                    }
                }
                noETagEnfTypes = tmpSet;
            }
        }
        if (CoreTokenUtils.debug.messageEnabled()) {
            CoreTokenUtils.debug.message("CoreTokenConfigServcie.init: " + "searchable Attrs=" + searchableAttrs + "; token store impl class=" + implClassName + "; cleanup interval=" + cleanupInt + "; token types without ETag enforcement=" + noETagEnfTypes);
        }
    } catch (SMSException ex) {
        CoreTokenUtils.debug.error("CoreTokenConfigService.init", ex);
    } catch (SSOException ex) {
        CoreTokenUtils.debug.error("CoreTokenConfigService.init", ex);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) HashSet(java.util.HashSet)

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