Class EmbeddedOidcProviderStub

java.lang.Object
de.bund.bva.isyfact.security.test.oidcprovider.EmbeddedOidcProviderStub
Direct Known Subclasses:
OidcProviderMockBase

public class EmbeddedOidcProviderStub extends Object
This class simulates the base functions of an OpenID Connect (OIDC) provider for tests in environments in which no dedicated OIDC provider can be used.
  • Field Details

    • DEFAULT_ROLES_CLAIM_NAME

      public static final String DEFAULT_ROLES_CLAIM_NAME
      Default name of the claim to store the user roles in.
      See Also:
    • BHKNZ_CLAIM_NAME

      public static final String BHKNZ_CLAIM_NAME
      Name of the claim to store the BHKNZ in.
      See Also:
  • Constructor Details

    • EmbeddedOidcProviderStub

      public EmbeddedOidcProviderStub(String host, int port, String issuerPath)
    • EmbeddedOidcProviderStub

      public EmbeddedOidcProviderStub(String host, int port, String issuerPath, int tokenLifespan)
    • EmbeddedOidcProviderStub

      public EmbeddedOidcProviderStub(String host, int port, String issuerPath, String publicKey, String privateKey)
    • EmbeddedOidcProviderStub

      public EmbeddedOidcProviderStub(String host, int port, String issuerPath, String publicKey, String privateKey, int tokenLifespan)
    • EmbeddedOidcProviderStub

      public EmbeddedOidcProviderStub(String host, int port, String issuerPath, KeyPair keyPair)
    • EmbeddedOidcProviderStub

      public EmbeddedOidcProviderStub(String host, int port, String issuerPath, KeyPair keyPair, int tokenLifespan)
      Create an OIDC provider stub with the given configuration.
      Parameters:
      host - the host the provider is running on
      port - the port the provider is running on
      issuerPath - the path that is part of the issuer identifier, may be the empty string
      keyPair - RSA key pair to use for signing JWT and to return from the JWKS endpoint
      tokenLifespan - lifespan of the access tokens issued by the provider
  • Method Details

    • setRolesClaimName

      public void setRolesClaimName(String rolesClaimName)
      Sets the claim to store the user roles in. The default is DEFAULT_ROLES_CLAIM_NAME. The value must be set before any access token is generated!
      Parameters:
      rolesClaimName - name of the roles claim
    • getHost

      public String getHost()
    • getPort

      public int getPort()
    • getIssuer

      public URI getIssuer()
    • getPublicKey

      public String getPublicKey()
    • getOIDCConfigResponse

      public String getOIDCConfigResponse(String jwksEndpoint, String authorizationEndpoint, String tokenEndpoint)
      Returns an OIDC Configuration Response with the URIs that point to the other endpoints provided by the mock.
      Parameters:
      jwksEndpoint - path to the JWKS endpoint
      authorizationEndpoint - path to the authorization endpoint
      tokenEndpoint - path to the token endpoint
      Returns:
      JSON representation of the configuration
    • getJwksResponse

      public String getJwksResponse()
    • getAccessTokenResponse

      public String getAccessTokenResponse(String clientId, String userName, Optional<String> bhknz, Set<String> roles)
    • getAccessTokenResponse

      public String getAccessTokenResponse(org.springframework.security.oauth2.jwt.JwtClaimsSet claims)
    • getAccessTokenString

      public String getAccessTokenString(String clientId, String userName, Optional<String> bhknz, Set<String> roles)
    • getAccessTokenString

      public String getAccessTokenString(UUID userId, String clientId, String userName, Optional<String> bhknz, Set<String> roles)
    • getAccessToken

      public org.springframework.security.oauth2.jwt.JwtClaimsSet getAccessToken(UUID userId, String clientId, String userName, Optional<String> bhknz, Set<String> roles)
    • getAccessToken

      public org.springframework.security.oauth2.jwt.JwtClaimsSet getAccessToken(UUID userId, String clientId, String userName, Optional<String> bhknz, Set<String> roles, int newTokenLifespan)
    • getAccessTokenString

      public String getAccessTokenString(org.springframework.security.oauth2.jwt.JwtClaimsSet claims)
    • getJwkSet

      public com.nimbusds.jose.jwk.JWKSet getJwkSet()
    • appendPath

      protected URI appendPath(URI baseUri, String path)