TokenAttributeConversion.java revision 1b5cb8422c825dbdc6d7669e74f285cede6ab71c
/**
* Copyright 2013-2015 ForgeRock AS.
*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*/
/**
* 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 CoreTokenConstants#OBJECT_CLASS
*
* @author robert.wapshott@forgerock.com
*/
public class TokenAttributeConversion {
/**
* Empty Strings cannot be stored in LDAP, so they are replaced by a keyword which
* will be handled accordingly.
*/
// Injected
private final LDAPConfig constants;
private final LDAPDataConversion conversion;
this.conversion = conversion;
}
/**
* Generate an Entry based on the given Token.
*
* @param token Non null Token to base the Entry on.
*
* @return An Entry suitable for LDAP operations. Includes the Object Class.
*/
// Token Type special case is an Enum
continue;
}
}
} else {
throw new IllegalStateException();
}
}
return 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.
*
* @param entry Non null entry to convert.
*
* @return A mapping of zero or more CoreTokenFields to Objects.
*/
// Special case for Token Type
continue;
}
value = "";
}
} else {
throw new IllegalStateException();
}
}
return r;
}
/**
* 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.
*
* @param entry A non null Entry.
*
* @return A non null Token initialised with the contents of the Entry.
*
* @see #mapFromEntry(org.forgerock.opendj.ldap.Entry)
*/
continue;
}
}
return token;
}
/**
* Only adds the ObjectClass if it hasn't already been added.
*
* @param entry Adds the ObjectClass attribute to this Entry.
*
* @return The updated Entry.
*/
}
return entry;
}
/**
* Only strips out the ObjectClass if it is present.
*
* @param entry Non null Entry to process.
*
* @return The Entry reference passed in.
*/
}
return entry;
}
/**
* @param token Token which has a TokenId to base the DN on.
* @return Non null DN.
*/
}
/**
* @param tokenId Token Id to base the DN on.
* @return Non null DN.
*/
}
}