Package org.forgerock.openam.cts.utils
Class LdapTokenAttributeConversion
- java.lang.Object
-
- org.forgerock.openam.cts.utils.LdapTokenAttributeConversion
-
public class LdapTokenAttributeConversion extends Object
Responsible for the conversion to and from LDAP Entry and Token. This class handles all the detail around this process and the appropriate class casting required. Note: This class manages the objectClass of an LDAP Entry as part of its operations.- See Also:
CoreTokenConstants.OBJECT_CLASS
-
-
Constructor Summary
Constructors Constructor Description LdapTokenAttributeConversion(LDAPDataConversion conversion, LdapDataLayerConfiguration dataLayerConfiguration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.forgerock.opendj.ldap.Entry
addObjectClass(org.forgerock.opendj.ldap.Entry entry)
Only adds the ObjectClass if it hasn't already been added.org.forgerock.opendj.ldap.DN
generateTokenDN(String tokenId)
org.forgerock.opendj.ldap.DN
generateTokenDN(Token token)
org.forgerock.opendj.ldap.Entry
getEntry(Token token)
Generate an Entry based on the given Token.Map<CoreTokenField,Object>
mapFromEntry(org.forgerock.opendj.ldap.Entry entry)
Convert an Entry into a more convenient Mapping of CoreTokenField to Object.static org.forgerock.opendj.ldap.Entry
stripObjectClass(org.forgerock.opendj.ldap.Entry entry)
Only strips out the ObjectClass if it is present.Token
tokenFromEntry(org.forgerock.opendj.ldap.Entry entry)
Convert an Entry into a Token.
-
-
-
Constructor Detail
-
LdapTokenAttributeConversion
@Inject public LdapTokenAttributeConversion(LDAPDataConversion conversion, LdapDataLayerConfiguration dataLayerConfiguration)
-
-
Method Detail
-
getEntry
public org.forgerock.opendj.ldap.Entry getEntry(Token token)
Generate an Entry based on the given Token.- Parameters:
token
- Non null Token to base the Entry on.- Returns:
- An Entry suitable for LDAP operations. Includes the Object Class.
-
mapFromEntry
public Map<CoreTokenField,Object> mapFromEntry(org.forgerock.opendj.ldap.Entry entry)
Convert an Entry into a more convenient Mapping of CoreTokenField to Object. This function is important because no every operation with LDAP needs to return a fully initialised Token. Instead users may be interested in only certain attributes of the Token, and choose to query just those as a performance enhancement.- Parameters:
entry
- Non null entry to convert.- Returns:
- A mapping of zero or more CoreTokenFields to Objects.
-
tokenFromEntry
public Token tokenFromEntry(org.forgerock.opendj.ldap.Entry entry)
Convert an Entry into a Token. The implication of function is that the Entry contains all the attributes of the Token. If any required attributes are missing, this operation will fail.- Parameters:
entry
- A non null Entry.- Returns:
- A non null Token initialised with the contents of the Entry.
- See Also:
mapFromEntry(org.forgerock.opendj.ldap.Entry)
-
addObjectClass
public static org.forgerock.opendj.ldap.Entry addObjectClass(org.forgerock.opendj.ldap.Entry entry)
Only adds the ObjectClass if it hasn't already been added.- Parameters:
entry
- Adds the ObjectClass attribute to this Entry.- Returns:
- The updated Entry.
-
stripObjectClass
public static org.forgerock.opendj.ldap.Entry stripObjectClass(org.forgerock.opendj.ldap.Entry entry)
Only strips out the ObjectClass if it is present.- Parameters:
entry
- Non null Entry to process.- Returns:
- The Entry reference passed in.
-
generateTokenDN
public org.forgerock.opendj.ldap.DN generateTokenDN(Token token)
- Parameters:
token
- Token which has a TokenId to base the DN on.- Returns:
- Non null DN.
-
generateTokenDN
public org.forgerock.opendj.ldap.DN generateTokenDN(String tokenId)
- Parameters:
tokenId
- Token Id to base the DN on.- Returns:
- Non null DN.
-
-