Class ClaimsUtils

java.lang.Object
io.micronaut.security.token.ClaimsUtils

@Internal public final class ClaimsUtils extends Object
Utility class to compare claims.
Since:
4.12.0
Author:
Sergio del Amo
  • Method Details

    • equalsIgnoringProtocolAndTrailingSlash

      public static boolean equalsIgnoringProtocolAndTrailingSlash(@NonNull String expectedClaim, @NonNull String claim)
      Compares an expected (configured) issuer with an issuer claim found in a token requiring an exact match after normalisation. A value that starts with an http:// or https:// scheme (case-insensitive) is normalised by removing the scheme and, when the value has no query (?) and no fragment (#), a single trailing slash; the rest (host, port, userinfo, path, query and fragment) is compared case-sensitively. Any other value is an opaque StringOrURI (RFC 7519, section 2) and is compared verbatim: no case folding and no trailing slash removal, so TenantA and tenanta are different issuers. No suffix or parent-domain matching is performed: an empty claim, a top-level domain, a registrable domain, a parent domain of the expected host or a path-only suffix never matches.

      The scheme tolerance exists for compatibility with micronaut.security.token.jwt.claims-validators.issuer; OpenID Connect ID tokens are compared with IssuerUtils.equivalent(String, String), which requires the scheme.

      Parameters:
      expectedClaim - Expected Claim
      claim - Claim
      Returns:
      Whether the claim is equal to the expected claim after normalisation.
      Since:
      5.5.2
    • endsWithIgnoringProtocolAndTrailingSlash

      @Deprecated(since="5.5.2", forRemoval=true) public static boolean endsWithIgnoringProtocolAndTrailingSlash(@NonNull String expectedClaim, @NonNull String claim)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use equalsIgnoringProtocolAndTrailingSlash(String, String) instead. This method no longer performs a suffix match.
      Compares an expected (configured) issuer with an issuer claim found in a token.
      Parameters:
      expectedClaim - Expected Claim
      claim - Claim
      Returns:
      Whether the claim is equal to the expected claim after normalisation.