Class Realm
- java.lang.Object
-
- com.sun.enterprise.security.auth.realm.AbstractRealm
-
- com.sun.enterprise.security.auth.realm.AbstractStatefulRealm
-
- com.sun.enterprise.security.auth.realm.Realm
-
- All Implemented Interfaces:
Comparable<Realm>
- Direct Known Subclasses:
BaseRealm
@Contract public abstract class Realm extends AbstractStatefulRealm implements Comparable<Realm>
- Author:
- Harish Prabandham, Harpreet Singh, Jyri Virkki, Shing Wai Chan
- See Also:
Principal
-
-
Field Summary
Fields Modifier and Type Field Description protected static Logger_loggerstatic StringJAAS_CONTEXT_PARAMRecommended property for keeping JAAS Context of a realm.static StringRI_DEFAULT-
Fields inherited from class com.sun.enterprise.security.auth.realm.AbstractStatefulRealm
groupMapper, GROUPS_SEP, PARAM_DEFAULT_DIGEST_ALGORITHM, PARAM_GROUP_MAPPING, PARAM_GROUPS
-
-
Constructor Summary
Constructors Constructor Description Realm()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RealmgetDefaultInstance()Convenience method which returns the Realm object representing the current default realm.static StringgetDefaultRealm()Returns the name of the default realm.static RealmgetInstance(String name)Returns the realm identified by the name which is passed as a parameter.static RealmgetInstance(String configName, String name)Returns the realm identified by the name which is passed as a parameter.static Enumeration<String>getRealmNames()Returns the names of accessible realms.static voidgetRealmStatsProvier()static Realminstantiate(String name, String className, Properties props)Instantiate a Realm with the given name and properties using the Class name given.static Realminstantiate(String name, String className, Properties props, String configName)Instantiate a Realm with the given name and properties using the Class name given.static booleanisValidRealm(String name)Checks if the given realm name is loaded/valid.static booleanisValidRealm(String configName, String name)Checks if the given realm name is loaded/valid.static voidsetDefaultRealm(String realmName)Sets the name of the default realm.static voidunloadInstance(String realmName)Remove realm with given name from cache.static voidunloadInstance(String configName, String realmName)Remove realm with given name from cache.protected static voidupdateInstance(Realm realm, String name)Replace a Realm instance.protected static voidupdateInstance(String configName, Realm realm, String name)Replace a Realm instance.-
Methods inherited from class com.sun.enterprise.security.auth.realm.AbstractStatefulRealm
addAssignGroups, compareTo, getDefaultDigestAlgorithm, getJAASContext, getMappedGroupNames, getName, getProperties, getProperty, init, refresh, setName, setProperty, toString
-
Methods inherited from class com.sun.enterprise.security.auth.realm.AbstractRealm
addUser, getAuthType, getGroupNames, getGroupNames, getUser, getUserNames, persist, refresh, removeUser, supportsUserManagement, updateUser
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Field Detail
-
JAAS_CONTEXT_PARAM
public static final String JAAS_CONTEXT_PARAM
Recommended property for keeping JAAS Context of a realm.
-
_logger
protected static final Logger _logger
-
RI_DEFAULT
public static final String RI_DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
instantiate
public static Realm instantiate(String name, String className, Properties props) throws BadRealmException
Instantiate a Realm with the given name and properties using the Class name given.- Parameters:
name- Name of the new realm.className- Java Class name of the realm to create.props- Properties containing values of the Property element from server.xml- Returns:
- Reference to the new Realm. The Realm class keeps an internal list of all instantiated realms.
- Throws:
BadRealmException- If the requested realm cannot be instantiated.
-
instantiate
public static Realm instantiate(String name, String className, Properties props, String configName) throws BadRealmException
Instantiate a Realm with the given name and properties using the Class name given.- Parameters:
name- Name of the new realm.className- Java Class name of the realm to create.props- Properties containing values of the Property element from server.xmlconfigName- the config to which this realm belongs- Throws:
BadRealmException- If the requested realm cannot be instantiated.
-
getDefaultInstance
public static Realm getDefaultInstance() throws NoSuchRealmException
Convenience method which returns the Realm object representing the current default realm. Equivalent to getInstance(getDefaultRealm()).- Returns:
- Realm representing default realm.
- Throws:
NoSuchRealmException- if default realm does not exist
-
getDefaultRealm
public static String getDefaultRealm()
Returns the name of the default realm.- Returns:
- Default realm name.
-
setDefaultRealm
public static void setDefaultRealm(String realmName)
Sets the name of the default realm.- Parameters:
realmName- Name of realm to set as default.
-
getInstance
public static Realm getInstance(String name) throws NoSuchRealmException
Returns the realm identified by the name which is passed as a parameter. This function knows about all the realms which exist; it is not possible to store (or create) one which is not accessible through this routine.- Parameters:
name- identifies the realm- Returns:
- the requested realm
- Throws:
NoSuchRealmException- if the realm is invalid
-
getInstance
public static Realm getInstance(String configName, String name) throws NoSuchRealmException
Returns the realm identified by the name which is passed as a parameter. This function knows about all the realms which exist; it is not possible to store (or create) one which is not accessible through this routine.- Parameters:
configName-name- identifies the realm- Returns:
- the requested realm
- Throws:
NoSuchRealmException- if the realm is invalid
-
getRealmNames
public static Enumeration<String> getRealmNames()
Returns the names of accessible realms.- Returns:
- set of realm names
-
isValidRealm
public static boolean isValidRealm(String name)
Checks if the given realm name is loaded/valid.- Parameters:
name- name of the realm to check.- Returns:
- true if realm present, false otherwise.
-
isValidRealm
public static boolean isValidRealm(String configName, String name)
Checks if the given realm name is loaded/valid.- Parameters:
configName-name- name of the realm to check.- Returns:
- true if realm present, false otherwise.
-
getRealmStatsProvier
public static void getRealmStatsProvier()
-
unloadInstance
public static void unloadInstance(String realmName) throws NoSuchRealmException
Remove realm with given name from cache.- Parameters:
realmName-- Throws:
NoSuchRealmException
-
unloadInstance
public static void unloadInstance(String configName, String realmName) throws NoSuchRealmException
Remove realm with given name from cache.- Parameters:
configName-realmName-- Throws:
NoSuchRealmException
-
updateInstance
protected static void updateInstance(Realm realm, String name)
Replace a Realm instance. Can be used by a Realm subclass to replace a previously initialized instance of itself. Future getInstance requests will then obtain the new instance.Minimal error checking is done. The realm being replaced must already exist (instantiate() was previously called), the new instance must be fully initialized properly and it must of course be of the same class as the previous instance.
- Parameters:
realm- The new realm instance.name- The (previously instantiated) name for this realm.
-
updateInstance
protected static void updateInstance(String configName, Realm realm, String name)
Replace a Realm instance. Can be used by a Realm subclass to replace a previously initialized instance of itself. Future getInstance requests will then obtain the new instance.Minimal error checking is done. The realm being replaced must already exist (instantiate() was previously called), the new instance must be fully initialized properly and it must of course be of the same class as the previous instance.
- Parameters:
configName-realm- The new realm instance.name- The (previously instantiated) name for this realm.
-
-