Java Code Examples for io.jsonwebtoken.SignatureAlgorithm#ES256

The following examples show how to use io.jsonwebtoken.SignatureAlgorithm#ES256 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JwtHelper.java    From hono with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Sets the path to a PKCS8 PEM file containing the RSA private key to use for signing tokens asserting the
 * registration status of devices.
 *
 * @param keyPath The absolute path to the file.
 * @throws NullPointerException if the path is {@code null}.
 * @throws IllegalArgumentException if the key cannot be read from the file.
 */
protected final void setPrivateKey(final String keyPath) {
    Objects.requireNonNull(keyPath);
    key = KeyLoader.fromFiles(vertx, keyPath, null).getPrivateKey();
    if (key == null) {
        throw new IllegalArgumentException("cannot load private key: " + keyPath);
    } else if (key instanceof ECKey) {
        algorithm = SignatureAlgorithm.ES256;
    } else if (key instanceof RSAKey) {
        algorithm = SignatureAlgorithm.RS256;
    } else {
        throw new IllegalArgumentException("unsupported private key type: " + key.getClass());
    }
}
 
Example 2
Source File: JwtHelper.java    From hono with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Sets the path to a PEM file containing a certificate holding a public key to use for validating the signature of
 * tokens asserting the registration status of devices.
 *
 * @param keyPath The absolute path to the file.
 * @throws NullPointerException if the path is {@code null}.
 * @throws IllegalArgumentException if the key cannot be read from the file.
 */
protected final void setPublicKey(final String keyPath) {
    Objects.requireNonNull(keyPath);
    key = KeyLoader.fromFiles(vertx, null, keyPath).getPublicKey();
    if (key == null) {
        throw new IllegalArgumentException("cannot load public key: " + keyPath);
    } else if (key instanceof ECKey) {
        algorithm = SignatureAlgorithm.ES256;
    } else if (key instanceof RSAKey) {
        algorithm = SignatureAlgorithm.RS256;
    } else {
        throw new IllegalArgumentException("unsupported public key type: " + key.getClass());
    }
}
 
Example 3
Source File: ServerPrivateKey.java    From athenz with Apache License 2.0 5 votes vote down vote up
public ServerPrivateKey(final PrivateKey key, final String id) {

        this.key = key;
        this.id = id;

        algorithm = ECDSA.equalsIgnoreCase(key.getAlgorithm()) ?
                SignatureAlgorithm.ES256 : SignatureAlgorithm.RS256;
    }