Class SaslId

java.lang.Object
com.isode.dsapi.util.SaslId

public class SaslId extends Object
Utility class to test and manage SASL ID.

A SASL Id consists of user name and domain, separated by an "@" character (similar to email address).

In some situations (Single Search mapping) it is allowed to specify SASL ID as a user name only but then default domain have to be specified (which is used instead of specific domain when needed). The default domain is used by the getShortID and getFullID methods.

Author:
mst
  • Constructor Details

    • SaslId

      public SaslId(String id, String defDomain) throws BadSaslIdException
      Constructs a SaslID.
      Parameters:
      id - a string of the form "username" or "username@domain". (not null).
      defDomain - default domain. Cannot be null if id doesn't contain a domain.
      Throws:
      BadSaslIdException - if id does not contain a string which can be parsed as a SaslID or if no domain is specified either in id of defDomain.
      Since:
      14.6
    • SaslId

      public SaslId(String id) throws BadSaslIdException
      Constructs a SaslID.
      Parameters:
      id - a string of the form "username@domain" (not null).
      Throws:
      BadSaslIdException - if id does not contain a string which can be parsed as a SaslID.
    • SaslId

      public SaslId(String userName, String domain, String defDomain) throws BadSaslIdException
      Constructs a SaslID.
      Parameters:
      userName - SASL username (null allowed)
      domain - SASL domain (null allowed)
      defDomain - default domain. Cannot be null if id doesn't contain a domain
      Throws:
      BadSaslIdException
      Since:
      14.6
  • Method Details

    • setID

      public final void setID(String id, String defDomain) throws BadSaslIdException
      Sets SASL ID.
      Parameters:
      id - a string of the form "username" or "username@domain" (not null)
      defDomain - default domain. Cannot be null if id doesn't contain a domain.
      Throws:
      BadSaslIdException - if id does not contain a string which can be parsed as a SaslID.
      Since:
      14.6
    • setUserName

      public final void setUserName(String userName) throws BadSaslIdException
      Sets the username component of a SaslId. Other components remain unchanged.
      Parameters:
      userName - the username (not null)
      Throws:
      BadSaslIdException
    • setDomain

      public final void setDomain(String domain, String defDomain) throws BadSaslIdException
      Sets the domain component and default domain of a SaslId. Other components remain unchanged.
      Parameters:
      domain - the domain. If null, then defDomain must be non-null
      defDomain - default domain. Must be not null if domain is null.
      Throws:
      BadSaslIdException
    • getID

      public String getID()
      Returns SASL ID as provided during construction.
      Returns:
      a string consisting of the username, followed, if the object contains a domain, by "@" and the domain.
    • getFullID

      public String getFullID()
      Returns full SASL ID.
      Returns:
      a non-null string consisting of the username and domain, separated by an "@" sign. If the object contains no domain, then the default domain will be used in the returned string.
      Since:
      14.6
    • getShortID

      public String getShortID()
      Returns short SASL ID (username). The returned string may or may not contain an "@" followed by a domain, depending on whether the object contains a domain which is different from the default domain.
      Returns:
      a String of the form "username" or "username@domain"
      Since:
      14.6
    • getUserName

      public String getUserName()
      Returns user name part of SASL ID.
      Returns:
      username string, which will never null.
    • getDomain

      public String getDomain()
      Returns domain part of SASL ID.
      Returns:
      domain string, which may be null if it was not specified.
    • getDefaultDomain

      public String getDefaultDomain()
      Returns default domain which should be used when SASL ID doesn't specify own domain.
      Returns:
      default domain, which may be null
      Since:
      14.6
    • getFullDomain

      public String getFullDomain()
      Returns full domain. If initial ID specified domain - this one is being returned - otherwise default domain is being returned.
      Returns:
      domain (not null)
      Since:
      15.0
    • toString

      public String toString()
      Overrides:
      toString in class Object