Class ECDSAAlgorithm

    • Constructor Detail

      • ECDSAAlgorithm

        ECDSAAlgorithm​(CryptoHelper crypto,
                       java.lang.String id,
                       java.lang.String algorithm,
                       int ecNumberSize,
                       ECDSAKeyProvider keyProvider)
                throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • ECDSAAlgorithm

        ECDSAAlgorithm​(java.lang.String id,
                       java.lang.String algorithm,
                       int ecNumberSize,
                       ECDSAKeyProvider keyProvider)
                throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
    • Method Detail

      • sign

        public byte[] sign​(byte[] headerBytes,
                           byte[] payloadBytes)
                    throws SignatureGenerationException
        Description copied from class: Algorithm
        Sign the given content using this Algorithm instance.
        Overrides:
        sign in class Algorithm
        Parameters:
        headerBytes - an array of bytes representing the base64 encoded header content to be verified against the signature.
        payloadBytes - an array of bytes representing the base64 encoded payload content to be verified against the signature.
        Returns:
        the signature in a base64 encoded array of bytes
        Throws:
        SignatureGenerationException - if the Key is invalid.
      • sign

        @Deprecated
        public byte[] sign​(byte[] contentBytes)
                    throws SignatureGenerationException
        Deprecated.
        Description copied from class: Algorithm
        Sign the given content using this Algorithm instance.
        Specified by:
        sign in class Algorithm
        Parameters:
        contentBytes - an array of bytes representing the base64 encoded content to be verified against the signature.
        Returns:
        the signature in a base64 encoded array of bytes
        Throws:
        SignatureGenerationException - if the Key is invalid.
      • getSigningKeyId

        public java.lang.String getSigningKeyId()
        Description copied from class: Algorithm
        Getter for the Id of the Private Key used to sign the tokens. This is usually specified as the `kid` claim in the Header.
        Overrides:
        getSigningKeyId in class Algorithm
        Returns:
        the Key Id that identifies the Signing Key or null if it's not specified.
      • DERToJOSE

        byte[] DERToJOSE​(byte[] derSignature)
                  throws java.security.SignatureException
        Throws:
        java.security.SignatureException
      • JOSEToDER

        byte[] JOSEToDER​(byte[] joseSignature)
                  throws java.security.SignatureException
        Throws:
        java.security.SignatureException
      • countPadding

        private int countPadding​(byte[] bytes,
                                 int fromIndex,
                                 int toIndex)
      • providerForKeys

        static ECDSAKeyProvider providerForKeys​(java.security.interfaces.ECPublicKey publicKey,
                                                java.security.interfaces.ECPrivateKey privateKey)