Add methods to convert from server DN class to
SDK DN class
Purpose is to ease migration to OpenDJ 3 server by minimizing
code that breaks.
| | |
| | | } |
| | | |
| | | /** |
| | | * Converts from OpenDJ server {@link org.opends.server.types.DN} to OpenDJ |
| | | * LDAP SDK {@link DN}. |
| | | * |
| | | * @param dn |
| | | * value to convert |
| | | * @return the converted value |
| | | */ |
| | | public static DN from(final org.opends.server.types.DN dn) { |
| | | try { |
| | | return DN.valueOf(dn.toString()); |
| | | } catch (Exception e) { |
| | | throw new IllegalStateException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Populates the result object with the operation details and return the |
| | | * result object if it was successful. Otherwise, it throws an |
| | | * {@link ErrorResultException}. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Converts a a LDAP server Distinguish Name to a SDK Distinguished Name. |
| | | * |
| | | * @throws DirectoryException |
| | | */ |
| | | @Test() |
| | | public final void testFromDN() throws DirectoryException { |
| | | final String dnString = "uid=scarter,ou=People,dc=example,dc=com"; |
| | | org.opends.server.types.DN srvDN = org.opends.server.types.DN.valueOf(dnString); |
| | | org.forgerock.opendj.ldap.DN sdkDN = from(srvDN); |
| | | |
| | | assertThat(sdkDN.toString()).isEqualTo(dnString); |
| | | } |
| | | |
| | | /** |
| | | * For an SASL bind request, credentials are composed by uid and password |
| | | * (in this config). |
| | | */ |