Package com.nimbusds.common.id
Class AuthzId
- java.lang.Object
-
- com.nimbusds.common.id.BaseIdentifier
-
- com.nimbusds.common.id.AuthzId
-
- All Implemented Interfaces:
Identifier
,Comparable<Identifier>
,net.minidev.json.JSONAware
public final class AuthzId extends BaseIdentifier
Represents a SASL authorisation identity, as specified in RFC 4513, section 5.2.1.8. This can be a distinguished name (DN) or a username.Note that for the purpose of keying and comparing authorisation identities, the DNs are normalised and the usernames are converted to lower case.
DN form:
"dn: uid=alice,ou=people,dc=wonderland,dc=net"
Username form:
"u: alice"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AuthzId.IdentityType
The identity data types.
-
Field Summary
Fields Modifier and Type Field Description static AuthzId
ANONYMOUS
Anonymous user identity.-
Fields inherited from class com.nimbusds.common.id.BaseIdentifier
DEFAULT_BYTE_LENGTH, SECURE_RANDOM
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
OverridesObject.equals()
.com.unboundid.ldap.sdk.DN
getDN()
Gets the identity DN.AuthzId.IdentityType
getIdentityType()
Gets the identity type.Username
getUsername()
Gets the identity username.static AuthzId
parse(String value)
Parses a string representation of a SASL authorisation identity.-
Methods inherited from class com.nimbusds.common.id.BaseIdentifier
compareTo, hashCode, toJSONString, toString
-
-
-
-
Constructor Detail
-
AuthzId
public AuthzId(com.unboundid.ldap.sdk.DN dn)
Creates a new authorisation identity from the specified DN.Note that for the purpose of keying and comparing authorisation IDs, the DN will be normalised (simple normalisation, without consulting the schema).
- Parameters:
dn
- The DN, must not benull
. IfDN.NULL_DN
indicates an anonymous user.
-
AuthzId
public AuthzId(Username username)
Creates a new authorisation identity from the specified username.Note that for the purpose of keying and comparing authorisation IDs, the username will be converted to lower case.
- Parameters:
username
- The username, must not benull
. If empty indicates an anonymous user.
-
-
Method Detail
-
parse
public static AuthzId parse(String value) throws ParseException
Parses a string representation of a SASL authorisation identity.- Parameters:
value
- The string to parse, ifnull
or emptyANONYMOUS
is returned.- Returns:
- The parsed authorisation identity.
- Throws:
ParseException
- On a bad authzid syntax.
-
getIdentityType
public AuthzId.IdentityType getIdentityType()
Gets the identity type.- Returns:
- The identity type.
-
getDN
public com.unboundid.ldap.sdk.DN getDN()
Gets the identity DN.- Returns:
- The DN,
null
if specified as a username instead.
-
getUsername
public Username getUsername()
Gets the identity username.- Returns:
- The username,
null
if specified as a DN instead.
-
equals
public boolean equals(Object object)
Description copied from class:BaseIdentifier
OverridesObject.equals()
.- Specified by:
equals
in classBaseIdentifier
- Parameters:
object
- The object to compare to.- Returns:
true
if the objects have the same value, otherwisefalse
.
-
-