public class SerializablePrincipal extends Object implements Serializable
Realm
implementations.
The GenericPrincipal does NOT implement serializable and I didn't want to
change that implementation hence I implemented this one instead.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 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).
|
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) |
protected static final StringManager sm
protected String name
protected String password
protected transient Realm realm
protected String[] roles
protected Principal userPrincipal
public SerializablePrincipal()
public SerializablePrincipal(String name, String password)
name
- The username of the user represented by this Principalpassword
- Credentials used to authenticate this userpublic SerializablePrincipal(String name, String password, List<String> roles)
name
- The username of the user represented by this Principalpassword
- Credentials used to authenticate this userroles
- List of roles (must be Strings) possessed by this userpublic SerializablePrincipal(String name, String password, List<String> roles, Principal userPrincipal)
name
- The username of the user represented by this Principalpassword
- Credentials used to authenticate this userroles
- List of roles (must be Strings) possessed by this useruserPrincipal
- The user principal to be exposed to applicationspublic String getName()
public String getPassword()
public Realm getRealm()
public void setRealm(Realm realm)
public String[] getRoles()
public String toString()
public static SerializablePrincipal createPrincipal(GenericPrincipal principal)
public GenericPrincipal getPrincipal()
public static GenericPrincipal readPrincipal(ObjectInput in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static void writePrincipal(GenericPrincipal p, ObjectOutput out) throws IOException
IOException
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.