Class SystemPrincipal
- All Implemented Interfaces:
Serializable
,Principal
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
The name of the principal.(package private) static final long
BTW, this class currently does not require special handling during serialization/deserialization, so, there's no need to define methodsreadObject(ObjectInputStream)
andwriteObject(ObjectOutputStream)
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares this principal to the specified object.getName()
Returns the name of this principal.int
hashCode()
Returns a hashcode for this principal.private void
Called upon deserialization for restoring the state of this SystemPrincipal from a stream.toString()
Returns a string representation of this principal.private static void
validateName
(String name) Verify that the specified name of the principal is valid.
-
Field Details
-
serialVersionUID
static final long serialVersionUIDBTW, this class currently does not require special handling during serialization/deserialization, so, there's no need to define methodsreadObject(ObjectInputStream)
andwriteObject(ObjectOutputStream)
.- See Also:
-
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 methodgetName()
. 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 interfacecom.sun.security.auth.PrincipalComparator
, which declares a methodimplies(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:
-
-
Constructor Details
-
SystemPrincipal
Constructs a principal for a given name.- Parameters:
name
- the name of the principal- Throws:
NullPointerException
- if name is nullIllegalArgumentException
- if name is not a legal Principal name
-
-
Method Details
-
validateName
Verify that the specified name of the principal is valid.- Parameters:
name
- the name of the principal- Throws:
NullPointerException
- if name is nullIllegalArgumentException
- if name is not a legal Principal name
-
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. -
getName
Returns the name of this principal. -
hashCode
public int hashCode()Returns a hashcode for this principal. -
toString
Returns a string representation of this principal. -
readObject
Called upon deserialization for restoring the state of this SystemPrincipal from a stream.- Throws:
IOException
ClassNotFoundException
-