This commit is contained in:
Valentin CZERYBA 2022-04-11 22:38:55 +02:00
parent dd081ae82a
commit 8feb3c5f32
4 changed files with 67 additions and 6 deletions

View File

@ -34,16 +34,14 @@ public class TokenRessource {
@Inject JWTParser parser;
private String secret = "AyM1SysPpbyDfgZld3umj1qzKObwVMko";
@GET
@Path("authentificate/{role}")
@Path("authentificate")
@Produces(MediaType.APPLICATION_JSON)
public Response getUserName(@CookieParam("jwt") String jwtCookie, @PathParam("role") String role) {
public Response getUserName(@CookieParam("jwt") String jwtCookie) {
if (jwtCookie == null) {
// Create a JWT token signed using the 'HS256' algorithm
// String newJwtCookie = Jwt.upn("Alice").groups(new HashSet<>(Arrays.asList("User", "Admin"))).signWithSecret(secret);
String newJwtCookie = Jwt.issuer("https://example.com/issuer").upn("Alice").groups(new HashSet<>(Arrays.asList("User", role))).sign();
String newJwtCookie = Jwt.issuer("https://example.com/issuer").upn("Alice").groups(new HashSet<>(Arrays.asList("User"))).sign();
// or create a JWT token encrypted using the 'A256KW' algorithm
// Jwt.upn("alice").encryptWithSecret(secret);
@ -51,7 +49,6 @@ public class TokenRessource {
} else {
// All mp.jwt and smallrye.jwt properties are still effective, only the verification key is customized.
try {
// jwt = parser.verify(jwtCookie, secret);
jwt = parser.parse(jwtCookie);
}
catch(ParseException p){

View File

@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDpjthUAWnz5l6d
Y5UTjW8zXx4IGwU0BK2HN7oPeZs1LTA6UDbHQtNK3rBlI/ycxFcmbGWm0v5folan
rRoCkpZjbvlddyATc1puVXn8vtKUBuXfJNQL28riSzIp3ifflKEVkwtCvyeLHTWN
XTATKArmQhWEBwQozwqITMhKxHcBfKJOBv3Hwd0S8elnHLyRzzVd60ulDAtV0Glv
09B3/j1DV+5NQU9iBq7I997RX4uVekkk3vjk/71ego5WhRhMTB6WTZ3zySCndkUY
6NNygPcL1i0CVKs8nLpgreTY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d6Ld
SRvki0bGVoz2zwVfK7kc4myZw5tHug8FsKkuZjNlAoGBAPKYRTMsxwLVGmmz4tLg
W4QyEKgtX31f8EqQxJweN6iC+55bNdLVJ8xrs3PTdn5UNq3CLu8kFdvKycmy/Mu3
bz1ZA/fIY3stV4TzqkbKBV8vChgb+0NPxd6QLwa9z8j5zwgpVQDVoRoj/y79WGRW
GGVrsKVMuRatfJ0Q5ZWcMNOp
-----END PRIVATE KEY-----

View File

@ -0,0 +1,9 @@
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6Y7YVAFp8+ZenWOVE41v
M18eCBsFNASthze6D3mbNS0wOlA2x0LTSt6wZSP8nMRXJmxlptL+X6JWp60aApKW
Y275XXcgE3NablV5/L7SlAbl3yTUC9vK4ksyKd4n35ShFZMLQr8nix01jV0wEygK
5kIVhAcEKM8KiEzISsR3AXyiTgb9x8HdEvHpZxy8kc81XetLpQwLVdBpb9PQd/49
Q1fuTUFPYgauyPfe0V+LlXpJJN745P+9XoKOVoUYTEwelk2d88kgp3ZFGOjTcoD3
C9YtAlSrPJy6YK3k2MXjm2P8lw+0pSUBzNIzttFDbejt9dwc2oyPxP29LFIlxGiV
lwIDAQAB
-----END PUBLIC KEY-----

View File

@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA6Y7YVAFp8+ZenWOVE41vM18eCBsFNASthze6D3mbNS0wOlA2
x0LTSt6wZSP8nMRXJmxlptL+X6JWp60aApKWY275XXcgE3NablV5/L7SlAbl3yTU
C9vK4ksyKd4n35ShFZMLQr8nix01jV0wEygK5kIVhAcEKM8KiEzISsR3AXyiTgb9
x8HdEvHpZxy8kc81XetLpQwLVdBpb9PQd/49Q1fuTUFPYgauyPfe0V+LlXpJJN74
5P+9XoKOVoUYTEwelk2d88kgp3ZFGOjTcoD3C9YtAlSrPJy6YK3k2MXjm2P8lw+0
pSUBzNIzttFDbejt9dw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