com.tagish.auth
Class TypedPrincipal

java.lang.Object
  |
  +--com.tagish.auth.TypedPrincipal
All Implemented Interfaces:
Principal, Serializable
Direct Known Subclasses:
NTPrincipal

public class TypedPrincipal
extends Object
implements Principal, Serializable

TypedPrincipals are derived from, and can be treated like Principals but they also contain extra information about the type of the Principal which can be USER, GROUP or DOMAIN. I'm not 100% certain that this is a good way of doing things. Suggestions welcome.

Version:
1.0.3
Author:
Andy Armstrong
See Also:
Serialized Form

Field Summary
static int DOMAIN
          This TypedPrincipal represents the domain name or SID.
static int GROUP
          This TypedPrincipal represents a group name or SID.
protected  String name
           
protected  int type
           
protected static String[] typeMap
           
static int UNKNOWN
          This TypedPrincipal represents an item of unknown type.
static int USER
          This TypedPrincipal represents a username or SID.
 
Constructor Summary
TypedPrincipal()
          Create a TypedPrincipal with a blank name.
TypedPrincipal(String name)
          Create a TypedPrincipal with a name.
TypedPrincipal(String name, int type)
          Create a TypedPrincipal with a name and type.
 
Method Summary
 boolean equals(Object o)
          Compares the specified Object with this TypedPrincipal for equality.
 String getName()
          Return the name for this TypedPrincipal.
 int getType()
          Return the type for this TypedPrincipal.
 String getTypeName()
          Return the name of the type for this TypedPrincipal.
 int hashCode()
          Return a hash code for this TypedPrincipal.
 void setName(String name)
           
 void setType(int type)
           
 String toString()
          Return a string representation of this TypedPrincipal.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name

type

protected int type

USER

public static final int USER
This TypedPrincipal represents a username or SID.

DOMAIN

public static final int DOMAIN
This TypedPrincipal represents the domain name or SID.

GROUP

public static final int GROUP
This TypedPrincipal represents a group name or SID.

UNKNOWN

public static final int UNKNOWN
This TypedPrincipal represents an item of unknown type.

typeMap

protected static final String[] typeMap
Constructor Detail

TypedPrincipal

public TypedPrincipal(String name,
                      int type)
Create a TypedPrincipal with a name and type.

Parameters:
name - the name for this principal.
type - the type for this principal.
Throws:
NullPointerException - if the name is null.

TypedPrincipal

public TypedPrincipal(String name)
Create a TypedPrincipal with a name.

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

TypedPrincipal

public TypedPrincipal()
Create a TypedPrincipal with a blank name.

Method Detail

setType

public void setType(int type)

setName

public void setName(String name)

getName

public String getName()
Return the name for this TypedPrincipal.

Specified by:
getName in interface Principal
Returns:
the name for this TypedPrincipal

getType

public int getType()
Return the type for this TypedPrincipal.

Returns:
the type for this TypedPrincipal

getTypeName

public String getTypeName()
Return the name of the type for this TypedPrincipal.

Returns:
the name of the type for this TypedPrincipal

toString

public String toString()
Return a string representation of this TypedPrincipal.

Specified by:
toString in interface Principal
Overrides:
toString in class Object
Returns:
a string representation of this TypedPrincipal.

equals

public boolean equals(Object o)
Compares the specified Object with this TypedPrincipal for equality. Returns true if the given object is also a TypedPrincipal and the two TypedPrincipals have the same name and type. If the object is any other kind Principal its will be considered equal if the name matches.

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

hashCode

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

Specified by:
hashCode in interface Principal
Overrides:
hashCode in class Object
Returns:
a hash code for this TypedPrincipal.