Class SASLUtils

java.lang.Object
com.unboundid.util.SASLUtils

This class provides a utility that may be used to help process SASL bind operations using the LDAP SDK.
  • Field Details

  • Method Details

    • getSupportedSASLMechanisms

      Retrieves information about the SASL mechanisms supported for use by this class.
      Returns:
      Information about the SASL mechanisms supported for use by this class.
    • getSASLMechanismInfo

      Retrieves information about the specified SASL mechanism.
      Parameters:
      mechanism - The name of the SASL mechanism for which to retrieve information. It will be treated in a case-insensitive manner.
      Returns:
      Information about the requested SASL mechanism, or null if no information about the specified mechanism is available.
    • createBindRequest

      @NotNull public static SASLBindRequest createBindRequest(@Nullable String bindDN, @Nullable String password, @Nullable String mechanism, @Nullable String... options) throws LDAPException
      Creates a new SASL bind request using the provided information.
      Parameters:
      bindDN - The bind DN to use for the SASL bind request. For most SASL mechanisms, this should be null, since the identity of the target user should be specified in some other way (e.g., via an "authID" SASL option).
      password - The password to use for the SASL bind request. It may be null if no password is required for the desired SASL mechanism.
      mechanism - The name of the SASL mechanism to use. It may be null if the provided set of options contains a "mech" option to specify the desired SASL option.
      options - The set of SASL options to use when creating the bind request, in the form "name=value". It may be null or empty if no SASL options are needed and a value was provided for the mechanism argument. If the set of SASL options includes a "mech" option, then the mechanism argument must be null or have a value that matches the value of the "mech" SASL option.
      Returns:
      The SASL bind request created using the provided information.
      Throws:
      LDAPException - If a problem is encountered while trying to create the SASL bind request.
    • createBindRequest

      @NotNull public static SASLBindRequest createBindRequest(@Nullable String bindDN, @Nullable String password, @Nullable String mechanism, @Nullable List<String> options, @Nullable Control... controls) throws LDAPException
      Creates a new SASL bind request using the provided information.
      Parameters:
      bindDN - The bind DN to use for the SASL bind request. For most SASL mechanisms, this should be null, since the identity of the target user should be specified in some other way (e.g., via an "authID" SASL option).
      password - The password to use for the SASL bind request. It may be null if no password is required for the desired SASL mechanism.
      mechanism - The name of the SASL mechanism to use. It may be null if the provided set of options contains a "mech" option to specify the desired SASL option.
      options - The set of SASL options to use when creating the bind request, in the form "name=value". It may be null or empty if no SASL options are needed and a value was provided for the mechanism argument. If the set of SASL options includes a "mech" option, then the mechanism argument must be null or have a value that matches the value of the "mech" SASL option.
      controls - The set of controls to include in the request.
      Returns:
      The SASL bind request created using the provided information.
      Throws:
      LDAPException - If a problem is encountered while trying to create the SASL bind request.
    • createBindRequest

      @NotNull public static SASLBindRequest createBindRequest(@Nullable String bindDN, @Nullable byte[] password, @Nullable String mechanism, @Nullable String... options) throws LDAPException
      Creates a new SASL bind request using the provided information.
      Parameters:
      bindDN - The bind DN to use for the SASL bind request. For most SASL mechanisms, this should be null, since the identity of the target user should be specified in some other way (e.g., via an "authID" SASL option).
      password - The password to use for the SASL bind request. It may be null if no password is required for the desired SASL mechanism.
      mechanism - The name of the SASL mechanism to use. It may be null if the provided set of options contains a "mech" option to specify the desired SASL option.
      options - The set of SASL options to use when creating the bind request, in the form "name=value". It may be null or empty if no SASL options are needed and a value was provided for the mechanism argument. If the set of SASL options includes a "mech" option, then the mechanism argument must be null or have a value that matches the value of the "mech" SASL option.
      Returns:
      The SASL bind request created using the provided information.
      Throws:
      LDAPException - If a problem is encountered while trying to create the SASL bind request.
    • createBindRequest

      @NotNull public static SASLBindRequest createBindRequest(@Nullable String bindDN, @Nullable byte[] password, @Nullable String mechanism, @Nullable List<String> options, @Nullable Control... controls) throws LDAPException
      Creates a new SASL bind request using the provided information.
      Parameters:
      bindDN - The bind DN to use for the SASL bind request. For most SASL mechanisms, this should be null, since the identity of the target user should be specified in some other way (e.g., via an "authID" SASL option).
      password - The password to use for the SASL bind request. It may be null if no password is required for the desired SASL mechanism.
      mechanism - The name of the SASL mechanism to use. It may be null if the provided set of options contains a "mech" option to specify the desired SASL option.
      options - The set of SASL options to use when creating the bind request, in the form "name=value". It may be null or empty if no SASL options are needed and a value was provided for the mechanism argument. If the set of SASL options includes a "mech" option, then the mechanism argument must be null or have a value that matches the value of the "mech" SASL option.
      controls - The set of controls to include in the request.
      Returns:
      The SASL bind request created using the provided information.
      Throws:
      LDAPException - If a problem is encountered while trying to create the SASL bind request.
    • createBindRequest

      @NotNull public static SASLBindRequest createBindRequest(@Nullable String bindDN, @Nullable byte[] password, boolean promptForPassword, @Nullable CommandLineTool tool, @Nullable String mechanism, @Nullable List<String> options, @Nullable Control... controls) throws LDAPException
      Creates a new SASL bind request using the provided information.
      Parameters:
      bindDN - The bind DN to use for the SASL bind request. For most SASL mechanisms, this should be null, since the identity of the target user should be specified in some other way (e.g., via an "authID" SASL option).
      password - The password to use for the SASL bind request. It may be null if no password is required for the desired SASL mechanism.
      promptForPassword - Indicates whether to interactively prompt for the password if one is needed but none was provided.
      tool - The command-line tool whose input and output streams should be used when prompting for the bind password. It may be null if promptForPassword is false.
      mechanism - The name of the SASL mechanism to use. It may be null if the provided set of options contains a "mech" option to specify the desired SASL option.
      options - The set of SASL options to use when creating the bind request, in the form "name=value". It may be null or empty if no SASL options are needed and a value was provided for the mechanism argument. If the set of SASL options includes a "mech" option, then the mechanism argument must be null or have a value that matches the value of the "mech" SASL option.
      controls - The set of controls to include in the request.
      Returns:
      The SASL bind request created using the provided information.
      Throws:
      LDAPException - If a problem is encountered while trying to create the SASL bind request.
    • ensureNoUnsupportedOptions

      Ensures that the provided map is empty, and will throw an exception if it isn't. This method is intended for internal use only.
      Parameters:
      options - The map of options to ensure is empty.
      mechanism - The associated SASL mechanism.
      Throws:
      LDAPException - If the map of SASL options is not empty.
    • getUsageString

      @NotNull public static String getUsageString(int maxWidth)
      Retrieves a string representation of the SASL usage information. This will include the supported SASL mechanisms and the properties that may be used with each.
      Parameters:
      maxWidth - The maximum line width to use for the output. If this is less than or equal to zero, then no wrapping will be performed.
      Returns:
      A string representation of the usage information.
    • getUsageString

      @NotNull public static String getUsageString(@Nullable String mechanism, int maxWidth)
      Retrieves a string representation of the SASL usage information. This will include the supported SASL mechanisms and the properties that may be used with each.
      Parameters:
      mechanism - The name of the SASL mechanism for which to obtain usage information It may be null if usage should be displayed for all available mechamisms.
      maxWidth - The maximum line width to use for the output. If this is less than or equal to zero, then no wrapping will be performed.
      Returns:
      A string representation of the usage information.
    • getUsage

      @NotNull public static List<String> getUsage(int maxWidth)
      Retrieves lines that make up the SASL usage information, optionally wrapping long lines.
      Parameters:
      maxWidth - The maximum line width to use for the output. If this is less than or equal to zero, then no wrapping will be performed.
      Returns:
      The lines that make up the SASL usage information.
    • getUsage

      @NotNull public static List<String> getUsage(@Nullable String mechanism, int maxWidth)
      Retrieves lines that make up the SASL usage information, optionally wrapping long lines.
      Parameters:
      mechanism - The name of the SASL mechanism for which to obtain usage information It may be null if usage should be displayed for all available mechamisms.
      maxWidth - The maximum line width to use for the output. If this is less than or equal to zero, then no wrapping will be performed.
      Returns:
      The lines that make up the SASL usage information.