Skip to content

Commit d9279dd

Browse files
committed
Increase separation of concerns and coupling between what should go to vertx-core and remain in this module (jwt)
1 parent 957281a commit d9279dd

File tree

7 files changed

+342
-293
lines changed

7 files changed

+342
-293
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package io.vertx.ext.auth.impl.jose;
2+
3+
import io.vertx.ext.auth.impl.jose.algo.SigningAlgorithm;
4+
5+
import java.security.Signature;
6+
import java.security.spec.MGF1ParameterSpec;
7+
import java.security.spec.PSSParameterSpec;
8+
import java.util.concurrent.Callable;
9+
10+
public enum Algorithm {
11+
12+
HS256("HmacSHA256", "1.2.840.113549.2.9", null),
13+
HS384("HmacSHA384", "1.2.840.113549.2.10", null),
14+
HS512("HmacSHA512", "1.2.840.113549.2.11", null),
15+
RS1(null, null, null), // ????
16+
RS256("SHA256withRSA", "1.2.840.113549.1.1.11", () -> Signature.getInstance("SHA256withRSA")),
17+
RS384("SHA384withRSA", "1.2.840.113549.1.1.12", () -> Signature.getInstance("SHA384withRSA")),
18+
RS512("SHA512withRSA", "1.2.840.113549.1.1.13", () -> Signature.getInstance("SHA512withRSA")),
19+
ES256K("SHA256withECDSA", null, () -> Signature.getInstance("SHA256withECDSA")),
20+
ES256("SHA256withECDSA", "1.2.840.10045.4.3.2", () -> Signature.getInstance("SHA256withECDSA")),
21+
ES384("SHA384withECDSA", "1.2.840.10045.4.3.3", () -> Signature.getInstance("SHA384withECDSA")),
22+
ES512("SHA512withECDSA", "1.2.840.10045.4.3.4", () -> Signature.getInstance("SHA512withECDSA")),
23+
24+
PS256("SHA256withRSAandMGF1", "1.2.840.113549.1.1.10", () -> {
25+
Signature sig = Signature.getInstance("RSASSA-PSS");
26+
sig.setParameter(new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, 256 / 8, 1));
27+
return sig;
28+
}),
29+
PS384("SHA384withRSAandMGF1", "1.2.840.113549.1.1.10", () -> {
30+
Signature sig = Signature.getInstance("RSASSA-PSS");
31+
sig.setParameter(new PSSParameterSpec("SHA-384", "MGF1", MGF1ParameterSpec.SHA384, 384 / 8, 1));
32+
return sig;
33+
}),
34+
PS512("SHA512withRSAandMGF1", "1.2.840.113549.1.1.10 ", () -> {
35+
Signature sig = Signature.getInstance("RSASSA-PSS");
36+
sig.setParameter(new PSSParameterSpec("SHA-512", "MGF1", MGF1ParameterSpec.SHA512, 512 / 8, 1));
37+
return sig;
38+
}),
39+
EdDSA(null, null, () -> Signature.getInstance("EdDSA")),
40+
41+
;
42+
43+
public final String jce;
44+
public final String oid;
45+
public final Callable<Signature> signatureProvider;
46+
47+
Algorithm(String jce, String oid, Callable<Signature> signatureProvider) {
48+
this.jce = jce;
49+
this.oid = oid;
50+
this.signatureProvider = signatureProvider;
51+
}
52+
53+
}

0 commit comments

Comments
 (0)