Package com.isode.dsapi.util
Class SaslId
java.lang.Object
com.isode.dsapi.util.SaslId
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns default domain which should be used when SASL ID doesn't specify own domain.Returns domain part of SASL ID.Returns full domain.Returns full SASL ID.getID()
Returns SASL ID as provided during construction.Returns short SASL ID (username).Returns user name part of SASL ID.final void
Sets the domain component and default domain of a SaslId.final void
Sets SASL ID.final void
setUserName
(String userName) Sets the username component of a SaslId.toString()
-
Constructor Details
-
SaslId
Constructs a SaslID.- Parameters:
id
- a string of the form "username" or "username@domain". (notnull
).defDomain
- default domain. Cannot benull
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
Constructs a SaslID.- Parameters:
id
- a string of the form "username@domain" (notnull
).- Throws:
BadSaslIdException
- if id does not contain a string which can be parsed as a SaslID.
-
SaslId
Constructs a SaslID.- Parameters:
userName
- SASL username (null
allowed)domain
- SASL domain (null
allowed)defDomain
- default domain. Cannot benull
if id doesn't contain a domain- Throws:
BadSaslIdException
- Since:
- 14.6
-
-
Method Details
-
setID
Sets SASL ID.- Parameters:
id
- a string of the form "username" or "username@domain" (notnull
)defDomain
- default domain. Cannot benull
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
Sets the username component of a SaslId. Other components remain unchanged.- Parameters:
userName
- the username (notnull
)- Throws:
BadSaslIdException
-
setDomain
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-nulldefDomain
- default domain. Must be notnull
if domain is null.- Throws:
BadSaslIdException
-
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
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
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
Returns user name part of SASL ID.- Returns:
- username string, which will never null.
-
getDomain
Returns domain part of SASL ID.- Returns:
- domain string, which may be
null
if it was not specified.
-
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
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
-