Class LdapUtil


  • public final class LdapUtil
    extends java.lang.Object
    LdapUtil provides helper methods for Ldap.
    Version:
    $Revision: 2217 $ $Date: 2012-01-23 20:56:35 +0100 (Mon, 23 Jan 2012) $
    Author:
    Middleware Services
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] base64Decode​(java.lang.String value)
      This will decode the supplied value as a base64 encoded string to a byte[].
      static java.lang.String base64Encode​(byte[] value)
      This will convert the supplied value to a base64 encoded string.
      static java.lang.String base64Encode​(java.lang.String value)
      This will convert the supplied value to a base64 encoded string.
      static boolean checkCredential​(java.lang.Object credential)
      This checks a credential to ensure it is the right type and it is not empty.
      static boolean isIPAddress​(java.lang.String s)
      Returns whether the supplied string represents an IP address.
      static byte[] readInputStream​(java.io.InputStream is)
      Reads the data in the supplied stream and returns it as a byte array.
      static byte[] readURL​(java.net.URL url)
      Reads the data at the supplied URL and returns it as a byte array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • checkCredential

        public static boolean checkCredential​(java.lang.Object credential)
        This checks a credential to ensure it is the right type and it is not empty. A credential can be of type String, char[], or byte[].
        Parameters:
        credential - Object to check
        Returns:
        boolean - whether the credential is valid
      • base64Encode

        public static java.lang.String base64Encode​(byte[] value)
        This will convert the supplied value to a base64 encoded string. Returns null if the bytes cannot be encoded.
        Parameters:
        value - byte[] to base64 encode
        Returns:
        String
      • base64Encode

        public static java.lang.String base64Encode​(java.lang.String value)
        This will convert the supplied value to a base64 encoded string. Returns null if the string cannot be encoded.
        Parameters:
        value - String to base64 encode
        Returns:
        String
      • base64Decode

        public static byte[] base64Decode​(java.lang.String value)
        This will decode the supplied value as a base64 encoded string to a byte[].
        Parameters:
        value - Object to base64 encode
        Returns:
        String
      • readURL

        public static byte[] readURL​(java.net.URL url)
                              throws java.io.IOException
        Reads the data at the supplied URL and returns it as a byte array.
        Parameters:
        url - URL to read
        Returns:
        byte[] read from URL
        Throws:
        java.io.IOException - if an error occurs reading data
      • readInputStream

        public static byte[] readInputStream​(java.io.InputStream is)
                                      throws java.io.IOException
        Reads the data in the supplied stream and returns it as a byte array.
        Parameters:
        is - InputStream to read
        Returns:
        byte[] read from the stream
        Throws:
        java.io.IOException - if an error occurs reading data
      • isIPAddress

        public static boolean isIPAddress​(java.lang.String s)
        Returns whether the supplied string represents an IP address. Matches both IPv4 and IPv6 addresses.
        Parameters:
        s - to match
        Returns:
        whether the supplied string represents an IP address