public final class SwitchUserHelper extends Object
SwitchUserGrantedAuthority
of the new user
which then will be used when switching back.
The target user will only have the roles as defined in ROLE_SWITCH_ORGINAL_USER
, all
other roles will not be used as authority for the target user. Therefore the target user will not
have client admin rights, even if the admin role is assigned in the database.
The switching of a user is only allowed if the current user has a system role authority (UserRole.ROLE_SYSTEM_USER
Modifier and Type | Method and Description |
---|---|
static boolean |
canSwitchUser() |
static org.springframework.security.core.Authentication |
getOriginalAuthentication() |
static boolean |
isUserSwitched() |
static org.springframework.security.core.Authentication |
removeSwitchedUser()
Throws an exception in case no switched user exists
|
static org.springframework.security.core.Authentication |
switchUser(User targetUser)
Switch the user to the target user.
|
public static boolean canSwitchUser()
public static org.springframework.security.core.Authentication getOriginalAuthentication()
public static boolean isUserSwitched()
public static org.springframework.security.core.Authentication removeSwitchedUser()
public static org.springframework.security.core.Authentication switchUser(User targetUser) throws SwitchUserNotAllowedException
targetUser
- the user to switch toSwitchUserNotAllowedException
- in case the switching is not allowedCopyright © 2019 Communote team. All rights reserved.