public class DefaultImpersonationService extends Object implements ImpersonationService
Modifier and Type | Field and Description |
---|---|
static String |
CSR_CLIENT_ID |
static String |
CSR_ID |
static String |
IMPERSONATED_CLIENT_ID |
static String |
IMPERSONATED_SUB |
protected static long |
IMPERSONATION_TOKEN_EXP_TIME_SEC |
static String |
REDIRECT_URI |
Constructor and Description |
---|
DefaultImpersonationService(ImpersonationClaimsEnhancer claimsEnhancer,
StatelessUtil statelessUtil) |
Modifier and Type | Method and Description |
---|---|
protected Map<String,Object> |
buildImpersonationClaims(ImpersonationRequest request,
org.springframework.security.core.Authentication authentication) |
ImpersonationRequestToken |
consumeImpersonationToken(String token)
Validates tokens generated by
ImpersonationService.generateImpersonationToken(ImpersonationRequest, Authentication) and converts them
into the original ImpersonationRequest supplied before redirect. |
String |
generateImpersonationRedirectUrl(String redirectUrl,
com.nimbusds.jwt.SignedJWT token,
String contextPath)
Generates a URL String containing a serialized signed JWT that should be redirected to in
order to consume an impersonation token.
|
com.nimbusds.jwt.SignedJWT |
generateImpersonationToken(ImpersonationRequest request,
org.springframework.security.core.Authentication authentication)
Generates a JWT to be used during redirects when impersonating a user.
|
protected ImpersonationClaimsEnhancer |
getClaimsEnhancer() |
protected Object |
getDetail(Map<String,Object> details,
String key) |
OAuth2SessionToken |
getImpersonationSessionToken(ImpersonationRequestToken token,
OAuth2UserDetails impersonatedUser)
Creates an
OAuth2SessionToken for the validated ImpersonationRequest . |
protected StatelessUtil |
getStatelessUtil() |
protected static final long IMPERSONATION_TOKEN_EXP_TIME_SEC
public static final String REDIRECT_URI
public static final String CSR_ID
public static final String CSR_CLIENT_ID
public static final String IMPERSONATED_SUB
public static final String IMPERSONATED_CLIENT_ID
public DefaultImpersonationService(ImpersonationClaimsEnhancer claimsEnhancer, StatelessUtil statelessUtil)
public OAuth2SessionToken getImpersonationSessionToken(ImpersonationRequestToken token, OAuth2UserDetails impersonatedUser)
ImpersonationService
OAuth2SessionToken
for the validated ImpersonationRequest
.getImpersonationSessionToken
in interface ImpersonationService
token
- The impersonation requestimpersonatedUser
- The user to be impersonatedOAuth2SessionToken
for the impersonated user with additional CSR
claims.public com.nimbusds.jwt.SignedJWT generateImpersonationToken(ImpersonationRequest request, org.springframework.security.core.Authentication authentication)
ImpersonationService
generateImpersonationToken
in interface ImpersonationService
request
- The impersonation request.authentication
- The current user's authenticationpublic String generateImpersonationRedirectUrl(String redirectUrl, com.nimbusds.jwt.SignedJWT token, String contextPath)
ImpersonationService
generateImpersonationRedirectUrl
in interface ImpersonationService
redirectUrl
- The redirect URL, typically ImpersonationRequest.getRedirect_uri()
token
- The signed JWT, generated from
ImpersonationService.generateImpersonationToken(ImpersonationRequest, Authentication)
contextPath
- The context path of the impersonation requestpublic ImpersonationRequestToken consumeImpersonationToken(String token)
ImpersonationService
ImpersonationService.generateImpersonationToken(ImpersonationRequest, Authentication)
and converts them
into the original ImpersonationRequest
supplied before redirect.consumeImpersonationToken
in interface ImpersonationService
token
- The serialized signed JWT.protected Map<String,Object> buildImpersonationClaims(ImpersonationRequest request, org.springframework.security.core.Authentication authentication)
@NonNull protected ImpersonationClaimsEnhancer getClaimsEnhancer()
@NonNull protected StatelessUtil getStatelessUtil()
Copyright © 2021. All rights reserved.