jrun.security
Class SimplePrincipal

java.lang.Object
  |
  +--jrun.security.SimplePrincipal
All Implemented Interfaces:
java.security.Principal, java.io.Serializable

public class SimplePrincipal
extends java.lang.Object
implements java.security.Principal, java.io.Serializable

This class implements the Principal interface and represents a Simple user with a name and type. The type can be any String, but usually is either "USER" which is the default value or "ROLE".

Principals such as this SimplePrincipal may be associated with a particular Subject to augment that Subject with an additional identity. Refer to the Subject class for more information on how to achieve this. Authorization decisions can then be based upon the Principals associated with a Subject.

See Also:
Principal, Subject, Serialized Form

Field Summary
protected  java.lang.String name
           
static java.lang.String ROLE
           
protected  java.lang.String type
           
static java.lang.String USER
           
 
Constructor Summary
SimplePrincipal(java.security.Principal p)
           
SimplePrincipal(java.lang.String name)
          Create a SimplePrincipal with a username.
SimplePrincipal(java.lang.String name, java.lang.String type)
          Create a SimplePrincipal with a username and type.
 
Method Summary
 boolean equals(java.lang.Object o)
          Compares the specified Object with this SimplePrincipal for equality.
 java.lang.String getName()
          Return the Sample username for this SimplePrincipal.
 java.lang.String getType()
           
 int hashCode()
          Return a hash code for this SimplePrincipal.
 void setType(java.lang.String type)
          Accessor methods for type.
 java.lang.String toString()
          Return a string representation of this SimplePrincipal.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ROLE

public static final java.lang.String ROLE

USER

public static final java.lang.String USER

name

protected java.lang.String name

type

protected java.lang.String type
Constructor Detail

SimplePrincipal

public SimplePrincipal(java.lang.String name)
Create a SimplePrincipal with a username.

Parameters:
name - the username for this user.
Throws:
NullPointerException - if the name is null.

SimplePrincipal

public SimplePrincipal(java.lang.String name,
                       java.lang.String type)
Create a SimplePrincipal with a username and type. If type is null default to "USER"

SimplePrincipal

public SimplePrincipal(java.security.Principal p)
Method Detail

getName

public java.lang.String getName()
Return the Sample username for this SimplePrincipal.

Specified by:
getName in interface java.security.Principal
Returns:
the Sample username for this SimplePrincipal

setType

public void setType(java.lang.String type)
Accessor methods for type.

getType

public java.lang.String getType()

toString

public java.lang.String toString()
Return a string representation of this SimplePrincipal.

Specified by:
toString in interface java.security.Principal
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this SimplePrincipal.

equals

public boolean equals(java.lang.Object o)
Compares the specified Object with this SimplePrincipal for equality. Returns true if the given object is also a SimplePrincipal and the two SimplePrincipals have the same username.

Specified by:
equals in interface java.security.Principal
Overrides:
equals in class java.lang.Object
Parameters:
o - Object to be compared for equality with this SimplePrincipal.
Returns:
true if the specified Object is equal equal to this SimplePrincipal.

hashCode

public int hashCode()
Return a hash code for this SimplePrincipal.

Specified by:
hashCode in interface java.security.Principal
Overrides:
hashCode in class java.lang.Object
Returns:
a hash code for this SimplePrincipal.


Copyright � 2002 Macromedia Corporation. All Rights Reserved.