SerializablePrincipal (Apache Tomcat 7.0.104 API Documentation)

org.apache.catalina.ha.session

## Class SerializablePrincipal

- java.lang.Object
- - org.apache.catalina.ha.session.SerializablePrincipal

- All Implemented Interfaces:
    Serializable

      public class SerializablePrincipal
      extends Object
      implements Serializable

  Generic implementation of java.security.Principal that is available for use by `Realm` implementations. The GenericPrincipal does NOT implement serializable and I didn't want to change that implementation hence I implemented this one instead.
  Author:
    Filip Hanik
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `name` The username of the user represented by this Principal.
    `protected String` | `password` The authentication credentials for the user represented by this Principal.
    `protected Realm` | `realm` The Realm with which this Principal is associated.
    `protected String[]` | `roles` The set of roles associated with this user.
    `protected static StringManager` | `sm` The string manager for this package.
    `protected Principal` | `userPrincipal` The user principal, if present.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SerializablePrincipal()`
    `SerializablePrincipal(String name, String password)` Construct a new Principal, associated with the specified Realm, for the specified username and password.
    `SerializablePrincipal(String name, String password, List<String> roles)` Construct a new Principal, associated with the specified Realm, for the specified username and password, with the specified role names (as Strings).
    `SerializablePrincipal(String name, String password, List<String> roles, Principal userPrincipal)` Construct a new Principal, associated with the specified Realm, for the specified username and password, with the specified role names (as Strings).

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static SerializablePrincipal` | `createPrincipal(GenericPrincipal principal)`
    `String` | `getName()`
    `String` | `getPassword()`
    `GenericPrincipal` | `getPrincipal()`
    `Realm` | `getRealm()`
    `String[]` | `getRoles()`
    `static GenericPrincipal` | `readPrincipal(ObjectInput in)`
    `void` | `setRealm(Realm realm)`
    `String` | `toString()` Return a String representation of this object, which exposes only information that should be public.
    `static void` | `writePrincipal(GenericPrincipal p, ObjectOutput out)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### sm

          protected static final StringManager sm

      The string manager for this package.

    - #### name

          protected String name

      The username of the user represented by this Principal.

    - #### password

          protected String password

      The authentication credentials for the user represented by this Principal.

    - #### realm

          protected transient Realm realm

      The Realm with which this Principal is associated.

    - #### roles

          protected String[] roles

      The set of roles associated with this user.

    - #### userPrincipal

          protected Principal userPrincipal

      The user principal, if present.

  - ### Constructor Detail

    - #### SerializablePrincipal

          public SerializablePrincipal()

    - #### SerializablePrincipal

          public SerializablePrincipal(String name,
                               String password)

      Construct a new Principal, associated with the specified Realm, for the specified username and password.
      Parameters:
        `name` - The username of the user represented by this Principal
        `password` - Credentials used to authenticate this user

    - #### SerializablePrincipal

          public SerializablePrincipal(String name,
                               String password,
                               List<String> roles)

      Construct a new Principal, associated with the specified Realm, for the specified username and password, with the specified role names (as Strings).
      Parameters:
        `name` - The username of the user represented by this Principal
        `password` - Credentials used to authenticate this user
        `roles` - List of roles (must be Strings) possessed by this user

    - #### SerializablePrincipal

          public SerializablePrincipal(String name,
                               String password,
                               List<String> roles,
                               Principal userPrincipal)

      Construct a new Principal, associated with the specified Realm, for the specified username and password, with the specified role names (as Strings).
      Parameters:
        `name` - The username of the user represented by this Principal
        `password` - Credentials used to authenticate this user
        `roles` - List of roles (must be Strings) possessed by this user
        `userPrincipal` - The user principal to be exposed to applications

  - ### Method Detail

    - #### getName

          public String getName()

    - #### getPassword

          public String getPassword()

    - #### getRealm

          public Realm getRealm()

    - #### setRealm

          public void setRealm(Realm realm)

    - #### getRoles

          public String[] getRoles()

    - #### toString

          public String toString()

      Return a String representation of this object, which exposes only information that should be public.
      Overrides:
        `toString` in class `Object`

    - #### createPrincipal

          public static SerializablePrincipal createPrincipal(GenericPrincipal principal)

    - #### getPrincipal

          public GenericPrincipal getPrincipal()

    - #### readPrincipal

          public static GenericPrincipal readPrincipal(ObjectInput in)
                                                throws IOException,
                                                       ClassNotFoundException

      Throws:
        `IOException`
        `ClassNotFoundException`

    - #### writePrincipal

          public static void writePrincipal(GenericPrincipal p,
                            ObjectOutput out)
                                     throws IOException

      Throws:
        `IOException`

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.