Package org.forgerock.opendj.rest2ldap
Class Rest2Ldap
java.lang.Object
org.forgerock.opendj.rest2ldap.Rest2Ldap
Provides methods for constructing Rest2Ldap protocol gateways. Applications construct a new Rest2Ldap
instance by calling
rest2Ldap(org.forgerock.util.Options, java.util.Collection<org.forgerock.opendj.rest2ldap.Resource>) passing in a list of resources which together define
the data model being exposed by the gateway. Call newRequestHandlerFor(String) in order to obtain
a request handler for a specific resource. The methods in this class can be categorized as follows:
Creating Rest2Ldap gateways:
rest2Ldap(org.forgerock.util.Options, java.util.Collection<org.forgerock.opendj.rest2ldap.Resource>)- creates a gateway for a given set of resourcesnewRequestHandlerFor(java.lang.String)- obtains a request handler for the specified endpoint resource.
resource(java.lang.String)- creates a resource having a fluent API for defining additional characteristics such as the resource's inheritance, sub-resources, and properties
collectionOf(java.lang.String)- creates a one-to-many relationship. Collections support creation, deletion, and querying of child resourcessingletonOf(java.lang.String)- creates a one-to-one relationship. Singletons cannot be created or destroyed, although they may be modified if they have properties which are modifiable. Singletons are usually only used as top-level entry points into REST APIs.
resourceType()- defines a property whose JSON value will be the name of the resource, e.g. "user"simple(org.forgerock.opendj.ldap.AttributeDescription)- defines a property which maps a JSON value to a single LDAP attributeobject()- defines a property which is a JSON object having zero or more nested propertiesreference(org.forgerock.opendj.ldap.AttributeDescription, java.lang.String, org.forgerock.opendj.ldap.AttributeDescription, org.forgerock.opendj.rest2ldap.PropertyMapper)- defines a property whose JSON value is a reference to another resource. Use these for mapping LDAP attributes which contain the DN of another LDAP entry exposed by Rest2Ldap. For example, a user's "manager" attribute or the members of a group.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.forgerock.util.Option<org.forgerock.opendj.ldap.DecodeOptions> Specifies the LDAP decoding options which should be used when decoding LDAP DNs, attribute types, and controls.static final org.forgerock.util.Option<String> Specifies the name of the LDAP attribute which should be used for multi-version concurrency control (MVCC) ifenabled.static final org.forgerock.util.Option<ReadOnUpdatePolicy> Specifies the policy which should be used in order to read an entry before it is deleted, or after it is added or modified.static final org.forgerock.util.Option<Boolean> Specifies whether Rest2Ldap should support multi-version concurrency control (MVCC) through the use of an MVCC LDAPattributesuch as "etag".static final org.forgerock.util.Option<Boolean> Specifies whether Rest2Ldap should perform LDAP modify operations using the LDAP permissive modify control.static final org.forgerock.util.Option<Boolean> Specifies whether Rest2Ldap should perform LDAP delete operations using the LDAP subtree delete control. -
Method Summary
Modifier and TypeMethodDescriptionstatic org.forgerock.json.resource.ResourceExceptionAdapts aThrowableto aResourceException.static SubResourceCollectioncollectionOf(String resourceId) Creates a newcollectionsub-resource definition whose members will be resources having the provided resource ID or its sub-types.static PropertyMapperReturns a property mapper which maps a single JSON attribute to a JSON constant.static JsonPropertyMapperReturns a property mapper which provides a mapping from a JSON value to a LDAP attribute having the JSON syntax.static JsonPropertyMapperjson(org.forgerock.opendj.ldap.AttributeDescription attribute) Returns a property mapper which provides a mapping from a JSON value to a LDAP attribute having the JSON syntax.org.forgerock.json.resource.RequestHandlernewRequestHandlerFor(String resourceId) Returns aRequestHandlerwhich will handle requests to the named resource and any of its sub-resources.static ObjectPropertyMapperobject()Returns a property mapper which maps JSON objects to LDAP attributes.static ReferencePropertyMapperreference(String attribute, String baseDnTemplate, String primaryKey, PropertyMapper mapper) Returns a property mapper which provides a mapping from a JSON value to a single DN valued LDAP attribute.static ReferencePropertyMapperreference(org.forgerock.opendj.ldap.AttributeDescription attribute, String baseDnTemplate, org.forgerock.opendj.ldap.AttributeDescription primaryKey, PropertyMapper mapper) Returns a property mapper which provides a mapping from a JSON value to a single DN valued LDAP attribute.static ResourceCreates a newresourcedefinition with the provided resource ID.static PropertyMapperReturns a property mapper which maps a JSON property containing the resource type to its associated LDAP object classes.static Rest2Ldaprest2Ldap(org.forgerock.util.Options options, Collection<Resource> resources) static Rest2Ldapstatic SimplePropertyMapperReturns a property mapper which provides a simple mapping from a JSON value to a single LDAP attribute.static SimplePropertyMappersimple(org.forgerock.opendj.ldap.AttributeDescription attribute) Returns a property mapper which provides a simple mapping from a JSON value to a single LDAP attribute.static SubResourceSingletonsingletonOf(String resourceId) Creates a newsingletonsub-resource definition which will reference a single resource having the specified resource ID.
-
Field Details
-
DECODE_OPTIONS
public static final org.forgerock.util.Option<org.forgerock.opendj.ldap.DecodeOptions> DECODE_OPTIONSSpecifies the LDAP decoding options which should be used when decoding LDAP DNs, attribute types, and controls. By default Rest2Ldap will use a set of options of will always use the default schema. -
USE_MVCC
Specifies whether Rest2Ldap should support multi-version concurrency control (MVCC) through the use of an MVCC LDAPattributesuch as "etag". By default Rest2Ldap will use MVCC. -
MVCC_ATTRIBUTE
Specifies the name of the LDAP attribute which should be used for multi-version concurrency control (MVCC) ifenabled. By default Rest2Ldap will use the "etag" operational attribute. -
READ_ON_UPDATE_POLICY
Specifies the policy which should be used in order to read an entry before it is deleted, or after it is added or modified. By default Rest2Ldap will use thecontrolsread on update policy. -
USE_PERMISSIVE_MODIFY
Specifies whether Rest2Ldap should perform LDAP modify operations using the LDAP permissive modify control. By default Rest2Ldap will use the permissive modify control and use of the control is strongly recommended. -
USE_SUBTREE_DELETE
Specifies whether Rest2Ldap should perform LDAP delete operations using the LDAP subtree delete control. By default Rest2Ldap will use the subtree delete control and use of the control is strongly recommended.
-
-
Method Details
-
rest2Ldap
public static Rest2Ldap rest2Ldap(org.forgerock.util.Options options, Collection<Resource> resources) Creates a newRest2Ldapinstance using the provided options andresources. Applications should callnewRequestHandlerFor(String)to obtain a request handler for a specific resource.The supported options are defined in this class.
- Parameters:
options- The configuration options for interactions with the backend LDAP server. The set of available options are provided in this class.resources- The list of resources.- Returns:
- A new Rest2Ldap instance from which REST request handlers can be obtained.
-
rest2Ldap
Creates a newRest2Ldapinstance using the provided options andresources. Applications should callnewRequestHandlerFor(String)to obtain a request handler for a specific resource.The supported options are defined in this class.
- Parameters:
options- The configuration options for interactions with the backend LDAP server. The set of available options are provided in this class.resources- The list of resources.- Returns:
- A new Rest2Ldap instance from which REST request handlers can be obtained.
-
resource
Creates a newresourcedefinition with the provided resource ID.- Parameters:
resourceId- The resource ID.- Returns:
- A new resource definition with the provided resource ID.
-
collectionOf
Creates a newcollectionsub-resource definition whose members will be resources having the provided resource ID or its sub-types.- Parameters:
resourceId- The type of resource contained in the sub-resource collection.- Returns:
- A new sub-resource definition with the provided resource ID.
-
singletonOf
Creates a newsingletonsub-resource definition which will reference a single resource having the specified resource ID.- Parameters:
resourceId- The type of resource referenced by the sub-resource singleton.- Returns:
- A new sub-resource definition with the provided resource ID.
-
resourceType
Returns a property mapper which maps a JSON property containing the resource type to its associated LDAP object classes.- Returns:
- The property mapper.
-
constant
Returns a property mapper which maps a single JSON attribute to a JSON constant.- Parameters:
value- The constant JSON value (a Boolean, Number, String, Map, or List).- Returns:
- The property mapper.
-
object
Returns a property mapper which maps JSON objects to LDAP attributes.- Returns:
- The property mapper.
-
reference
public static ReferencePropertyMapper reference(org.forgerock.opendj.ldap.AttributeDescription attribute, String baseDnTemplate, org.forgerock.opendj.ldap.AttributeDescription primaryKey, PropertyMapper mapper) Returns a property mapper which provides a mapping from a JSON value to a single DN valued LDAP attribute.- Parameters:
attribute- The DN valued LDAP attribute to be mapped.baseDnTemplate- The DN template which will be used as the search base when performing reverse lookups. The DN template may include template parameters and also parent RDNs using ".." notation. For example, the DN template "ou=groups,..,.." specifies that the search base DN should be computed by appending the RDN "ou=groups" to the grand-parent of the current resource's LDAP entry.primaryKey- The search primary key LDAP attribute to use for performing reverse lookups.mapper- An property mapper which will be used to map LDAP attributes in the referenced entry.- Returns:
- The property mapper.
-
reference
public static ReferencePropertyMapper reference(String attribute, String baseDnTemplate, String primaryKey, PropertyMapper mapper) Returns a property mapper which provides a mapping from a JSON value to a single DN valued LDAP attribute.- Parameters:
attribute- The DN valued LDAP attribute to be mapped.baseDnTemplate- The DN template which will be used as the search base when performing reverse lookups. The DN template may include template parameters and also parent RDNs using ".." notation. For example, the DN template "ou=groups,..,.." specifies that the search base DN should be computed by appending the RDN "ou=groups" to the grand-parent of the current resource's LDAP entry.primaryKey- The search primary key LDAP attribute to use for performing reverse lookups.mapper- An property mapper which will be used to map LDAP attributes in the referenced entry.- Returns:
- The property mapper.
-
simple
Returns a property mapper which provides a simple mapping from a JSON value to a single LDAP attribute.- Parameters:
attribute- The LDAP attribute to be mapped.- Returns:
- The property mapper.
-
simple
Returns a property mapper which provides a simple mapping from a JSON value to a single LDAP attribute.- Parameters:
attribute- The LDAP attribute to be mapped.- Returns:
- The property mapper.
-
json
Returns a property mapper which provides a mapping from a JSON value to a LDAP attribute having the JSON syntax.- Parameters:
attribute- The LDAP attribute to be mapped.- Returns:
- The property mapper.
-
json
Returns a property mapper which provides a mapping from a JSON value to a LDAP attribute having the JSON syntax.- Parameters:
attribute- The LDAP attribute to be mapped.- Returns:
- The property mapper.
-
asResourceException
Adapts aThrowableto aResourceException. If theThrowableis an LDAPLdapExceptionthen an appropriateResourceExceptionis returned, otherwise anInternalServerErrorExceptionis returned.- Parameters:
t- TheThrowableto be converted.- Returns:
- The equivalent resource exception.
-
newRequestHandlerFor
Returns aRequestHandlerwhich will handle requests to the named resource and any of its sub-resources.- Parameters:
resourceId- The resource ID.- Returns:
- A
RequestHandlerwhich will handle requests to the named resource.
-