Class AbstractStatefulRealm
- java.lang.Object
-
- com.sun.enterprise.security.auth.realm.AbstractRealm
-
- com.sun.enterprise.security.auth.realm.AbstractStatefulRealm
-
- All Implemented Interfaces:
Comparable<Realm>
- Direct Known Subclasses:
Realm
public abstract class AbstractStatefulRealm extends AbstractRealm implements Comparable<Realm>
This class is the base for all Payara Realm classes, and contains common object state such as the realm name, general properties and the assign groups.- Author:
- Arjan Tijms
-
-
Field Summary
Fields Modifier and Type Field Description protected GroupMapper
groupMapper
protected static String
GROUPS_SEP
Separator of group values: ","static String
PARAM_DEFAULT_DIGEST_ALGORITHM
Realm parameter: "default-digest-algorithm"static String
PARAM_GROUP_MAPPING
Realm parameter: "group-mapping"static String
PARAM_GROUPS
Realm parameter: "assign-groups".
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractStatefulRealm()
The default the constructor creates a realm which will later be initialized, either from properties or by deserializing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String[]
addAssignGroups(String[] groups)
Add assign groups to given array of groups.int
compareTo(Realm otherRealm)
Compares a realm to another.protected String
getDefaultDigestAlgorithm()
String
getJAASContext()
Returns name of JAAS context used by this realm.protected ArrayList<String>
getMappedGroupNames(String group)
String
getName()
Returns the name of this realm.protected Properties
getProperties()
String
getProperty(String name)
Get a realm property.protected void
init(Properties properties)
Initialize a realm with some properties.void
refresh(String configName)
Refreshes the realm data so that new users/groups are visible.protected void
setName(String name)
Assigns the name of this realm, and stores it in the cache of realms.void
setProperty(String name, String value)
Set a realm property.String
toString()
Returns the name of this realm.-
Methods inherited from class com.sun.enterprise.security.auth.realm.AbstractRealm
addUser, getAuthType, getGroupNames, getGroupNames, getUser, getUserNames, persist, refresh, removeUser, supportsUserManagement, updateUser
-
-
-
-
Field Detail
-
PARAM_GROUP_MAPPING
public static final String PARAM_GROUP_MAPPING
Realm parameter: "group-mapping"- See Also:
- Constant Field Values
-
PARAM_GROUPS
public static final String PARAM_GROUPS
Realm parameter: "assign-groups".Comma separated. All users authenticated by this realm will be in these groups
- See Also:
- Constant Field Values
-
PARAM_DEFAULT_DIGEST_ALGORITHM
public static final String PARAM_DEFAULT_DIGEST_ALGORITHM
Realm parameter: "default-digest-algorithm"- See Also:
- Constant Field Values
-
GROUPS_SEP
protected static final String GROUPS_SEP
Separator of group values: ","- See Also:
- Constant Field Values
-
groupMapper
protected GroupMapper groupMapper
-
-
Method Detail
-
init
protected void init(Properties properties) throws BadRealmException, NoSuchRealmException
Initialize a realm with some properties. This can be used when instantiating realms from their descriptions. This method may only be called a single time.- Parameters:
properties
- initialization parameters used by this realm.- Throws:
BadRealmException
- if the configuration parameters identify a corrupt realmNoSuchRealmException
- if the configuration parameters specify a realm which doesn't exist
-
addAssignGroups
protected String[] addAssignGroups(String[] groups)
Add assign groups to given array of groups.- Parameters:
groups
- user's groups to merge with "assign-groups" parameter. Can be null.- Returns:
- merged array of group names. Never null.
-
refresh
public void refresh(String configName) throws BadRealmException
Refreshes the realm data so that new users/groups are visible.- Parameters:
configName
-- Throws:
BadRealmException
- if realm data structures are bad
-
getName
public final String getName()
Returns the name of this realm.- Returns:
- realm name.
-
setName
protected final void setName(String name)
Assigns the name of this realm, and stores it in the cache of realms. Used when initializing a newly created in-memory realm object; if the realm already has a name, there is no effect.- Parameters:
name
- name to be assigned to this realm.
-
getDefaultDigestAlgorithm
protected String getDefaultDigestAlgorithm()
- Returns:
- default digest algorithm, for example: "SHA-256"
-
getProperty
public String getProperty(String name)
Get a realm property.Note: requires server restart when updating or removing.
- Parameters:
name
- property name.- Returns:
- value.
-
setProperty
public void setProperty(String name, String value)
Set a realm property.Note: requires server restart when updating or removing.
- Parameters:
name
- property name.value
- property value. Nulls are ignored.
-
getProperties
protected Properties getProperties()
- Returns:
- properties of the realm.
-
getJAASContext
public String getJAASContext()
Returns name of JAAS context used by this realm.JAAS context determines the login module(s) to be invoked by means of JAAS configuration file (
login.conf
in domain config directory).Default implementation uses value of realm's property
jaas-context
.- Returns:
- String containing JAAS context name.
-
toString
public String toString()
Returns the name of this realm.
-
compareTo
public int compareTo(Realm otherRealm)
Compares a realm to another.The comparison first considers the authentication type, so that realms supporting the same kind of user authentication are grouped together. Then it compares realm realm names. Realms compare "before" other kinds of objects (i.e. there's only a partial order defined, in the case that those other objects compare themselves "before" a realm object).
- Specified by:
compareTo
in interfaceComparable<Realm>
-
-