Package org.forgerock.openam.cts.impl
Class LdapAdapter
- java.lang.Object
-
- org.forgerock.openam.cts.impl.LdapAdapter
-
- All Implemented Interfaces:
TokenStorageAdapter
public class LdapAdapter extends Object implements TokenStorageAdapter
Responsible adapting the LDAP SDK Connection and its associated domain values into Tokens. This class will manage the associated conversion tasks and present a common interface to calling classes. It also helps us work around a number of final classes in the SDK which were hindering unit testing.
-
-
Constructor Summary
Constructors Constructor Description LdapAdapter(LdapTokenAttributeConversion conversion, LdapQueryFilterVisitor queryConverter, LdapQueryFactory queryFactory, LdapConnectionFactoryProvider connectionFactoryProvider, Map<org.forgerock.util.Option<?>,LdapOptionFunction> optionFunctionMap)Create an instance of this adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tokencreate(Token token, org.forgerock.util.Options options)Create the Token in LDAP.PartialTokendelete(String tokenId, org.forgerock.util.Options options)Performs a delete against the Token ID provided.Collection<PartialToken>partialQuery(TokenFilter query)Performs a partial query using the provided filter.Collection<Token>query(TokenFilter query)Performs a full-token query using the provided filter.Tokenread(String tokenId, org.forgerock.util.Options options)Performs a read against the LDAP connection and converts the result into a Token.ContinuousQuerystartContinuousQuery(TokenFilter filter, ContinuousQueryListener listener)Performs a continuous query using the provided filter.Tokenupdate(Token previous, Token updated, org.forgerock.util.Options options)Update the Token based on whether there were any changes between the two.
-
-
-
Constructor Detail
-
LdapAdapter
@Inject public LdapAdapter(LdapTokenAttributeConversion conversion, LdapQueryFilterVisitor queryConverter, LdapQueryFactory queryFactory, LdapConnectionFactoryProvider connectionFactoryProvider, Map<org.forgerock.util.Option<?>,LdapOptionFunction> optionFunctionMap)
Create an instance of this adapter.- Parameters:
conversion- Non null, required for Token conversion.queryConverter- For converting between CTS and LDAP.queryFactory- Produces queries.connectionFactoryProvider- Produces connection factories for connections to the datastore.
-
-
Method Detail
-
create
public Token create(Token token, org.forgerock.util.Options options) throws DataLayerException
Create the Token in LDAP.- Specified by:
createin interfaceTokenStorageAdapter- Parameters:
token- Non null Token to create.options- Non null Options for the operations.- Returns:
- A copy of the created
Tokenwith the ETag set. - Throws:
DataLayerException- If the operation failed, this exception will capture the reason.
-
read
public Token read(String tokenId, org.forgerock.util.Options options) throws DataLayerException
Performs a read against the LDAP connection and converts the result into a Token.- Specified by:
readin interfaceTokenStorageAdapter- Parameters:
tokenId- The id of the Token to read.options- Non null Options for the operations.- Returns:
- Token if found, otherwise null.
- Throws:
DataLayerException- If the operation failed, this exception will capture the reason.
-
update
public Token update(Token previous, Token updated, org.forgerock.util.Options options) throws DataLayerException
Update the Token based on whether there were any changes between the two. It is up to the underlying ldap later to update the etag so the etag so the etag is removed from the previous and updated token before the diff is computed.If the previous
Tokencontains a non-nullCoreTokenField.ETAGattribute value then the update will be performed with an optimistic concurrency check. If it does not contain the attribute or it contains anullvalue the update will be performed without any concurrency checks.- Specified by:
updatein interfaceTokenStorageAdapter- Parameters:
previous- The non null previous Token to check against.options- The non null Options for the operation.updated- The non null Token to update with.- Returns:
- A copy of the updated token. The token would contain the updated etag.
- Throws:
OptimisticConcurrencyCheckFailedException- If the operation failed due to an assertion on the tokens ETag. Only possible if theCoreTokenField.ETAGattribute is present on the previous token.DataLayerException- If the operation failed for a known reason.
-
delete
public PartialToken delete(String tokenId, org.forgerock.util.Options options) throws DataLayerException
Performs a delete against the Token ID provided.If the etag parameter is a non-
nullvalue then the delete will be performed with an optimistic concurrency check. If it isnullthen the delete will be performed without any concurrency checks.- Specified by:
deletein interfaceTokenStorageAdapter- Parameters:
tokenId- The non null Token ID to delete.options- The non null Options for the operation.- Returns:
- A
PartialTokencontaining at least theCoreTokenField.TOKEN_ID. - Throws:
DataLayerException- If the operation failed, this exception will capture the reason.OptimisticConcurrencyCheckFailedException- If the operation failed due to an assertion on the tokens ETag.
-
query
public Collection<Token> query(TokenFilter query) throws DataLayerException
Description copied from interface:TokenStorageAdapterPerforms a full-token query using the provided filter.- Specified by:
queryin interfaceTokenStorageAdapter- Parameters:
query- The non null filter specification.- Throws:
DataLayerException- If the operation failed, this exception will capture the reason.
-
partialQuery
public Collection<PartialToken> partialQuery(TokenFilter query) throws DataLayerException
Description copied from interface:TokenStorageAdapterPerforms a partial query using the provided filter.- Specified by:
partialQueryin interfaceTokenStorageAdapter- Parameters:
query- The non null filter specification.- Throws:
DataLayerException- If the operation failed, this exception will capture the reason.
-
startContinuousQuery
public ContinuousQuery startContinuousQuery(TokenFilter filter, ContinuousQueryListener listener) throws DataLayerException
Description copied from interface:TokenStorageAdapterPerforms a continuous query using the provided filter.- Specified by:
startContinuousQueryin interfaceTokenStorageAdapter- Parameters:
filter- The non null filter specification.- Throws:
DataLayerException- If the operation failed, this exception will capture the reason.
-
-