Package org.forgerock.opendj.rest2ldap
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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RequestHandlerconfigureEndpoint(File endpointDirectory, Options options)Creates a new CRESTRequestHandlerrepresenting a single endpoint whose configuration is defined in the providedendpointDirectoryparameter.static RouterconfigureEndpoints(File endpointsDirectory, Options options)Creates a new CRESTRouterusing the provided endpoints configuration directory and Rest2Ldap options.static X509KeyManagerconfigureKeyManager(JsonValue configuration)Configures aX509KeyManagerusing the provided JSON configuration.static LdapClientconfigureLdapClient(JsonValue configuration, String name, TrustManager trustManager, X509KeyManager keyManager)Creates a new LDAP client using the named configuration in the provided JSON list of client configurations.static OptionsconfigureOptions(JsonValue config)Parses Rest2Ldap configuration options.static List<Resource>configureResources(JsonValue config, Options options)Parses a list of Rest2Ldap resource definitions.static TrustManagerconfigureTrustManager(JsonValue configuration)Configures aTrustManagerusing the provided JSON configuration.
-
-
-
Method Detail
-
configureOptions
public static Options configureOptions(JsonValue config)
Parses Rest2Ldap configuration options. The JSON configuration must have the following format:{ "readOnUpdatePolicy": "controls", "useSubtreeDelete": true, "usePermissiveModify": true, "useMvcc": true, "mvccAttribute": "etag", "useServerSideSortForJson": true, "localSortMaxEntries": 1000 }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(JsonValue config, Options options)
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.options- The Rest2Ldap configuration options.- Returns:
- The parsed list of Rest2Ldap resource definitions.
- Throws:
IllegalArgumentException- If the configuration is invalid.
-
configureEndpoints
public static Router configureEndpoints(File endpointsDirectory, Options options) throws IOException
Creates a new CRESTRouterusing 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
Routerconfigured using the provided options and endpoints. - Throws:
IOException- If the endpoints configuration cannot be read.IllegalArgumentException- If the configuration is invalid.
-
configureEndpoint
public static RequestHandler configureEndpoint(File endpointDirectory, Options options) throws IOException
Creates a new CRESTRequestHandlerrepresenting a single endpoint whose configuration is defined in the providedendpointDirectoryparameter. 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
RequestHandlerconfigured 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(JsonValue configuration)
Configures aX509KeyManagerusing the provided JSON configuration.- Parameters:
configuration- The JSON object containing the key manager configuration.- Returns:
- The configured key manager.
-
configureTrustManager
public static TrustManager configureTrustManager(JsonValue configuration)
Configures aTrustManagerusing the provided JSON configuration.- Parameters:
configuration- The JSON object containing the trust manager configuration.- Returns:
- The configured trust manager.
-
configureLdapClient
public static LdapClient configureLdapClient(JsonValue configuration, String name, TrustManager trustManager, X509KeyManager keyManager)
Creates a new LDAP client using the named configuration in the provided JSON list of client configurations. See the sample configuration file for a detailed description of its content.- Parameters:
configuration- The JSON configuration.name- The name of the LDAP client configuration to be parsed.trustManager- The trust manager to use for secure connection, which may benullto use the default JVM trust manager.keyManager- The key manager to use for secure connection, which may benullindicating that no certificates will be used.- Returns:
- A new ldap client using the provided JSON configuration.
- Throws:
LocalizedIllegalArgumentException- If the configuration is invalid.
-
-