Class BaseRealm
- All Implemented Interfaces:
Comparable
This class provides default implementation for most of the abstract methods in com.sun.enterprise.security.auth.realm.Realm. Since most of these abstract methods are not supported by Realms there is no need for the subclasses to implement them. The default implementations provided here generally throw an exception if invoked.
- Author:
- Harpreet Singh
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected static final com.sun.enterprise.util.i18n.StringManager
Fields inherited from class com.sun.enterprise.security.auth.realm.Realm
_logger, groupMapper, PARAM_GROUP_MAPPING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds new user to file realm.void
Deprecated.Returns an AuthenticationHandler object which can be used to authenticate within this realm.Returns names of all the groups in this particular realm.Returns the information recorded about a particular named user.Returns names of all the users in this particular realm.void
persist()
Persist the realm data to permanent storagevoid
refresh()
Refreshes the realm data so that new users/groups are visible.void
removeUser
(String name) Remove user from file realm.boolean
void
updateUser
(String name, String newName, char[] password, String[] groups) Update data for an existing user.void
updateUser
(String name, String newName, String password, String[] groups) Deprecated.Methods inherited from class com.sun.enterprise.security.auth.realm.Realm
addAssignGroups, compareTo, getAuthType, getDefaultDigestAlgorithm, getDefaultInstance, getDefaultRealm, getGroupNames, getInstance, getInstance, getJAASContext, getMappedGroupNames, getName, getProperties, getProperty, getRealmNames, getRealmStatsProvier, init, instantiate, instantiate, instantiate, isValidRealm, isValidRealm, refresh, setDefaultRealm, setName, setProperty, toString, unloadInstance, unloadInstance, updateInstance, updateInstance
-
Field Details
-
JAAS_CONTEXT_PARAM
- See Also:
-
sm
protected static final com.sun.enterprise.util.i18n.StringManager sm
-
-
Constructor Details
-
BaseRealm
public BaseRealm()
-
-
Method Details
-
getAuthenticationHandler
Returns an AuthenticationHandler object which can be used to authenticate within this realm.This method return null always, since AuthenticationHandlers are generally not supported by iAS realms. Subclass can override if necessary.
- Specified by:
getAuthenticationHandler
in classRealm
- Returns:
- An AuthenticationHandler object for this realm (always null)
-
getUserNames
Returns names of all the users in this particular realm.This method always throws a BadRealmException since by default this operation is not supported. Subclasses which support this method can override.
- Specified by:
getUserNames
in classRealm
- Returns:
- enumeration of user names (strings)
- Throws:
BadRealmException
- if realm data structures are bad
-
getUser
Returns the information recorded about a particular named user.This method always throws a BadRealmException since by default this operation is not supported. Subclasses which support this method can override.
- Specified by:
getUser
in classRealm
- Parameters:
name
- name of the user whose information is desired- Returns:
- the user object
- Throws:
NoSuchUserException
- if the user doesn't existBadRealmException
- if realm data structures are bad
-
getGroupNames
Returns names of all the groups in this particular realm.This method always throws a BadRealmException since by default this operation is not supported. Subclasses which support this method can override.
- Specified by:
getGroupNames
in classRealm
- Returns:
- enumeration of group names (strings)
- Throws:
BadRealmException
- if realm data structures are bad
-
refresh
Refreshes the realm data so that new users/groups are visible.This method always throws a BadRealmException since by default this operation is not supported. Subclasses which support this method can override.
- Specified by:
refresh
in classRealm
- Throws:
BadRealmException
- if realm data structures are bad
-
addUser
public void addUser(String name, char[] password, String[] groupList) throws BadRealmException, IASSecurityException Adds new user to file realm. User cannot exist already.- Specified by:
addUser
in classRealm
- Parameters:
name
- User name.password
- Cleartext password for the user.groupList
- List of groups to which user belongs.- Throws:
BadRealmException
- If there are problems adding user.IASSecurityException
-
addUser
@Deprecated public void addUser(String name, String password, String[] groupList) throws BadRealmException, IASSecurityException Deprecated.Adds new user to file realm. User cannot exist already. Deprecated - User of the overloaded method with char[] password is encouraged -
removeUser
Remove user from file realm. User must exist.- Specified by:
removeUser
in classRealm
- Parameters:
name
- User name.- Throws:
NoSuchUserException
- If user does not exist.BadRealmException
-
updateUser
@Deprecated public void updateUser(String name, String newName, String password, String[] groups) throws NoSuchUserException, BadRealmException, IASSecurityException Deprecated.Update data for an existing user. User must exist. Deprecated - User of the overloaded method with char[] password is encouraged -
updateUser
public void updateUser(String name, String newName, char[] password, String[] groups) throws NoSuchUserException, BadRealmException, IASSecurityException Update data for an existing user. User must exist.- Specified by:
updateUser
in classRealm
- Parameters:
name
- Current name of the user to update.newName
- New name to give this user. It can be the same as the original name. Otherwise it must be a new user name which does not already exist as a user.password
- Cleartext password for the user. If non-null the user password is changed to this value. If null, the original password is retained.groupList
- List of groups to which user belongs.- Throws:
BadRealmException
- If there are problems adding user.NoSuchUserException
- If user does not exist.IASSecurityException
-
supportsUserManagement
public boolean supportsUserManagement()- Specified by:
supportsUserManagement
in classRealm
- Returns:
- true if the realm implementation support User Management (add,remove,update user)
-
persist
Persist the realm data to permanent storage- Specified by:
persist
in classRealm
- Throws:
BadRealmException
-