Top Description Fields Constructors Methods
org.apache.derby.authentication

public final Class SystemPrincipal

extends Object
implements Principal, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.security.Principal
Imports
java.io.IOException, .ObjectInputStream, .Serializable, java.security.Principal

This class represents Derby's notion of a principal, a concept of user identity with controlled access to Derby System Privileges. An authenticated user may have other identities which make sense in other code domains.

Note that principal names do NOT follow Authorization Identifier rules. For instance, although edward and edWard both match the normalized authorization identifier EDWARD, the instances SystemPrincipal("edward") and SystemPrincipal("edWard") represent different principals under the methods getName(), equals(), and hashCode().

According to JAASRefGuide, Principal classes must implement Serializable.

See Also
Principal#getName, JAASRefGuide on Principals

Field Summary

Modifier and TypeField and Description
private final String
name

The name of the principal.

pack-priv static final long
serialVersionUID

BTW, this class currently does not require special handling during serialization/deserialization, so, there's no need to define methods readObject(ObjectInputStream) and writeObject(ObjectOutputStream).

Constructor Summary

AccessConstructor and Description
public
SystemPrincipal(String
the name of the principal
name
)

Constructs a principal for a given name.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the principal passed in is the same as that encapsulated by this principal, and false otherwise
equals
(Object
principal to compare with
other
)

Overrides java.lang.Object.equals.

Implements java.security.Principal.equals.

Compares this principal to the specified object.

public String

Returns:

the name of this principal
getName
()

Implements java.security.Principal.getName.

Returns the name of this principal.

public int

Returns:

a hashcode for this principal
hashCode
()

Overrides java.lang.Object.hashCode.

Implements java.security.Principal.hashCode.

Returns a hashcode for this principal.

private void
readObject(ObjectInputStream s)

Called upon deserialization for restoring the state of this SystemPrincipal from a stream.

public String

Returns:

a string representation of this principal
toString
()

Overrides java.lang.Object.toString.

Implements java.security.Principal.toString.

Returns a string representation of this principal.

private static void
validateName(String
the name of the principal
name
)

Verify that the specified name of the principal is valid.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

nameback to summary
private final String name

The name of the principal.

Note that the name is not a "normalized" Authorization Identifier. This is due to peculiarities of the Java Security Runtime, which compares a javax.security.auth.Subject's Principals against the literal Principal name as declared in the policy files, and not against the return value of method getName(). So, a normalization of names within SystemPrincipal doesn't affect permission checking by the SecurityManager.

In order for a javax.security.auth.Subject to be granted permissions on the basis Authorization Identifier rules, e.g., for a Subject authenticated as edWard to fall under a policy clause declared for EDWARD, the Subject has to be constructed (or augmented) with both the literal name and the normalized Authorization Identifier.

As an alternative approach, class SystemPrincipal could implement the non-standard interface com.sun.security.auth.PrincipalComparator, which declares a method implies(Subject) that would allow for Principals to match Subjects on the basis of normalized Authorization Identifiers. But then we'd be relying upon non-standard Security Runtime behaviour.

See Also
User Names & Authorization Identifiers in Derby
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

BTW, this class currently does not require special handling during serialization/deserialization, so, there's no need to define methods readObject(ObjectInputStream) and writeObject(ObjectOutputStream).

Constructor Detail

SystemPrincipalback to summary
public SystemPrincipal(String name)

Constructs a principal for a given name.

Parameters
name:String

the name of the principal

Exceptions
NullPointerException:
if name is null
IllegalArgumentException:
if name is not a legal Principal name

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Implements java.security.Principal.equals.

Compares this principal to the specified object. Returns true if the object passed in matches the principal represented by the implementation of this interface.

Parameters
other:Object

principal to compare with

Returns:boolean

true if the principal passed in is the same as that encapsulated by this principal, and false otherwise

See Also
Principal#equals
getNameback to summary
public String getName()

Implements java.security.Principal.getName.

Returns the name of this principal.

Returns:String

the name of this principal

See Also
Principal#getName()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.security.Principal.hashCode.

Returns a hashcode for this principal.

Returns:int

a hashcode for this principal

See Also
Principal#hashCode()
readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

Called upon deserialization for restoring the state of this SystemPrincipal from a stream.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements java.security.Principal.toString.

Returns a string representation of this principal.

Returns:String

a string representation of this principal

See Also
Principal#toString()
validateNameback to summary
private static void validateName(String name)

Verify that the specified name of the principal is valid.

Parameters
name:String

the name of the principal

Exceptions
NullPointerException:
if name is null
IllegalArgumentException:
if name is not a legal Principal name