io.vertx.ext.jwt

## Class JWK

- java.lang.Object
- - io.vertx.ext.jwt.JWK

- All Implemented Interfaces:
    Crypto

      public final class JWK
      extends Object
      implements Crypto

  JWK https://tools.ietf.org/html/rfc7517 In a nutshell a JWK is a Key(Pair) encoded as JSON. This implementation follows the spec with some limitations: * Supported algorithms are: "RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "HS256", "HS384", "HS512" The rationale for this choice is to support the required algorithms for JWT. The constructor takes a single JWK (the the KeySet) or a PEM encoded pair (used by Google and useful for importing standard PEM files from OpenSSL). * Certificate chains (x5c) only allow a single element chain, certificate urls and fingerprints are not considered.
  Author:
    Paulo Lopes

- - ### Field Summary

    - ### Fields inherited from interface io.vertx.ext.jwt.Crypto

      `ECDSA_ALGORITHMS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JWK(JsonObject json)`
    `JWK(String algorithm, boolean isCertificate, String pemPub, String pemSec)` Creates a Key(Pair) from pem formatted strings.
    `JWK(String algorithm, String hmac)` Creates a Symmetric Key from a base64 encoded string.
    `JWK(String algorithm, String pemPub, String pemSec)` Creates a Key(Pair) from pem formatted strings.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `decrypt(byte[] payload)`
    `byte[]` | `encrypt(byte[] payload)`
    `String` | `getAlgorithm()`
    `String` | `getId()`
    `byte[]` | `sign(byte[] payload)`
    `boolean` | `verify(byte[] expected, byte[] payload)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface io.vertx.ext.jwt.Crypto

      `ECDSALength, isECDSA`

- - ### Constructor Detail

    - #### JWK

          public JWK(String algorithm,
                     String pemPub,
                     String pemSec)

      Creates a Key(Pair) from pem formatted strings.
      Parameters:
        `algorithm` - the algorithm e.g.: RS256
        `pemPub` - the public key in PEM format
        `pemSec` - the private key in PEM format

    - #### JWK

          public JWK(String algorithm,
                     boolean isCertificate,
                     String pemPub,
                     String pemSec)

      Creates a Key(Pair) from pem formatted strings.
      Parameters:
        `algorithm` - the algorithm e.g.: RS256
        `isCertificate` - when true the public PEM is assumed to be a X509 Certificate
        `pemPub` - the public key in PEM format
        `pemSec` - the private key in PEM format

    - #### JWK

          public JWK(String algorithm,
                     String hmac)

      Creates a Symmetric Key from a base64 encoded string.
      Parameters:
        `algorithm` - the algorithm e.g.: HS256
        `hmac` - the symmetric key

    - #### JWK

          public JWK(JsonObject json)

  - ### Method Detail

    - #### getAlgorithm

          public String getAlgorithm()

    - #### getId

          public String getId()

      Specified by:
        `getId` in interface `Crypto`

    - #### encrypt

          public byte[] encrypt(byte[] payload)

    - #### decrypt

          public byte[] decrypt(byte[] payload)

    - #### sign

          public byte[] sign(byte[] payload)

      Specified by:
        `sign` in interface `Crypto`

    - #### verify

          public boolean verify(byte[] expected,
                                byte[] payload)

      Specified by:
        `verify` in interface `Crypto`

Copyright © 2018 Eclipse. All rights reserved.