org.n52.security.common.subject
Class NamePrincipal

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

public abstract class NamePrincipal
extends Object
implements Principal, Scope, Serializable

Minimal implementation of a 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.common.subject.Scope
GLOBAL
 
Constructor Summary
NamePrincipal(String name, Scope scope)
          Constructor NamePrincipal creates a new NamePrincipal instance, which name is only valid within the given scope.
 
Method Summary
 boolean equals(Object o)
           
 String getName()
          Method gets the name of this NamePrincipal object.
 Scope getScope()
          Returns the scope of this name principal.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NamePrincipal

public NamePrincipal(String name,
                     Scope scope)
              throws 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:
IllegalArgumentException - if one of the arguments is null.
Method Detail

getName

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

Specified by:
getName in interface 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(Object o)
Specified by:
equals in interface Principal
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Principal
Overrides:
hashCode in class Object

toString

public String toString()
Specified by:
toString in interface Principal
Overrides:
toString in class Object


Copyright © 2004–2013 52north.org. All rights reserved.