Class JDBCRealm
- java.lang.Object
-
- com.sun.enterprise.security.auth.realm.AbstractRealm
-
- com.sun.enterprise.security.auth.realm.AbstractStatefulRealm
-
- com.sun.enterprise.security.auth.realm.Realm
-
- com.sun.enterprise.security.BaseRealm
-
- com.sun.enterprise.security.ee.auth.realm.DigestRealmBase
-
- com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm
-
- All Implemented Interfaces:
DigestRealm,Comparable<Realm>
@Service public final class JDBCRealm extends DigestRealmBase
Realm for supporting JDBC authentication.The JDBC realm needs the following properties in its configuration:
- jaas-context : JAAS context name used to access LoginModule for authentication (for example JDBCRealm).
- datasource-jndi : jndi name of datasource
- db-user : user name to access the datasource
- db-password : password to access the datasource
- digest: digest mechanism
- charset: charset encoding
- user-table: table containing user name and password
- group-table: table containing user name and group name
- user-name-column: column corresponding to user name in user-table and group-table
- password-column : column corresponding to password in user-table
- group-name-column : column corresponding to group in group-table
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUTH_TYPEDescriptive string of the authentication type of this realm.static StringBASE64static StringDEFAULT_ENCODINGstatic StringHEXstatic StringNONEstatic StringPARAM_CHARSETstatic StringPARAM_DATASOURCE_JNDIstatic StringPARAM_DB_PASSWORDstatic StringPARAM_DB_USERstatic StringPARAM_DIGEST_ALGORITHMstatic StringPARAM_ENCODINGstatic StringPARAM_GROUP_NAME_COLUMNstatic StringPARAM_GROUP_TABLEstatic StringPARAM_GROUP_TABLE_USER_NAME_COLUMNstatic StringPARAM_PASSWORD_COLUMNstatic StringPARAM_USER_NAME_COLUMNstatic StringPARAM_USER_TABLEstatic StringPRE_HASHED-
Fields inherited from class com.sun.enterprise.security.auth.realm.Realm
_logger, JAAS_CONTEXT_PARAM, RI_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 JDBCRealm()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]authenticate(String username, char[] password)Invoke the native authentication call.StringgetAuthType()Returns a short (preferably less than fifteen characters) description of the kind of authentication which is supported by this realm.Enumeration<String>getGroupNames(String username)Returns the name of all the groups that this user belongs to.protected voidinit(Properties props)Initialize a realm with some properties.booleanvalidate(String username, DigestAlgorithmParameter[] params)-
Methods inherited from class com.sun.enterprise.security.ee.auth.realm.DigestRealmBase
validate
-
Methods inherited from class com.sun.enterprise.security.BaseRealm
addUser, addUser, getGroupNames, getUser, getUserNames, persist, refresh, removeUser, supportsUserManagement, updateUser, updateUser
-
Methods inherited from class com.sun.enterprise.security.auth.realm.Realm
getDefaultInstance, getDefaultRealm, getInstance, getInstance, getRealmNames, getRealmStatsProvier, instantiate, instantiate, isValidRealm, isValidRealm, setDefaultRealm, unloadInstance, unloadInstance, updateInstance, updateInstance
-
Methods inherited from class com.sun.enterprise.security.auth.realm.AbstractStatefulRealm
addAssignGroups, compareTo, getDefaultDigestAlgorithm, getJAASContext, getMappedGroupNames, getName, getProperties, getProperty, refresh, setName, setProperty, toString
-
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
-
AUTH_TYPE
public static final String AUTH_TYPE
Descriptive string of the authentication type of this realm.- See Also:
- Constant Field Values
-
PRE_HASHED
public static final String PRE_HASHED
- See Also:
- Constant Field Values
-
PARAM_DATASOURCE_JNDI
public static final String PARAM_DATASOURCE_JNDI
- See Also:
- Constant Field Values
-
PARAM_DB_USER
public static final String PARAM_DB_USER
- See Also:
- Constant Field Values
-
PARAM_DB_PASSWORD
public static final String PARAM_DB_PASSWORD
- See Also:
- Constant Field Values
-
PARAM_DIGEST_ALGORITHM
public static final String PARAM_DIGEST_ALGORITHM
- See Also:
- Constant Field Values
-
NONE
public static final String NONE
- See Also:
- Constant Field Values
-
PARAM_ENCODING
public static final String PARAM_ENCODING
- See Also:
- Constant Field Values
-
HEX
public static final String HEX
- See Also:
- Constant Field Values
-
BASE64
public static final String BASE64
- See Also:
- Constant Field Values
-
DEFAULT_ENCODING
public static final String DEFAULT_ENCODING
- See Also:
- Constant Field Values
-
PARAM_CHARSET
public static final String PARAM_CHARSET
- See Also:
- Constant Field Values
-
PARAM_USER_TABLE
public static final String PARAM_USER_TABLE
- See Also:
- Constant Field Values
-
PARAM_USER_NAME_COLUMN
public static final String PARAM_USER_NAME_COLUMN
- See Also:
- Constant Field Values
-
PARAM_PASSWORD_COLUMN
public static final String PARAM_PASSWORD_COLUMN
- See Also:
- Constant Field Values
-
PARAM_GROUP_TABLE
public static final String PARAM_GROUP_TABLE
- See Also:
- Constant Field Values
-
PARAM_GROUP_NAME_COLUMN
public static final String PARAM_GROUP_NAME_COLUMN
- See Also:
- Constant Field Values
-
PARAM_GROUP_TABLE_USER_NAME_COLUMN
public static final String PARAM_GROUP_TABLE_USER_NAME_COLUMN
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
protected void init(Properties props) throws BadRealmException, NoSuchRealmException
Description copied from class:AbstractStatefulRealmInitialize a realm with some properties. This can be used when instantiating realms from their descriptions. This method may only be called a single time.- Overrides:
initin classAbstractStatefulRealm- Parameters:
props- 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
-
getAuthType
public String getAuthType()
Returns a short (preferably less than fifteen characters) description of the kind of authentication which is supported by this realm.- Specified by:
getAuthTypein classAbstractRealm- Returns:
- Description of the kind of authentication that is directly supported by this realm.
-
getGroupNames
public Enumeration<String> getGroupNames(String username) throws InvalidOperationException, NoSuchUserException
Returns the name of all the groups that this user belongs to. It loads the result from groupCache first. This is called from web path group verification, though it should not be.- Specified by:
getGroupNamesin classAbstractRealm- Parameters:
username- Name of the user in this realm whose group listing is needed.- Returns:
- Enumeration of group names (strings).
- Throws:
InvalidOperationException- thrown if the realm does not support this operation - e.g. Certificate realm does not support this operation.NoSuchUserException
-
authenticate
public String[] authenticate(String username, char[] password)
Invoke the native authentication call.- Parameters:
username- User to authenticate.password- Given password.- Returns:
- groups of valid user or null.
-
validate
public boolean validate(String username, DigestAlgorithmParameter[] params)
-
-