org.keycloak.federation.ldap.idm.store.ldap

## Class LDAPUtil

- java.lang.Object
- - org.keycloak.federation.ldap.idm.store.ldap.LDAPUtil

-     public class LDAPUtil
      extends Object

  Utility class for working with LDAP.

  Author:
    Pedro Igor

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LDAPUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `convertObjectGUIToByteString(byte[] objectGUID)` Creates a byte-based `String` representation of a raw byte array representing the value of the `objectGUID` attribute retrieved from Active Directory.
    `static String` | `decodeObjectGUID(byte[] objectGUID)` Decode a raw byte array representing the value of the `objectGUID` attribute retrieved from Active Directory.
    `static String` | `formatDate(Date date)` Formats the given date.
    `static Date` | `parseDate(String date)` Parses dates/time stamps stored in LDAP.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LDAPUtil

          public LDAPUtil()

  - ### Method Detail

    - #### formatDate

          public static final String formatDate(Date date)

      Formats the given date.

      Parameters:
        `date` - The Date to format.
      Returns:
        A String representing the formatted date.

    - #### parseDate

          public static final Date parseDate(String date)

      Parses dates/time stamps stored in LDAP. Some possible values:

      - 20020228150820
      - 20030228150820Z
      - 20050228150820.12
      - 20060711011740.0Z
      Parameters:
        `date` - The date string to parse from.
      Returns:
        the Date.

    - #### convertObjectGUIToByteString

          public static String convertObjectGUIToByteString(byte[] objectGUID)

      Creates a byte-based `String` representation of a raw byte array representing the value of the `objectGUID` attribute retrieved from Active Directory.

      The returned string is useful to perform queries on AD based on the `objectGUID` value. Eg.:

      String filter = "(&(objectClass=*)(objectGUID" + EQUAL + convertObjectGUIToByteString(objectGUID) + "))";

      Parameters:
        `objectGUID` - A raw byte array representing the value of the `objectGUID` attribute retrieved from Active Directory.
      Returns:
        A byte-based String representation in the form of \[0]\[1]\[2]\[3]\[4]\[5]\[6]\[7]\[8]\[9]\[10]\[11]\[12]\[13]\[14]\[15]

    - #### decodeObjectGUID

          public static String decodeObjectGUID(byte[] objectGUID)

      Decode a raw byte array representing the value of the `objectGUID` attribute retrieved from Active Directory.

      The returned string is useful to directly bind an entry. Eg.:

      String bindingString = decodeObjectGUID(objectGUID);
      Attributes attributes = ctx.getAttributes(bindingString);

      Parameters:
        `objectGUID` - A raw byte array representing the value of the `objectGUID` attribute retrieved from Active Directory.
      Returns:
        A string representing the decoded value in the form of [3][2][1][0]-[5][4]-[7][6]-[8][9]-[10][11][12][13][14][15].

Copyright © 2016 JBoss by Red Hat. All rights reserved.