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

public static final class WithJwt.AuthenticationFactory extends Object implements org.springframework.security.test.context.support.WithSecurityContextFactory<WithJwt>
  • Constructor Details

    • AuthenticationFactory

      public AuthenticationFactory()
  • Method Details

    • createSecurityContext

      public org.springframework.security.core.context.SecurityContext createSecurityContext(WithJwt annotation)
      Specified by:
      createSecurityContext in interface org.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 Authentication instance 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 claims
      headers - the test JWT headers
      bearerString - the test JWT Bearer String
      Returns:
      an Authentication instance built by the JWT authentication converter in security configuration
    • authenticationsFrom

      public Stream<org.springframework.security.authentication.AbstractAuthenticationToken> authenticationsFrom(String... classpathResources)
      Build an Authentication for each of the claim-sets provided as classpath resources (JSON file)
      Parameters:
      classpathResources - classpath resources to get JWT claims from
      Returns:
      an stream of Authentication instances built by the JWT authentication converter in security configuration (using default JWT headers and Bearer String)
    • parseFile

      public static Map<String,Object> parseFile(String fileName)
      Extracts the claim-set in a JSON file
      Parameters:
      fileName -
      Returns:
    • parseJson

      public static Map<String,Object> parseJson(String json)
      Extracts the claim-set in a JSON String
      Parameters:
      json -
      Returns: