Search in sources :

Example 1 with ValueNotFoundException

use of com.sun.identity.shared.datastruct.ValueNotFoundException in project OpenAM by OpenRock.

the class ScriptConfigurationDataStore method oidcClaimsUsageCount.

/**
     * Count how many times the script identified by the specified uuid is used in OIDC claims.
     * @param uuid The specified uuid.
     * @return the count of how many times the script is used in OIDC Claims
     * @throws SMSException If the LDAP node could not be read.
     * @throws SSOException If the Admin token could not be found.
     */
private int oidcClaimsUsageCount(String uuid) throws SSOException, SMSException {
    SMSEntry smsEntry = new SMSEntry(getToken(), getOAuth2ProviderBaseDN());
    Map<String, Set<String>> attributes = smsEntry.getAttributes();
    try {
        Set<String> sunKeyValues = getMapSetThrows(attributes, "sunKeyValue");
        if (sunKeyValues.contains("forgerock-oauth2-provider-oidc-claims-extension-script=" + uuid)) {
            return 1;
        }
    } catch (ValueNotFoundException ignored) {
    }
    return 0;
}
Also used : ValueNotFoundException(com.sun.identity.shared.datastruct.ValueNotFoundException) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) SMSEntry(com.sun.identity.sm.SMSEntry)

Example 2 with ValueNotFoundException

use of com.sun.identity.shared.datastruct.ValueNotFoundException in project OpenAM by OpenRock.

the class ConfigLoader method loadConfig.

/**
     * Loads the configured global RADIUS Service values and declared clients as specified in openAM's admin console via
     * registration of those properties via the amRadiusServer.xml file. We load them here into simple pojos for caching
     * in memory. If we are unable to do so this method will return a null value.
     *
     * @return an object containing the configuration parameters for the radius service, or null if the config can't be
     *         loaded.
     */
public RadiusServiceConfig loadConfig() {
    try {
        // now get the fields in the Configuration tab, Global sub-tab, Global Properties table, RADIUS client
        // page
        RadiusServiceConfig cfg = null;
        final ServiceConfig serviceConf = serviceConfigManager.getGlobalConfig("default");
        if (serviceConf != null) {
            final Map<String, Set<String>> configAttributes = serviceConf.getAttributes();
            final boolean isEnabled = "YES".equals(CollectionHelper.getMapAttrThrows(configAttributes, RadiusServerConstants.GBL_ATT_LISTENER_ENABLED));
            final int listenerPort = CollectionHelper.getIntMapAttr(configAttributes, RadiusServerConstants.GBL_ATT_LISTENER_PORT, -1, LOG);
            final int coreThreads = CollectionHelper.getIntMapAttr(configAttributes, RadiusServerConstants.GBL_ATT_THREADS_CORE_SIZE, -1, LOG);
            final int maxThreads = CollectionHelper.getIntMapAttr(configAttributes, RadiusServerConstants.GBL_ATT_THREADS_MAX_SIZE, -1, LOG);
            final int queueSize = CollectionHelper.getIntMapAttr(configAttributes, RadiusServerConstants.GBL_ATT_QUEUE_SIZE, -1, LOG);
            final int keepaliveSeconds = CollectionHelper.getIntMapAttr(configAttributes, RadiusServerConstants.GBL_ATT_THREADS_KEEPALIVE_SECONDS, -1, LOG);
            final ThreadPoolConfig poolCfg = new ThreadPoolConfig(coreThreads, maxThreads, queueSize, keepaliveSeconds);
            // now get the RADIUS client instances from the secondary configuration instances table in the
            // Configuration tab, Global sub-tab, Global Properties table, RADIUS client page
            final Set<String> clientConfigNames = serviceConf.getSubConfigNames();
            final List<ClientConfig> definedClientConfigs = new ArrayList<ClientConfig>();
            for (final String clientConfigName : clientConfigNames) {
                try {
                    // create object for holding values in
                    final ClientConfig clientConfig = new ClientConfig();
                    // memory
                    clientConfig.setName(clientConfigName);
                    // go get our admin
                    final ServiceConfig clientCfg = serviceConf.getSubConfig(clientConfigName);
                    // console values
                    final Map<String, Set<String>> map = clientCfg.getAttributes();
                    clientConfig.setIpaddr(CollectionHelper.getMapAttrThrows(map, RadiusServerConstants.CLIENT_ATT_IP_ADDR));
                    clientConfig.setSecret(CollectionHelper.getMapAttrThrows(map, RadiusServerConstants.CLIENT_ATT_SECRET));
                    final Boolean setLogPackets = "YES".equals(CollectionHelper.getMapAttrThrows(map, RadiusServerConstants.CLIENT_ATT_LOG_PACKETS));
                    clientConfig.setLogPackets(setLogPackets);
                    clientConfig.setAccessRequestHandlerClassname(CollectionHelper.getMapAttrThrows(map, RadiusServerConstants.CLIENT_ATT_CLASSNAME));
                    final Class accessRequestHandlerClass = validateClass(clientConfig);
                    if (accessRequestHandlerClass == null) {
                        throw new ClientConfigurationException(clientConfigName, RadiusServerConstants.CLIENT_ATT_CLASSNAME);
                    } else {
                        clientConfig.setAccessRequestHandler(accessRequestHandlerClass);
                        clientConfig.setClassIsValid(true);
                    }
                    final Set<String> properties = map.get(RadiusServerConstants.CLIENT_ATT_PROPERTIES);
                    if (properties != null) {
                        clientConfig.setHandlerConfig(extractProperties(properties));
                    } else {
                        LOG.warning("No properties defined for handler.");
                    }
                    definedClientConfigs.add(clientConfig);
                } catch (final ValueNotFoundException vnfe) {
                    LOG.error(vnfe.getMessage() + " in RADIUS client config '" + clientConfigName + "'. Requests " + "from this client will be ignored.");
                } catch (final ClientConfigurationException e) {
                    LOG.error(e.getMessage());
                }
            }
            cfg = new RadiusServiceConfig(isEnabled, listenerPort, poolCfg, definedClientConfigs.toArray(new ClientConfig[0]));
        }
        return cfg;
    } catch (final Exception e) {
        LOG.error("Unable to load RADIUS Service Configuration", e);
    }
    return null;
}
Also used : Set(java.util.Set) ArrayList(java.util.ArrayList) ConfigurationException(com.google.inject.ConfigurationException) ValueNotFoundException(com.sun.identity.shared.datastruct.ValueNotFoundException) ProvisionException(com.google.inject.ProvisionException) ValueNotFoundException(com.sun.identity.shared.datastruct.ValueNotFoundException) ServiceConfig(com.sun.identity.sm.ServiceConfig)

Aggregations

ValueNotFoundException (com.sun.identity.shared.datastruct.ValueNotFoundException)2 Set (java.util.Set)2 ConfigurationException (com.google.inject.ConfigurationException)1 ProvisionException (com.google.inject.ProvisionException)1 SMSEntry (com.sun.identity.sm.SMSEntry)1 ServiceConfig (com.sun.identity.sm.ServiceConfig)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1