Converters.java revision 62da52c144e8d6ba69f611c45deeeb4f985ea24c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2013 ForgeRock AS.
*/
/**
* Common utility methods.
*/
public final class Converters {
// Prevent instantiation.
private Converters() {
throw new AssertionError();
}
/**
* Converts from OpenDJ LDAP SDK {@link org.forgerock.opendj.ldap.responses.SearchResultEntry} to OpenDJ
* server {@link org.opends.server.types.SearchResultEntry}.
*
* @param value
* value to convert
* @return the converted value
*/
}
return searchResultEntry;
}
return null;
}
/**
* Converts from OpenDJ LDAP SDK {@link DereferenceAliasesPolicy} to OpenDJ
* server {@link DereferencePolicy}.
*
* @param dereferenceAliasesPolicy
* value to convert
* @return the converted value
*/
}
/**
* Converts from OpenDJ LDAP SDK {@link DN} to OpenDJ server
* {@link org.opends.server.types.DN}.
*
* @param dn
* value to convert
* @return the converted value
*/
try {
} catch (Exception e) {
throw new IllegalStateException(e.getMessage());
}
}
/**
* Converts from OpenDJ LDAP SDK {@link RDN} to OpenDJ server
* {@link org.opends.server.types.RDN}.
*
* @param rdn
* value to convert
* @return the converted value
*/
try {
} catch (Exception e) {
throw new IllegalStateException(e.getMessage());
}
}
/**
* Converts from OpenDJ LDAP SDK {@link ByteString} to OpenDJ server
* {@link org.opends.server.types.ByteString}.
*
* @param value
* value to convert
* @return the converted value
*/
}
return null;
}
/**
* Converts from OpenDJ LDAP SDK {@link org.forgerock.opendj.ldap.SearchScope}
* to OpenDJ server {@link org.opends.server.types.SearchScope}.
*
* @param searchScope
* value to convert
* @return the converted value
*/
if (searchScope == null) {
return null;
}
}
/**
* Converts from OpenDJ LDAP SDK {@link org.forgerock.opendj.ldap.Filter} to
* OpenDJ server {@link org.opends.server.types.RawFilter}.
*
* @param filter
* value to convert
* @return the converted value
*/
try {
} catch (LDAPException e) {
throw new IllegalStateException(e);
}
return ldapFilter;
}
/**
* Converts from OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.responses.SearchResultReference} to OpenDJ
* server {@link org.opends.server.types.SearchResultReference}.
*
* @param searchResultReference
* value to convert
* @return the converted value
*/
}
/**
* Converts from OpenDJ LDAP SDK {@link String} to OpenDJ server
* {@link org.opends.server.types.ByteString}.
*
* @param value
* value to convert
* @return the converted value
*/
}
/**
* Converts from OpenDJ LDAP SDK {@link Control} to OpenDJ server
* {@link org.opends.server.protocols.ldap.LDAPControl}.
*
* @param control
* value to convert
* @return the converted value
*/
}
/**
* Converts from a <code>List</code> of OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.controls.Control} to a <code>List</code>
* of OpenDJ server {@link org.opends.server.types.Control}.
*
* @param listOfControl
* value to convert
* @return the converted value
*/
}
return toListOfControl;
}
/**
* Converts from OpenDJ LDAP SDK {@link org.forgerock.opendj.ldap.Attribute}
* to OpenDJ server {@link org.opends.server.types.RawAttribute}.
*
* @param attribute
* value to convert
* @return the converted value
*/
}
}
/**
* Converts from an <code>Iterable</code> of OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.Attribute} to a <code>List</code> of
* OpenDJ server {@link org.opends.server.types.RawAttribute}.
*
* @param listOfAttributes
* value to convert
* @return the converted value
*/
}
return toListOfAttributes;
}
/**
* Converts from OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.Modification} to OpenDJ server
* {@link org.opends.server.types.RawModification}.
*
* @param modification
* value to convert
* @return the converted value
*/
.getAttribute()));
}
/**
* Converts from a <code>List</code> of OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.Modification} to a <code>List</code> of
* OpenDJ server {@link org.opends.server.types.RawModification}.
*
* @param listOfModifications
* value to convert
* @return the converted value
*/
}
return toListOfModifications;
}
/**
* Converts from OpenDJ LDAP SDK {@link org.forgerock.opendj.ldap.Attribute}
* to OpenDJ server {@link org.opends.server.types.Attribute}.
*
* @param attribute
* value to convert
* @return the converted value
*/
final AttributeBuilder attrBuilder =
}
return attrBuilder.toAttribute();
}
/**
* Converts from an <code>Iterable</code> of OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.Attribute} to a <code>List</code> of
* OpenDJ server {@link org.opends.server.types.RawAttribute}.
*
* @param listOfAttributes
* value to convert
* @return the converted value
*/
}
return toListOfAttributes;
}
/**
* Converts from OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.Modification} to OpenDJ server
* {@link org.opends.server.types.Modification}.
*
* @param modification
* value to convert
* @return the converted value
*/
}
/**
* Converts from a <code>List</code> of OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.Modification} to a <code>List</code> of
* OpenDJ server {@link org.opends.server.types.Modification}.
*
* @param listOfModifications
* value to convert
* @return the converted value
*/
}
return toListOfModifications;
}
/**
* Converts from OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.ModificationType} to OpenDJ server
* {@link org.opends.server.types.ModificationType}.
*
* @param modificationType
* value to convert
* @return the converted value
*/
}
/**
* Converts from OpenDJ server {@link org.opends.server.types.ByteString} to
* OpenDJ LDAP SDK {@link ByteString}.
*
* @param value
* value to convert
* @return the converted value
*/
}
return null;
}
/**
* Converts from OpenDJ server {@link org.opends.server.types.SearchScope}. to
* OpenDJ LDAP SDK {@link org.forgerock.opendj.ldap.SearchScope}.
*
* @param searchScope
* value to convert
* @return the converted value
*/
if (searchScope == null) {
return null;
}
}
/**
* Converts from OpenDJ server
* {@link org.opends.server.protocols.ldap.LDAPControl} to OpenDJ LDAP SDK
* {@link Control}.
*
* @param ldapControl
* value to convert
* @return the converted value
*/
}
/**
* Converts from OpenDJ server {@link org.opends.server.types.Control} to
* OpenDJ LDAP SDK {@link Control}.
*
* @param control
* value to convert
* @return the converted value
*/
boolean isCritical = false;
// The server control doesn't have a method for extracting directly the value so, we need to ASN1 it.
try {
} catch (IOException e) {
// Nothing to do.
}
// Reads the ASN1 SDK byte string.
try {
if (sdkReaderASN1.hasNextElement()
}
if (sdkReaderASN1.hasNextElement()
}
} catch (DecodeException e) {
// Nothing to do.
} catch (IOException e) {
// Nothing to do.
}
// Creates the control
}
/**
* Converts from a <code>List</code> of OpenDJ server
* {@link org.opends.server.types.Control} to a <code>List</code> of OpenDJ
* LDAP SDK {@link org.forgerock.opendj.ldap.controls.Control}.
*
* @param listOfControl
* value to convert
* @return the converted value
*/
}
return fromListofControl;
}
/**
* Converts from OpenDJ server
* {@link org.opends.server.types.SearchResultReference} to OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.responses.SearchResultReference}.
*
* @param srvResultReference
* value to convert
* @return the converted value
*/
}
/**
* Converts from OpenDJ server {@link org.opends.server.types.Attribute} to
* OpenDJ LDAP SDK {@link org.forgerock.opendj.ldap.Attribute}.
*
* @param attribute
* value to convert
* @return the converted value
*/
}
return sdkAttribute;
}
/**
* Converts from an <code>Iterable</code> of OpenDJ server
* {@link org.opends.server.types.Attribute} to a <code>List</code> of OpenDJ
* LDAP SDK {@link org.forgerock.opendj.ldap.Attribute}.
*
* @param listOfAttributes
* value to convert
* @return the converted value
*/
}
return fromListofAttributes;
}
/**
* Converts from OpenDJ server
* {@link org.opends.server.types.SearchResultEntry} to OpenDJ LDAP SDK
* {@link org.forgerock.opendj.ldap.responses.SearchResultEntry}.
*
* @param srvResultEntry
* value to convert
* @return the converted value
*/
final SearchResultEntry searchResultEntry =
}
}
}
}
return searchResultEntry;
}
/**
* Populates the result object with the operation details and return the
* result object if it was successful. Otherwise, it throws an
* {@link ErrorResultException}.
*
* @param <T>
* the type of the result object
* @param operation
* used to populate the result
* @param result
* the result object to populate from the Operation
* @return the result if successful, an {@link ErrorResultException} is thrown
* otherwise
* @throws ErrorResultException
* when an error occurs
*/
throws ErrorResultException {
}
}
}
}
return result;
} else {
}
}
/**
* Converts the OpenDJ server {@link Operation} object into an OpenDJ LDAP SDK
* {@link Result} object.
*
* @param operation
* value to convert
* @return the converted value
* @throws ErrorResultException
* when an error occurs
*/
}
if (operation instanceof BindOperation) {
} else if (operation instanceof CompareOperation) {
} else if (operation instanceof ExtendedOperation) {
}
}
/**
* Returns the OpenDJ LDAP SDK {@link ResultCode} extracted out of the OpenDJ
* server {@link Operation}.
*
* @param operation
* value to convert
* @return the converted value
*/
}
/**
* Converts from <code>byte[]</code> to OpenDJ server
* {@link org.opends.server.types.ByteString}.
*
* @param authenticationValue
* value to convert
* @return the converted value
*/
try {
if (reader.hasNextElement()) {
}
} catch (ASN1Exception e) {
// Nothing to do.
}
return saslCred.toByteString();
}
}