Class ClaimsUtils
java.lang.Object
io.micronaut.security.token.ClaimsUtils
Utility class to compare claims.
- Since:
- 4.12.0
- Author:
- Sergio del Amo
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanendsWithIgnoringProtocolAndTrailingSlash(@NonNull String expectedClaim, @NonNull String claim) Deprecated, for removal: This API element is subject to removal in a future version.static booleanequalsIgnoringProtocolAndTrailingSlash(@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.
-
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 anhttp://orhttps://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 opaqueStringOrURI(RFC 7519, section 2) and is compared verbatim: no case folding and no trailing slash removal, soTenantAandtenantaare 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 withIssuerUtils.equivalent(String, String), which requires the scheme.- Parameters:
expectedClaim- Expected Claimclaim- 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.UseequalsIgnoringProtocolAndTrailingSlash(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 Claimclaim- Claim- Returns:
- Whether the claim is equal to the expected claim after normalisation.
-
equalsIgnoringProtocolAndTrailingSlash(String, String)instead.