Class Rest2LdapJsonConfigurator

java.lang.Object
org.forgerock.opendj.rest2ldap.Rest2LdapJsonConfigurator

public final class Rest2LdapJsonConfigurator extends Object
Provides core factory methods and builders for constructing Rest2Ldap endpoints from JSON configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.forgerock.opendj.ldap.ConnectionFactory
    configureConnectionFactory(org.forgerock.json.JsonValue configuration, String name, TrustManager trustManager, X509KeyManager keyManager)
    Creates a new connection factory using the named configuration in the provided JSON list of factory configurations.
    static org.forgerock.opendj.ldap.ConnectionFactory
    configureConnectionFactory(org.forgerock.json.JsonValue configuration, String name, TrustManager trustManager, X509KeyManager keyManager, ClassLoader providerClassLoader)
    Creates a new connection factory using the named configuration in the provided JSON list of factory configurations.
    static org.forgerock.json.resource.RequestHandler
    configureEndpoint(File endpointDirectory, org.forgerock.util.Options options)
    Creates a new CREST RequestHandler representing a single endpoint whose configuration is defined in the provided endpointDirectory parameter.
    static org.forgerock.json.resource.Router
    configureEndpoints(File endpointsDirectory, org.forgerock.util.Options options)
    Creates a new CREST Router using the provided endpoints configuration directory and Rest2Ldap options.
    configureKeyManager(org.forgerock.json.JsonValue configuration)
    Configures a X509KeyManager using the provided JSON configuration.
    static org.forgerock.util.Options
    configureOptions(org.forgerock.json.JsonValue config)
    Parses Rest2Ldap configuration options.
    static List<Resource>
    configureResources(org.forgerock.json.JsonValue config)
    Parses a list of Rest2Ldap resource definitions.
    configureTrustManager(org.forgerock.json.JsonValue configuration)
    Configures a TrustManager using the provided JSON configuration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • configureOptions

      public static org.forgerock.util.Options configureOptions(org.forgerock.json.JsonValue config)
      Parses Rest2Ldap configuration options. The JSON configuration must have the following format:

       {
            "readOnUpdatePolicy": "controls",
            "useSubtreeDelete": true,
            "usePermissiveModify": true,
            "useMvcc": true
            "mvccAttribute": "etag"
       }
       

      See the sample configuration file for a detailed description of its content.

      Parameters:
      config - The JSON configuration.
      Returns:
      The parsed Rest2Ldap configuration options.
      Throws:
      IllegalArgumentException - If the configuration is invalid.
    • configureResources

      public static List<Resource> configureResources(org.forgerock.json.JsonValue config)
      Parses a list of Rest2Ldap resource definitions. The JSON configuration must have the following format:

       "top": {
           "isAbstract": true,
           "properties": {
               "_rev": {
                   "type": "simple"
                   "ldapAttribute": "etag",
                   "writability": "readOnly"
               },
               ...
           },
           ...
       },
       ...
       

      See the sample configuration file for a detailed description of its content.

      Parameters:
      config - The JSON configuration.
      Returns:
      The parsed list of Rest2Ldap resource definitions.
      Throws:
      IllegalArgumentException - If the configuration is invalid.
    • configureEndpoints

      public static org.forgerock.json.resource.Router configureEndpoints(File endpointsDirectory, org.forgerock.util.Options options) throws IOException
      Creates a new CREST Router using the provided endpoints configuration directory and Rest2Ldap options. The Rest2Ldap configuration typically has the following structure on disk:
      • config.json - contains the configuration for the LDAP connection factories and authorization
      • rest2ldap/rest2ldap.json - defines Rest2Ldap configuration options
      • rest2ldap/endpoints/{api} - a directory containing the endpoint's resource definitions for endpoint {api}
      • rest2ldap/endpoints/{api}/{resource-id}.json - the resource definitions for a specific version of API {api}. The name of the file, {resource-id}, determines which resource type definition in the mapping file will be used as the root resource.
      Parameters:
      endpointsDirectory - The directory representing the Rest2Ldap "endpoints" directory.
      options - The Rest2Ldap configuration options.
      Returns:
      A new CREST Router configured using the provided options and endpoints.
      Throws:
      IOException - If the endpoints configuration cannot be read.
      IllegalArgumentException - If the configuration is invalid.
    • configureEndpoint

      public static org.forgerock.json.resource.RequestHandler configureEndpoint(File endpointDirectory, org.forgerock.util.Options options) throws IOException
      Creates a new CREST RequestHandler representing a single endpoint whose configuration is defined in the provided endpointDirectory parameter. The directory should contain a separate file for each supported version of the REST endpoint. The name of the file, excluding the suffix, identifies the resource definition which acts as the entry point into the endpoint.
      Parameters:
      endpointDirectory - The directory containing the endpoint's resource definitions, e.g. rest2ldap/routes/api would contain definitions for the "api" endpoint.
      options - The Rest2Ldap configuration options.
      Returns:
      A new CREST RequestHandler configured using the provided options and endpoint mappings.
      Throws:
      IOException - If the endpoint configuration cannot be read.
      IllegalArgumentException - If the configuration is invalid.
    • configureKeyManager

      public static X509KeyManager configureKeyManager(org.forgerock.json.JsonValue configuration)
      Configures a X509KeyManager using the provided JSON configuration.
      Parameters:
      configuration - The JSON object containing the key manager configuration.
      Returns:
      The configured key manager.
    • configureTrustManager

      public static TrustManager configureTrustManager(org.forgerock.json.JsonValue configuration)
      Configures a TrustManager using the provided JSON configuration.
      Parameters:
      configuration - The JSON object containing the trust manager configuration.
      Returns:
      The configured trust manager.
    • configureConnectionFactory

      public static org.forgerock.opendj.ldap.ConnectionFactory configureConnectionFactory(org.forgerock.json.JsonValue configuration, String name, TrustManager trustManager, X509KeyManager keyManager, ClassLoader providerClassLoader)
      Creates a new connection factory using the named configuration in the provided JSON list of factory configurations. See the sample configuration file for a detailed description of its content.
      Parameters:
      configuration - The JSON configuration.
      name - The name of the connection factory configuration to be parsed.
      trustManager - The trust manager to use for secure connection. Can be null to use the default JVM trust manager.
      keyManager - The key manager to use for secure connection. Can be null to use the default JVM key manager.
      providerClassLoader - The ClassLoader used to fetch the TransportProvider. This can be useful in OSGI environments.
      Returns:
      A new connection factory using the provided JSON configuration.
      Throws:
      IllegalArgumentException - If the configuration is invalid.
    • configureConnectionFactory

      public static org.forgerock.opendj.ldap.ConnectionFactory configureConnectionFactory(org.forgerock.json.JsonValue configuration, String name, TrustManager trustManager, X509KeyManager keyManager)
      Creates a new connection factory using the named configuration in the provided JSON list of factory configurations. See the sample configuration file for a detailed description of its content.
      Parameters:
      configuration - The JSON configuration.
      name - The name of the connection factory configuration to be parsed.
      trustManager - The trust manager to use for secure connection. Can be null to use the default JVM trust manager.
      keyManager - The key manager to use for secure connection. Can be null to use the default JVM key manager.
      Returns:
      A new connection factory using the provided JSON configuration.
      Throws:
      IllegalArgumentException - If the configuration is invalid.