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.
Principal#getName, JAASRefGuide on Principals
| Modifier and Type | Field 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
|
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the principal passed in is the same as that encapsulated by this principal, and false otherwiseprincipal to compare with other)Overrides java. Implements java. Compares this principal to the specified object. |
| public String | Returns: the name of this principalImplements java. Returns the name of this principal. |
| public int | Returns: a hashcode for this principalOverrides java. Implements java. 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 principalOverrides java. Implements java. 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. |
| name | back 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
In order for a
As an alternative approach, class | |
| serialVersionUID | back 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
| |
| SystemPrincipal | back to summary |
|---|---|
| public SystemPrincipal(String name) Constructs a principal for a given name.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Implements java. 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 | back to summary |
|---|---|
| public String getName() Implements java. Returns the name of this principal.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Returns a hashcode for this principal.
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException Called upon deserialization for restoring the state of this SystemPrincipal from a stream. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Implements java. Returns a string representation of this principal.
| |
| validateName | back to summary |
|---|---|
| private static void validateName(String name) Verify that the specified name of the principal is valid.
| |