io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm Maven / Gradle / Ivy
Show all versions of rest-toolkit-utils Show documentation
package io.github.nichetoolkit.rest.worker.jwt;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.fusionauth.jwt.Signer;
import io.fusionauth.jwt.UnsecuredSigner;
import io.fusionauth.jwt.Verifier;
import io.fusionauth.jwt.domain.Algorithm;
import io.fusionauth.jwt.ec.ECSigner;
import io.fusionauth.jwt.ec.ECVerifier;
import io.fusionauth.jwt.hmac.HMACSigner;
import io.fusionauth.jwt.hmac.HMACVerifier;
import io.fusionauth.jwt.rsa.RSAPSSSigner;
import io.fusionauth.jwt.rsa.RSAPSSVerifier;
import io.fusionauth.jwt.rsa.RSASigner;
import io.fusionauth.jwt.rsa.RSAVerifier;
import io.fusionauth.security.CryptoProvider;
import io.github.nichetoolkit.rest.RestValue;
import java.nio.file.Path;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Optional;
/**
* JwtAlgorithm
* The jwt algorithm enumeration.
* @author Cyan ([email protected])
* @see io.github.nichetoolkit.rest.worker.jwt.JwtSigner
* @since Jdk1.8
*/
public enum JwtAlgorithm implements JwtSigner {
/**
* NONE
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The NONE
field.
*/
NONE(0, "none", Algorithm.none) {
@Override
public final Signer signer() {
UnsecuredSigner signer = new UnsecuredSigner();
setSigner(signer);
return signer;
}
},
/**
* ES256
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The ES256
field.
*/
ES256(1, "ES256", Algorithm.ES256) {
@Override
public final Signer signer(String secret) {
ECSigner signer = ECSigner.newSHA256Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
ECSigner signer = ECSigner.newSHA256Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA256Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA256Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey) {
ECSigner signer = ECSigner.newSHA256Signer(privateKey);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid) {
ECSigner signer = ECSigner.newSHA256Signer(privateKey, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA256Signer(privateKey, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA256Signer(privateKey, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
ECVerifier verifier = ECVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey) {
ECVerifier verifier = ECVerifier.newVerifier(publicKey);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
ECVerifier verifier = ECVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
ECVerifier verifier = ECVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(publicKey, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(bytes, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* ES384
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The ES384
field.
*/
ES384(2, "ES384", Algorithm.ES384) {
@Override
public final Signer signer(String secret) {
ECSigner signer = ECSigner.newSHA384Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
ECSigner signer = ECSigner.newSHA384Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA384Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA384Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey) {
ECSigner signer = ECSigner.newSHA384Signer(privateKey);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid) {
ECSigner signer = ECSigner.newSHA384Signer(privateKey, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA384Signer(privateKey, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA384Signer(privateKey, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
ECVerifier verifier = ECVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey) {
ECVerifier verifier = ECVerifier.newVerifier(publicKey);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
ECVerifier verifier = ECVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
ECVerifier verifier = ECVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(publicKey, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(bytes, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* ES512
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The ES512
field.
*/
ES512(3, "ES512", Algorithm.ES512) {
@Override
public final Signer signer(String secret) {
ECSigner signer = ECSigner.newSHA512Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
ECSigner signer = ECSigner.newSHA512Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA512Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA512Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey) {
ECSigner signer = ECSigner.newSHA512Signer(privateKey);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid) {
ECSigner signer = ECSigner.newSHA512Signer(privateKey, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA512Signer(privateKey, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid, CryptoProvider cryptoProvider) {
ECSigner signer = ECSigner.newSHA512Signer(privateKey, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
ECVerifier verifier = ECVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey) {
ECVerifier verifier = ECVerifier.newVerifier(publicKey);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
ECVerifier verifier = ECVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
ECVerifier verifier = ECVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(publicKey, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes, CryptoProvider cryptoProvider) {
ECVerifier verifier = ECVerifier.newVerifier(bytes, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* HS256
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The HS256
field.
*/
HS256(4, "HS256", Algorithm.HS256) {
@Override
public final Signer signer(byte[] secret) {
HMACSigner signer = HMACSigner.newSHA256Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret) {
HMACSigner signer = HMACSigner.newSHA256Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(byte[] secret, String kid) {
HMACSigner signer = HMACSigner.newSHA256Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
HMACSigner signer = HMACSigner.newSHA256Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
HMACSigner signer = HMACSigner.newSHA256Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(byte[] secret, String kid, CryptoProvider cryptoProvider) {
HMACSigner signer = HMACSigner.newSHA256Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
HMACSigner signer = HMACSigner.newSHA256Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
HMACVerifier verifier = HMACVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
HMACVerifier verifier = HMACVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
HMACVerifier verifier = HMACVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
HMACVerifier verifier = HMACVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
HMACVerifier verifier = HMACVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes, CryptoProvider cryptoProvider) {
HMACVerifier verifier = HMACVerifier.newVerifier(bytes, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* HS384
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The HS384
field.
*/
HS384(5, "HS384", Algorithm.HS384) {
@Override
public final Signer signer(byte[] secret) {
HMACSigner signer = HMACSigner.newSHA384Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret) {
HMACSigner signer = HMACSigner.newSHA384Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(byte[] secret, String kid) {
HMACSigner signer = HMACSigner.newSHA384Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
HMACSigner signer = HMACSigner.newSHA384Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
HMACSigner signer = HMACSigner.newSHA384Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(byte[] secret, String kid, CryptoProvider cryptoProvider) {
HMACSigner signer = HMACSigner.newSHA384Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
HMACSigner signer = HMACSigner.newSHA384Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
HMACVerifier verifier = HMACVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
HMACVerifier verifier = HMACVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
HMACVerifier verifier = HMACVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
HMACVerifier verifier = HMACVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
HMACVerifier verifier = HMACVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes, CryptoProvider cryptoProvider) {
HMACVerifier verifier = HMACVerifier.newVerifier(bytes, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* HS512
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The HS512
field.
*/
HS512(6, "HS512", Algorithm.HS512) {
@Override
public final Signer signer(byte[] secret) {
HMACSigner signer = HMACSigner.newSHA512Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret) {
HMACSigner signer = HMACSigner.newSHA512Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(byte[] secret, String kid) {
HMACSigner signer = HMACSigner.newSHA512Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
HMACSigner signer = HMACSigner.newSHA512Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
HMACSigner signer = HMACSigner.newSHA512Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(byte[] secret, String kid, CryptoProvider cryptoProvider) {
HMACSigner signer = HMACSigner.newSHA512Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
HMACSigner signer = HMACSigner.newSHA512Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
HMACVerifier verifier = HMACVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
HMACVerifier verifier = HMACVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
HMACVerifier verifier = HMACVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
HMACVerifier verifier = HMACVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
HMACVerifier verifier = HMACVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes, CryptoProvider cryptoProvider) {
HMACVerifier verifier = HMACVerifier.newVerifier(bytes, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* PS256
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The PS256
field.
*/
PS256(7, "PS256", Algorithm.PS256) {
@Override
public final Signer signer(String secret) {
RSAPSSSigner signer = RSAPSSSigner.newSHA256Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
RSAPSSSigner signer = RSAPSSSigner.newSHA256Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA256Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA256Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey) {
RSAPSSSigner signer = RSAPSSSigner.newSHA256Signer(privateKey);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid) {
RSAPSSSigner signer = RSAPSSSigner.newSHA256Signer(privateKey, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA256Signer(privateKey, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA256Signer(privateKey, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(publicKey);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey, CryptoProvider cryptoProvider) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(publicKey, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* PS384
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The PS384
field.
*/
PS384(8, "PS384", Algorithm.PS384) {
@Override
public final Signer signer(String secret) {
RSAPSSSigner signer = RSAPSSSigner.newSHA384Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
RSAPSSSigner signer = RSAPSSSigner.newSHA384Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA384Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA384Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey) {
RSAPSSSigner signer = RSAPSSSigner.newSHA384Signer(privateKey);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid) {
RSAPSSSigner signer = RSAPSSSigner.newSHA384Signer(privateKey, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA384Signer(privateKey, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA384Signer(privateKey, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(publicKey);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey, CryptoProvider cryptoProvider) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(publicKey, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* PS512
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The PS512
field.
*/
PS512(9, "PS512", Algorithm.PS512) {
@Override
public final Signer signer(String secret) {
RSAPSSSigner signer = RSAPSSSigner.newSHA512Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
RSAPSSSigner signer = RSAPSSSigner.newSHA512Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA512Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA512Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey) {
RSAPSSSigner signer = RSAPSSSigner.newSHA512Signer(privateKey);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid) {
RSAPSSSigner signer = RSAPSSSigner.newSHA512Signer(privateKey, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA512Signer(privateKey, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid, CryptoProvider cryptoProvider) {
RSAPSSSigner signer = RSAPSSSigner.newSHA512Signer(privateKey, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(publicKey);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey, CryptoProvider cryptoProvider) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(publicKey, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
RSAPSSVerifier verifier = RSAPSSVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* RS256
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The RS256
field.
*/
RS256(10, "RS256", Algorithm.RS256) {
@Override
public final Signer signer(String secret) {
RSASigner signer = RSASigner.newSHA256Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
RSASigner signer = RSASigner.newSHA256Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA256Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA256Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey) {
RSASigner signer = RSASigner.newSHA256Signer(privateKey);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid) {
RSASigner signer = RSASigner.newSHA256Signer(privateKey, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA256Signer(privateKey, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA256Signer(privateKey, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
RSAVerifier verifier = RSAVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey) {
RSAVerifier verifier = RSAVerifier.newVerifier(publicKey);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
RSAVerifier verifier = RSAVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
RSAVerifier verifier = RSAVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
RSAVerifier verifier = RSAVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey, CryptoProvider cryptoProvider) {
RSAVerifier verifier = RSAVerifier.newVerifier(publicKey, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
RSAVerifier verifier = RSAVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* RS384
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The RS384
field.
*/
RS384(11, "RS384", Algorithm.RS384) {
@Override
public final Signer signer(String secret) {
RSASigner signer = RSASigner.newSHA384Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
RSASigner signer = RSASigner.newSHA384Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA384Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA384Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey) {
RSASigner signer = RSASigner.newSHA384Signer(privateKey);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid) {
RSASigner signer = RSASigner.newSHA384Signer(privateKey, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA384Signer(privateKey, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA384Signer(privateKey, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
RSAVerifier verifier = RSAVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey) {
RSAVerifier verifier = RSAVerifier.newVerifier(publicKey);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
RSAVerifier verifier = RSAVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
RSAVerifier verifier = RSAVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
RSAVerifier verifier = RSAVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey, CryptoProvider cryptoProvider) {
RSAVerifier verifier = RSAVerifier.newVerifier(publicKey, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
RSAVerifier verifier = RSAVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
/**
* RS512
* {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The RS512
field.
*/
RS512(12, "RS512", Algorithm.RS512) {
@Override
public final Signer signer(String secret) {
RSASigner signer = RSASigner.newSHA512Signer(secret);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid) {
RSASigner signer = RSASigner.newSHA512Signer(secret, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA512Signer(secret, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(String secret, String kid, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA512Signer(secret, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey) {
RSASigner signer = RSASigner.newSHA512Signer(privateKey);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid) {
RSASigner signer = RSASigner.newSHA512Signer(privateKey, kid);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA512Signer(privateKey, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Signer signer(PrivateKey privateKey, String kid, CryptoProvider cryptoProvider) {
RSASigner signer = RSASigner.newSHA512Signer(privateKey, kid, cryptoProvider);
setSigner(signer);
return signer;
}
@Override
public final Verifier verifier(String secret) {
RSAVerifier verifier = RSAVerifier.newVerifier(secret);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey) {
RSAVerifier verifier = RSAVerifier.newVerifier(publicKey);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path) {
RSAVerifier verifier = RSAVerifier.newVerifier(path);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(byte[] bytes) {
RSAVerifier verifier = RSAVerifier.newVerifier(bytes);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(String secret, CryptoProvider cryptoProvider) {
RSAVerifier verifier = RSAVerifier.newVerifier(secret, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(PublicKey publicKey, CryptoProvider cryptoProvider) {
RSAVerifier verifier = RSAVerifier.newVerifier(publicKey, cryptoProvider);
setVerifier(verifier);
return verifier;
}
@Override
public final Verifier verifier(Path path, CryptoProvider cryptoProvider) {
RSAVerifier verifier = RSAVerifier.newVerifier(path, cryptoProvider);
setVerifier(verifier);
return verifier;
}
},
;
/**
* key
* {@link java.lang.Integer} The key
field.
* @see java.lang.Integer
*/
private final Integer key;
/**
* value
* {@link java.lang.String} The value
field.
* @see java.lang.String
*/
private final String value;
/**
* algorithm
* {@link io.fusionauth.jwt.domain.Algorithm} The algorithm
field.
* @see io.fusionauth.jwt.domain.Algorithm
*/
private final Algorithm algorithm;
/**
* signer
* {@link io.fusionauth.jwt.Signer} The signer
field.
* @see io.fusionauth.jwt.Signer
*/
private Signer signer;
/**
* verifier
* {@link io.fusionauth.jwt.Verifier} The verifier
field.
* @see io.fusionauth.jwt.Verifier
*/
private Verifier verifier;
/**
* JwtAlgorithm
* Instantiates a new jwt algorithm.
* @param key {@link java.lang.Integer} The key parameter is Integer
type.
* @param value {@link java.lang.String} The value parameter is String
type.
* @param algorithm {@link io.fusionauth.jwt.domain.Algorithm} The algorithm parameter is Algorithm
type.
* @see java.lang.Integer
* @see java.lang.String
* @see io.fusionauth.jwt.domain.Algorithm
*/
JwtAlgorithm(Integer key, String value, Algorithm algorithm) {
this.key = key;
this.value = value;
this.algorithm = algorithm;
}
@Override
public Integer getKey() {
return this.key;
}
@JsonValue
@Override
public String getValue() {
return this.value;
}
@Override
public Algorithm getAlgorithm() {
return this.algorithm;
}
/**
* setSigner
* The set signer setter method.
* @param signer {@link io.fusionauth.jwt.Signer} The signer parameter is Signer
type.
* @see io.fusionauth.jwt.Signer
*/
protected void setSigner(Signer signer) {
this.signer = signer;
}
/**
* getSigner
* The get signer getter method.
* @return {@link io.fusionauth.jwt.Signer} The get signer return object is Signer
type.
* @see io.fusionauth.jwt.Signer
*/
public final Signer getSigner() {
return signer;
}
/**
* getVerifier
* The get verifier getter method.
* @return {@link io.fusionauth.jwt.Verifier} The get verifier return object is Verifier
type.
* @see io.fusionauth.jwt.Verifier
*/
public final Verifier getVerifier() {
return verifier;
}
/**
* setVerifier
* The set verifier setter method.
* @param verifier {@link io.fusionauth.jwt.Verifier} The verifier parameter is Verifier
type.
* @see io.fusionauth.jwt.Verifier
*/
protected void setVerifier(Verifier verifier) {
this.verifier = verifier;
}
/**
* parseKey
* The parse key method.
* @param key {@link java.lang.Integer} The key parameter is Integer
type.
* @return {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The parse key return object is JwtAlgorithm
type.
* @see java.lang.Integer
*/
public static JwtAlgorithm parseKey(Integer key) {
JwtAlgorithm sortTypeEnum = RestValue.parseKey(JwtAlgorithm.class, key);
return Optional.ofNullable(sortTypeEnum).orElse(JwtAlgorithm.HS256);
}
/**
* parseValue
* The parse value method.
* @param value {@link java.lang.String} The value parameter is String
type.
* @return {@link io.github.nichetoolkit.rest.worker.jwt.JwtAlgorithm} The parse value return object is JwtAlgorithm
type.
* @see java.lang.String
* @see com.fasterxml.jackson.annotation.JsonCreator
*/
@JsonCreator
public static JwtAlgorithm parseValue(String value) {
JwtAlgorithm sortTypeEnum = RestValue.parseValue(JwtAlgorithm.class, value);
return Optional.ofNullable(sortTypeEnum).orElse(JwtAlgorithm.HS256);
}
}