Class TokenUtils


  • public class TokenUtils
    extends Object
    Author:
    hmlnarik
    • Constructor Summary

      Constructors 
      Constructor Description
      TokenUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.keycloak.TokenVerifier.Predicate<org.keycloak.representations.JsonWebToken> checkThat​(BooleanSupplier function, String errorEvent, String errorMessage)
      Returns a predicate for use in TokenVerifier using the given boolean-returning function.
      static <T extends org.keycloak.representations.JsonWebToken>
      org.keycloak.TokenVerifier.Predicate<T>
      checkThat​(Predicate<T> function, String errorEvent, String errorMessage)
      Returns a predicate for use in TokenVerifier using the given boolean-returning function.
      static <T extends org.keycloak.representations.JsonWebToken>
      org.keycloak.TokenVerifier.Predicate<T>
      onlyIf​(Predicate<T> condition, org.keycloak.TokenVerifier.Predicate<T> predicate)
      Returns a predicate that is applied only if the given condition evaluates to .
      static <T extends org.keycloak.representations.JsonWebToken>
      org.keycloak.TokenVerifier.Predicate<? super T>[]
      predicates​(org.keycloak.TokenVerifier.Predicate<? super T>... predicate)  
    • Constructor Detail

      • TokenUtils

        public TokenUtils()
    • Method Detail

      • checkThat

        public static org.keycloak.TokenVerifier.Predicate<org.keycloak.representations.JsonWebToken> checkThat​(BooleanSupplier function,
                                                                                                                String errorEvent,
                                                                                                                String errorMessage)
        Returns a predicate for use in TokenVerifier using the given boolean-returning function. When the function return false, this predicate throws a ExplainedTokenVerificationException with message and errorEvent set from errorMessage and errorEvent, .
        Parameters:
        function -
        errorEvent -
        errorMessage -
        Returns:
      • checkThat

        public static <T extends org.keycloak.representations.JsonWebToken> org.keycloak.TokenVerifier.Predicate<T> checkThat​(Predicate<T> function,
                                                                                                                              String errorEvent,
                                                                                                                              String errorMessage)
        Returns a predicate for use in TokenVerifier using the given boolean-returning function. When the function return false, this predicate throws a ExplainedTokenVerificationException with message and errorEvent set from errorMessage and errorEvent, .
        Parameters:
        function -
        errorEvent -
        errorMessage -
        Returns:
      • onlyIf

        public static <T extends org.keycloak.representations.JsonWebToken> org.keycloak.TokenVerifier.Predicate<T> onlyIf​(Predicate<T> condition,
                                                                                                                           org.keycloak.TokenVerifier.Predicate<T> predicate)
        Returns a predicate that is applied only if the given condition evaluates to . In case it evaluates to false, the predicate passes.
        Type Parameters:
        T -
        Parameters:
        condition - Condition guarding execution of the predicate
        predicate - Predicate that gets tested if the condition evaluates to true
        Returns:
      • predicates

        public static <T extends org.keycloak.representations.JsonWebToken> org.keycloak.TokenVerifier.Predicate<? super T>[] predicates​(org.keycloak.TokenVerifier.Predicate<? super T>... predicate)