Class JdbcUserDetailsManager
java.lang.Object
org.springframework.dao.support.DaoSupport
org.springframework.jdbc.core.support.JdbcDaoSupport
org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl
org.springframework.security.provisioning.JdbcUserDetailsManager
- All Implemented Interfaces:
- org.springframework.beans.factory.Aware,- org.springframework.beans.factory.InitializingBean,- org.springframework.context.MessageSourceAware,- UserDetailsService,- GroupManager,- UserDetailsManager
Jdbc user management service, based on the same table structure as its parent class,
 JdbcDaoImpl.
 
 Provides CRUD operations for both users and groups. Note that if the
 enableAuthorities property is set to false,
 calls to createUser, updateUser and deleteUser will not store the authorities from the
 UserDetails or delete authorities for the user. Since this class cannot
 differentiate between authorities which were loaded for an individual or for a group of
 which the individual is a member, it's important that you take this into account when
 using this implementation for managing your users.
- Since:
- 2.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected final org.apache.commons.logging.LogFields inherited from class org.springframework.security.core.userdetails.jdbc.JdbcDaoImplDEF_AUTHORITIES_BY_USERNAME_QUERY, DEF_GROUP_AUTHORITIES_BY_USERNAME_QUERY, DEF_USERS_BY_USERNAME_QUERY, DEFAULT_USER_SCHEMA_DDL_LOCATION, messages
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddGroupAuthority(String groupName, GrantedAuthority authority) Assigns a new authority to a group.voidaddUserToGroup(String username, String groupName) Makes a user a member of a particular group.voidchangePassword(String oldPassword, String newPassword) Modify the current user's password.voidcreateGroup(String groupName, List<GrantedAuthority> authorities) Creates a new group with the specified list of authorities.protected AuthenticationcreateNewAuthentication(Authentication currentAuth, String newPassword) voidcreateUser(UserDetails user) Create a new user with the supplied details.voiddeleteGroup(String groupName) Removes a group, including all members and authorities.voiddeleteUser(String username) Remove the user with the given login name from the system.Returns the names of all groups that this group manager controls.findGroupAuthorities(String groupName) Obtains the list of authorities which are assigned to a group.findUsersInGroup(String groupName) Locates the users who are members of a groupprotected voidinitDao()protected List<UserDetails>loadUsersByUsername(String username) Executes the SQL usersByUsernameQuery and returns a list of UserDetails objects.voidremoveGroupAuthority(String groupName, GrantedAuthority authority) Deletes an authority from those assigned to a groupvoidremoveUserFromGroup(String username, String groupName) Deletes a user's membership of a group.voidrenameGroup(String oldName, String newName) Changes the name of a group without altering the assigned authorities or members.voidsetAuthenticationManager(AuthenticationManager authenticationManager) voidsetChangePasswordSql(String changePasswordSql) voidsetCreateAuthoritySql(String createAuthoritySql) voidsetCreateUserSql(String createUserSql) voidsetDeleteGroupAuthoritiesSql(String deleteGroupAuthoritiesSql) voidsetDeleteGroupAuthoritySql(String deleteGroupAuthoritySql) voidsetDeleteGroupMemberSql(String deleteGroupMemberSql) voidsetDeleteGroupMembersSql(String deleteGroupMembersSql) voidsetDeleteGroupSql(String deleteGroupSql) voidsetDeleteUserAuthoritiesSql(String deleteUserAuthoritiesSql) voidsetDeleteUserSql(String deleteUserSql) voidsetFindAllGroupsSql(String findAllGroupsSql) voidsetFindGroupIdSql(String findGroupIdSql) voidsetFindUsersInGroupSql(String findUsersInGroupSql) voidsetGroupAuthoritiesSql(String groupAuthoritiesSql) voidsetInsertGroupAuthoritySql(String insertGroupAuthoritySql) voidsetInsertGroupMemberSql(String insertGroupMemberSql) voidsetInsertGroupSql(String insertGroupSql) voidsetRenameGroupSql(String renameGroupSql) voidsetSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use.voidsetUpdateUserSql(String updateUserSql) voidsetUserCache(UserCache userCache) Optionally sets the UserCache if one is in use in the application.voidsetUserExistsSql(String userExistsSql) voidupdateUser(UserDetails user) Update the specified user.booleanuserExists(String username) Check if a user with the supplied login name exists in the system.Methods inherited from class org.springframework.security.core.userdetails.jdbc.JdbcDaoImpladdCustomAuthorities, createUserDetails, getAuthoritiesByUsernameQuery, getEnableAuthorities, getEnableGroups, getMessages, getRolePrefix, getUsersByUsernameQuery, isUsernameBasedPrimaryKey, loadGroupAuthorities, loadUserAuthorities, loadUserByUsername, setAuthoritiesByUsernameQuery, setEnableAuthorities, setEnableGroups, setGroupAuthoritiesByUsernameQuery, setMessageSource, setRolePrefix, setUsernameBasedPrimaryKey, setUsersByUsernameQueryMethods inherited from class org.springframework.jdbc.core.support.JdbcDaoSupportcheckDaoConfig, createJdbcTemplate, getConnection, getDataSource, getExceptionTranslator, getJdbcTemplate, initTemplateConfig, releaseConnection, setDataSource, setJdbcTemplateMethods inherited from class org.springframework.dao.support.DaoSupportafterPropertiesSetMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.security.core.userdetails.UserDetailsServiceloadUserByUsername
- 
Field Details- 
DEF_CREATE_USER_SQL- See Also:
 
