Class WithOpaqueToken.AuthenticationFactory
java.lang.Object
com.c4_soft.springaddons.security.oauth2.test.annotations.WithOpaqueToken.AuthenticationFactory
- All Implemented Interfaces:
org.springframework.security.test.context.support.WithSecurityContextFactory<WithOpaqueToken>
- Enclosing class:
- WithOpaqueToken
public static final class WithOpaqueToken.AuthenticationFactory
extends Object
implements org.springframework.security.test.context.support.WithSecurityContextFactory<WithOpaqueToken>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.core.Authenticationauthentication(WithOpaqueToken annotation) org.springframework.security.core.Authenticationauthentication(Map<String, Object> claims, String bearerString) Stream<org.springframework.security.core.Authentication>authenticationsFrom(String... classpathResources) Build anAuthenticationfor each of the claim-sets provided as classpath resources (JSON file)org.springframework.security.core.context.SecurityContextcreateSecurityContext(WithOpaqueToken annotation) Extracts the claim-set in a JSON fileExtracts the claim-set in a JSON String
-
Constructor Details
-
AuthenticationFactory
public AuthenticationFactory()
-
-
Method Details
-
createSecurityContext
public org.springframework.security.core.context.SecurityContext createSecurityContext(WithOpaqueToken annotation) - Specified by:
createSecurityContextin interfaceorg.springframework.security.test.context.support.WithSecurityContextFactory<WithOpaqueToken>
-
authentication
- Parameters:
annotation- Test annotation with reference to a classpath resource or a JSON string to get claims from (and optional JWT headers and Bearer string)- Returns:
- an
Authenticationinstance built by the opaque token authentication converter in security configuration
-
authentication
public org.springframework.security.core.Authentication authentication(Map<String, Object> claims, String bearerString) - Parameters:
claims- the test user claimsbearerString- the test opaque token Bearer String- Returns:
- an
Authenticationinstance built by the opaque token authentication converter in security configuration
-
authenticationsFrom
public Stream<org.springframework.security.core.Authentication> authenticationsFrom(String... classpathResources) Build anAuthenticationfor each of the claim-sets provided as classpath resources (JSON file)- Parameters:
classpathResources- classpath resources to get user claims from- Returns:
- a stream of
Authenticationinstances built by the opaque token authentication converter in security configuration (using default Bearer String)
-
parseFile
Extracts the claim-set in a JSON file- Parameters:
fileName-- Returns:
-
parseJson
Extracts the claim-set in a JSON String- Parameters:
json-- Returns:
-