Class JOSEMatcher


  • public class JOSEMatcher
    extends java.lang.Object
    JOSE object / header matcher. May be used to ensure a JOSE object / header matches a set of application-specific criteria.

    Supported matching criteria:

    • Any, one or more JOSE classes (plain, JWS, JWE).
    • Any, one or more algorithms (alg).
    • Any, one or more encryption methods (enc).
    • Any, one or more JWK URLs (jku).
    • Any, one or more JWK IDs (kid).

    Matching by X.509 certificate URL, thumbprint and chain is not supported.

    Version:
    2022-01-24
    Author:
    Vladimir Dzhuvinov
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  JOSEMatcher.Builder
      Builder for constructing JOSE matchers.
    • Constructor Summary

      Constructors 
      Constructor Description
      JOSEMatcher​(java.util.Set<java.lang.Class<? extends JOSEObject>> classes, java.util.Set<Algorithm> algs, java.util.Set<EncryptionMethod> encs, java.util.Set<java.net.URI> jkus, java.util.Set<java.lang.String> kids)
      Creates a new JOSE matcher.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set<Algorithm> getAlgorithms()
      Returns the JOSE algorithms to match.
      java.util.Set<EncryptionMethod> getEncryptionMethods()
      Returns the JOSE encryption methods to match.
      java.util.Set<java.lang.Class<? extends JOSEObject>> getJOSEClasses()
      Returns the JOSE classes to match.
      java.util.Set<java.net.URI> getJWKURLs()
      Returns the JWK URLs to match.
      java.util.Set<java.lang.String> getKeyIDs()
      Returns the key IDs to match.
      boolean matches​(JOSEObject joseObject)
      Returns true if the specified JOSE object matches.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JOSEMatcher

        public JOSEMatcher​(java.util.Set<java.lang.Class<? extends JOSEObject>> classes,
                           java.util.Set<Algorithm> algs,
                           java.util.Set<EncryptionMethod> encs,
                           java.util.Set<java.net.URI> jkus,
                           java.util.Set<java.lang.String> kids)
        Creates a new JOSE matcher.
        Parameters:
        classes - The JOSE classes to match, null if not specified.
        algs - The JOSE algorithms to match, null if not specified.
        encs - The JOSE encryption methods to match, null if not specified.
        jkus - The JWK URLs to match, null if not specified.
        kids - The key IDs to match, null if not specified.
    • Method Detail

      • getJOSEClasses

        public java.util.Set<java.lang.Class<? extends JOSEObject>> getJOSEClasses()
        Returns the JOSE classes to match.
        Returns:
        The JOSE classes, null if not specified.
      • getAlgorithms

        public java.util.Set<Algorithm> getAlgorithms()
        Returns the JOSE algorithms to match.
        Returns:
        The JOSE algorithms, null if not specified.
      • getEncryptionMethods

        public java.util.Set<EncryptionMethod> getEncryptionMethods()
        Returns the JOSE encryption methods to match.
        Returns:
        The JOSE encryption methods, null if not specified.
      • getJWKURLs

        public java.util.Set<java.net.URI> getJWKURLs()
        Returns the JWK URLs to match.
        Returns:
        The JWK URLs, null if not specified.
      • getKeyIDs

        public java.util.Set<java.lang.String> getKeyIDs()
        Returns the key IDs to match.
        Returns:
        The key IDs, null if not specified.
      • matches

        public boolean matches​(JOSEObject joseObject)
        Returns true if the specified JOSE object matches.
        Parameters:
        joseObject - The JOSE object. Must not be null.
        Returns:
        true if the JOSE object matches, else false.