Class WithJwt.AuthenticationFactory
java.lang.Object
com.c4_soft.springaddons.security.oauth2.test.annotations.WithJwt.AuthenticationFactory
- All Implemented Interfaces:
org.springframework.security.test.context.support.WithSecurityContextFactory<WithJwt>
- Enclosing class:
- WithJwt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.authentication.AbstractAuthenticationTokenauthentication(WithJwt annotation) org.springframework.security.authentication.AbstractAuthenticationTokenStream<org.springframework.security.authentication.AbstractAuthenticationToken>authenticationsFrom(String... classpathResources) Build anAuthenticationfor each of the claim-sets provided as classpath resources (JSON file)org.springframework.security.core.context.SecurityContextcreateSecurityContext(WithJwt 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(WithJwt annotation) - Specified by:
createSecurityContextin interfaceorg.springframework.security.test.context.support.WithSecurityContextFactory<WithJwt>
-
authentication
public org.springframework.security.authentication.AbstractAuthenticationToken authentication(WithJwt annotation) - 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 JWT authentication converter in security configuration
-
authentication
public org.springframework.security.authentication.AbstractAuthenticationToken authentication(Map<String, Object> claims, Map<String, Object> headers, String bearerString) - Parameters:
claims- the test JWT claimsheaders- the test JWT headersbearerString- the test JWT Bearer String- Returns:
- an
Authenticationinstance built by the JWT authentication converter in security configuration
-
authenticationsFrom
public Stream<org.springframework.security.authentication.AbstractAuthenticationToken> authenticationsFrom(String... classpathResources) Build anAuthenticationfor each of the claim-sets provided as classpath resources (JSON file)- Parameters:
classpathResources- classpath resources to get JWT claims from- Returns:
- an stream of
Authenticationinstances built by the JWT authentication converter in security configuration (using default JWT headers and 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:
-