public class SecurityPrincipal
extends java.lang.Object
implements java.security.Principal
Canonical Form | Example | Description |
---|---|---|
1 - Distinguished Name | CN=Alice Baker,CN=Users,DC=example,DC=com | An X.500 style Distinguished Name (DN) or Relative Distinguished Name (RDN) like CN=Alice Baker. |
2 - Username | alice | A simple username without a domain. |
3 - Backslash | EXAMPLE\alice | A Windows-style qualified account name with NetBIOS short domain name. A DNS domain name may also be used like "example.com\alice". |
4 - Principal | alice@example.com | A qualified account name with a DNS domain. |
Modifier and Type | Field and Description |
---|---|
protected int |
canonicalForm |
protected java.lang.String |
domain |
protected java.lang.String |
name |
Constructor and Description |
---|
SecurityPrincipal(java.lang.String acctname)
Create a new SecurityPrincipal with an account name like "alice@example.com", "EXAMPLE\alice" or "alice".
|
SecurityPrincipal(java.lang.String dname,
java.lang.String uname)
Create a new SecurityPrincipal from a domain and username.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Compare two principals for equality using a case insensitive comparison of the username and domain.
|
int |
getCanonicalForm() |
java.lang.String |
getCanonicalName(int form)
Return the full principal name in the desired canonical form (see table of values above).
|
java.lang.String |
getDomain()
Return the domain component of this principal name.
|
java.lang.String |
getName()
Return the full principal name in the canonical form in which it was supplied or in principal name form (2) if the domain and username were supplied separately.
|
java.lang.String |
getUsername()
Return the username component of this principal name.
|
int |
hashCode()
Return a hash value for the name and possibly domain.
|
java.lang.String |
toString()
Returns the same value as
getName() . |
protected int canonicalForm
protected java.lang.String domain
protected java.lang.String name
public SecurityPrincipal(java.lang.String acctname) throws SecurityProviderException
acctname
- the account name (preferrably qualified with a domain name)SecurityProviderException
- if a username component cannot be parsed from the supplied account namepublic SecurityPrincipal(java.lang.String dname, java.lang.String uname) throws SecurityProviderException
dname
- the domain name of the principaluname
- the username of the principalSecurityProviderException
- if a username is null, empty or contains only whitespacepublic java.lang.String getDomain()
public java.lang.String getUsername()
public java.lang.String getName()
getName
in interface java.security.Principal
public java.lang.String getCanonicalName(int form) throws SecurityProviderException
form
- the canonical form (1 - DN or RDN; 2 - username; 3 - backslash; 4 - principal)SecurityProviderException
public int getCanonicalForm()
public int hashCode()
hashCode
in interface java.security.Principal
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in interface java.security.Principal
equals
in class java.lang.Object
obj
- the other SecurityPrincipal
being compairedpublic java.lang.String toString()
getName()
.toString
in interface java.security.Principal
toString
in class java.lang.Object