org.n52.security.authentication.principals
Class NamePrincipal

java.lang.Object
  extended by org.n52.security.authentication.principals.NamePrincipal
All Implemented Interfaces:
java.io.Serializable, java.security.Principal, Scope
Direct Known Subclasses:
AttributePrincipal, LoginNamePrincipal, RolePrincipal, UsernameIDPrincipal

public abstract class NamePrincipal
extends java.lang.Object
implements java.security.Principal, Scope, java.io.Serializable

Class NamePrincipal is a minimal implementation of an principal. It is declared abstract to avoid the usage of such unspecific principals.

A login module shall use one of its subclasses for better application support.

To support better differentiation of principals a scope is introduced, this can be used to distinguish principals with the same name and class.

Version:
$Revision: $
Author:
Marko Reiprecht Created on 16.09.2007
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.n52.security.authentication.principals.Scope
GLOBAL
 
Constructor Summary
NamePrincipal(java.lang.String name, Scope scope)
          Constructor NamePrincipal creates a new NamePrincipal instance, which name is only valid within the given scope.
 
Method Summary
 boolean equals(java.lang.Object o)
          Returns the equaltiy.
 java.lang.String getName()
          Method gets the name of this NamePrincipal object.
 Scope getScope()
          Returns the scope of this name principal.
 int hashCode()
          Returns the hashCode.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.security.Principal
toString
 

Constructor Detail

NamePrincipal

public NamePrincipal(java.lang.String name,
                     Scope scope)
              throws java.lang.IllegalArgumentException
Constructor NamePrincipal creates a new NamePrincipal instance, which name is only valid within the given scope.

It throws an IllegalArgumentException if one of the arguments is null.

Parameters:
name - the name != null.
scope - the scope != null.
Throws:
java.lang.IllegalArgumentException - if one of the arguments is null.
Method Detail

getName

public java.lang.String getName()
Method gets the name of this NamePrincipal object.

Specified by:
getName in interface java.security.Principal
Specified by:
getName in interface Scope
Returns:
String.

getScope

public Scope getScope()
Returns the scope of this name principal.

Specified by:
getScope in interface Scope
Returns:
returns the scope.
See Also:
Scope.getScope()

equals

public boolean equals(java.lang.Object o)
Returns the equaltiy.

Specified by:
equals in interface java.security.Principal
Overrides:
equals in class java.lang.Object
Parameters:
o - the other object.
Returns:
boolean.

hashCode

public int hashCode()
Returns the hashCode.

Specified by:
hashCode in interface java.security.Principal
Overrides:
hashCode in class java.lang.Object
Returns:
int.


Copyright © 2004-2009 52north.org. All Rights Reserved.