Class JwtParser

java.lang.Object
org.openehealth.ipf.commons.ihe.fhir.audit.auth.JwtParser

public class JwtParser extends Object
  • Constructor Details

    • JwtParser

      public JwtParser()
  • Method Details

    • parseAuthorizationToJwtDataSet

      public static Optional<JwtDataSet> parseAuthorizationToJwtDataSet(String authenticationHeader, JwtExtractorProperties jwtExtractorProperties)
      Reads what the audit record is to say about the access token the request carried.

      A token that cannot be looked into is not the same as no token at all: it yields JwtDataSet.opaque(), so that the record can state that a token was presented even though its contents were not visible here. Only a request without a bearer token yields nothing.

      Parameters:
      authenticationHeader - contents of the Authorization header, may be null
      jwtExtractorProperties - where to find the claims
      Returns:
      the claims, an opaque marker, or empty if the request carried no bearer token
    • bearerToken

      public static Optional<String> bearerToken(String authenticationHeader)
      Parameters:
      authenticationHeader - contents of the Authorization header, may be null
      Returns:
      the bearer token it carries, if it carries one
    • parseAuthenticationToJWT

      public static Optional<com.nimbusds.jwt.JWT> parseAuthenticationToJWT(String authenticationHeader)
      Parameters:
      authenticationHeader - contents of the Authorization header, may be null
      Returns:
      the token as a JWT whose claims can be read, or empty when it is not one. An encrypted JWT counts as not one: it parses, but its claims stay sealed without the key, which the audit source does not have -- so it is as opaque here as a reference token.
    • parseJwtToBalpDataSet

      public static JwtDataSet parseJwtToBalpDataSet(com.nimbusds.jwt.JWT jwt, JwtClaimsExtractor claimsExtractor, JwtExtractorProperties jwtExtractorProperties)