- 
DEF_DELETE_USER_SQL- See Also:
 
- 
DEF_UPDATE_USER_SQL- See Also:
 
- 
DEF_INSERT_AUTHORITY_SQL- See Also:
 
- 
DEF_DELETE_USER_AUTHORITIES_SQL- See Also:
 
- 
DEF_USER_EXISTS_SQL- See Also:
 
- 
DEF_CHANGE_PASSWORD_SQL- See Also:
 
- 
DEF_FIND_GROUPS_SQL- See Also:
 
- 
DEF_FIND_USERS_IN_GROUP_SQL- See Also:
 
- 
DEF_INSERT_GROUP_SQL- See Also:
 
- 
DEF_FIND_GROUP_ID_SQL- See Also:
 
- 
DEF_INSERT_GROUP_AUTHORITY_SQL- See Also:
 
- 
DEF_DELETE_GROUP_SQL- See Also:
 
- 
DEF_DELETE_GROUP_AUTHORITIES_SQL- See Also:
 
- 
DEF_DELETE_GROUP_MEMBERS_SQL- See Also:
 
- 
DEF_RENAME_GROUP_SQL- See Also:
 
- 
DEF_INSERT_GROUP_MEMBER_SQL- See Also:
 
- 
DEF_DELETE_GROUP_MEMBER_SQL- See Also:
 
- 
DEF_GROUP_AUTHORITIES_QUERY_SQL- See Also:
 
- 
DEF_DELETE_GROUP_AUTHORITY_SQL- See Also:
 
- 
loggerprotected final org.apache.commons.logging.Log logger
 
- 
- 
Constructor Details- 
JdbcUserDetailsManagerpublic JdbcUserDetailsManager()
- 
JdbcUserDetailsManager
 
- 
- 
Method Details- 
initDaoprotected void initDao() throws org.springframework.context.ApplicationContextException- Overrides:
- initDaoin class- JdbcDaoImpl
- Throws:
- org.springframework.context.ApplicationContextException
 
- 
loadUsersByUsernameExecutes the SQL usersByUsernameQuery and returns a list of UserDetails objects. There should normally only be one matching user.- Overrides:
- loadUsersByUsernamein class- JdbcDaoImpl
 
- 
createUserDescription copied from interface:UserDetailsManagerCreate a new user with the supplied details.- Specified by:
- createUserin interface- UserDetailsManager
 
- 
updateUserDescription copied from interface:UserDetailsManagerUpdate the specified user.- Specified by:
- updateUserin interface- UserDetailsManager
 
