FileDocCategorySizeDatePackage
LdapPrincipal.javaAPI DocJava SE 6 API3155Tue Jun 10 00:23:22 BST 2008com.sun.security.auth

LdapPrincipal

public final class LdapPrincipal extends Object implements Principal, Serializable
A principal identified by a distinguished name as specified by RFC 2253.

After successful authentication, a user {@link java.security.Principal} can be associated with a particular {@link javax.security.auth.Subject} to augment that Subject with an additional identity. Authorization decisions can then be based upon the Principals that are associated with a Subject.

This class is immutable.

since
1.6

Fields Summary
private static final long
serialVersionUID
private final String
nameString
The principal's string name
private final LdapName
name
The principal's name
Constructors Summary
public LdapPrincipal(String name)
Creates an LDAP principal.

param
name The principal's string distinguished name.
throws
InvalidNameException If a syntax violation is detected.
exception
NullPointerException If the name is null.


                                    
         
        if (name == null) {
            throw new NullPointerException("null name is illegal");
        }
	this.name = getLdapName(name);
	nameString = name;
    
Methods Summary
public booleanequals(java.lang.Object object)
Compares this principal to the specified object.

param
object The object to compare this principal against.
return
true if they are equal; false otherwise.

	if (this == object) {
	    return true;
	}
	if (object instanceof LdapPrincipal) {
	    try {

		return 
		    name.equals(getLdapName(((LdapPrincipal)object).getName()));

	    } catch (InvalidNameException e) {
		return false;
	    }
	}
	return false;
    
private javax.naming.ldap.LdapNamegetLdapName(java.lang.String name)

	return new LdapName(name);
    
public java.lang.StringgetName()
Returns the name originally used to create this principal.

return
The principal's string name.

	return nameString;
    
public inthashCode()
Computes the hash code for this principal.

return
The principal's hash code.

	return name.hashCode();
    
public java.lang.StringtoString()
Creates a string representation of this principal's name in the format defined by RFC 2253. If the name has zero components an empty string is returned.

return
The principal's string name.

	return name.toString();