Class JWACredentialSupport


  • public final class JWACredentialSupport
    extends Object
    Support class for JSON Web Algorithm credentials.
    • Field Detail

      • LOG

        private static final org.slf4j.Logger LOG
        Logger.
    • Constructor Detail

      • JWACredentialSupport

        private JWACredentialSupport()
        Constructor.
    • Method Detail

      • isECKeyType

        public static boolean isECKeyType​(@Nullable
                                          Key key)
        Returns true of the key is not null and is an EC key.
        Parameters:
        key - the key to test
        Returns:
        true if either a private or public EC key exists
      • keySupportsCurve

        public static boolean keySupportsCurve​(@Nonnull
                                               ECKey key,
                                               @Nonnull @NotEmpty
                                               com.nimbusds.jose.JWSAlgorithm algorithm)
                                        throws com.nimbusds.jose.JOSEException
        Is the EC key supplied compatible with the EC Curve required by the algorithm given.
        Parameters:
        key - the key to check compatibility for
        algorithm - the JWS algorithm to match compatibility against
        Returns:
        true if compatible, false otherwise.
        Throws:
        com.nimbusds.jose.JOSEException - if there is an issue deriving algorithms
      • keySupportsCurve

        public static boolean keySupportsCurve​(@Nonnull
                                               ECKey key,
                                               @Nonnull @NotEmpty
                                               String algorithm)
                                        throws com.nimbusds.jose.JOSEException
        Is the EC key supplied compatible with the EC Curve required by the algorithm given.
        Parameters:
        key - the key to check compatibility for
        algorithm - the string algorithm to match compatibility against
        Returns:
        true if compatible, false otherwise.
        Throws:
        com.nimbusds.jose.JOSEException - if there is an issue deriving algorithms
      • keyLengthSupportsMACAlgorithm

        public static boolean keyLengthSupportsMACAlgorithm​(@Nonnull
                                                            com.nimbusds.jose.JWSAlgorithm macAlg,
                                                            @Nonnull
                                                            Key key)
        Check the key length is compatible with the given JWS algorithm. If not, or the given algorithm is not a MAC algorithm, return false.
        Parameters:
        macAlg - the MAC algorithm to check
        key - the key to check the length of
        Returns:
        true if the algorithm is a MAC algorithm and the key length is compatible with the MAC algorithm, false otherwise.