- 
deleteUserDescription copied from interface:UserDetailsManagerRemove the user with the given login name from the system.- Specified by:
- deleteUserin interface- UserDetailsManager
 
- 
changePasswordDescription copied from interface:UserDetailsManagerModify the current user's password. This should change the user's password in the persistent user repository (database, LDAP etc).- Specified by:
- changePasswordin interface- UserDetailsManager
- Parameters:
- oldPassword- current password (for re-authentication if required)
- newPassword- the password to change to
- Throws:
- AuthenticationException
 
- 
createNewAuthentication
- 
userExistsDescription copied from interface:UserDetailsManagerCheck if a user with the supplied login name exists in the system.- Specified by:
- userExistsin interface- UserDetailsManager
 
- 
findAllGroupsDescription copied from interface:GroupManagerReturns the names of all groups that this group manager controls.- Specified by:
- findAllGroupsin interface- GroupManager
 
- 
findUsersInGroupDescription copied from interface:GroupManagerLocates the users who are members of a group- Specified by:
- findUsersInGroupin interface- GroupManager
- Parameters:
- groupName- the group whose members are required
- Returns:
- the usernames of the group members
 
- 
createGroupDescription copied from interface:GroupManagerCreates a new group with the specified list of authorities.- Specified by:
- createGroupin interface- GroupManager
- Parameters:
- groupName- the name for the new group
- authorities- the authorities which are to be allocated to this group.
 
- 
deleteGroupDescription copied from interface:GroupManagerRemoves a group, including all members and authorities.- Specified by:
- deleteGroupin interface- GroupManager
- Parameters:
- groupName- the group to remove.
 
- 
renameGroupDescription copied from interface:GroupManagerChanges the name of a group without altering the assigned authorities or members.- Specified by:
- renameGroupin interface- GroupManager
 
- 
addUserToGroupDescription copied from interface:GroupManagerMakes a user a member of a particular group.- Specified by:
- addUserToGroupin interface- GroupManager
- Parameters:
- username- the user to be given membership.
- groupName- the name of the group to which the user will be added.
 
- 
removeUserFromGroupDescription copied from interface:GroupManagerDeletes a user's membership of a group.- Specified by:
- removeUserFromGroupin interface- GroupManager
- Parameters:
- username- the user
- groupName- the group to remove them from
 
- 
findGroupAuthoritiesDescription copied from interface:GroupManagerObtains the list of authorities which are assigned to a group.- Specified by:
- findGroupAuthoritiesin interface- GroupManager
 
- 
removeGroupAuthorityDescription copied from interface:GroupManagerDeletes an authority from those assigned to a group- Specified by:
- removeGroupAuthorityin interface- GroupManager
 
- 
addGroupAuthorityDescription copied from interface:GroupManagerAssigns a new authority to a group.- Specified by:
- addGroupAuthorityin interface- GroupManager
 
- 
setSecurityContextHolderStrategypublic void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use. The default action is to use theSecurityContextHolderStrategystored inSecurityContextHolder.- Since:
- 5.8
 
- 
setAuthenticationManager
- 
setCreateUserSql
- 
setDeleteUserSql
- 
setUpdateUserSql
- 
setCreateAuthoritySql
- 
setDeleteUserAuthoritiesSql
- 
setUserExistsSql
- 
setChangePasswordSql
- 
setFindAllGroupsSql
- 
setFindUsersInGroupSql
- 
setInsertGroupSql
- 
setFindGroupIdSql
- 
setInsertGroupAuthoritySql
- 
setDeleteGroupSql
- 
setDeleteGroupAuthoritiesSql
- 
setDeleteGroupMembersSql
- 
setRenameGroupSql
- 
setInsertGroupMemberSql
- 
setDeleteGroupMemberSql
- 
setGroupAuthoritiesSql
- 
setDeleteGroupAuthoritySql
- 
setUserCacheOptionally sets the UserCache if one is in use in the application. This allows the user to be removed from the cache after updates have taken place to avoid stale data.- Parameters:
- userCache- the cache used by the AuthenticationManager.
 
 
-