-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from sberyozkin/generate_token
JWT builder code and tests
- Loading branch information
Showing
29 changed files
with
2,686 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
implementation/src/main/java/io/smallrye/jwt/algorithm/ContentEncryptionAlgorithm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.smallrye.jwt.algorithm; | ||
|
||
/** | ||
* * JWT JSON Web Content Encryption Algorithms. | ||
* | ||
* @see <a href="https://tools.ietf.org/html/rfc7518#section-5">https://tools.ietf.org/html/rfc7518#section-5</a> | ||
*/ | ||
public enum ContentEncryptionAlgorithm { | ||
A256GCM("A256GCM"), | ||
A128CBC_HS256("A128CBC-HS256"); | ||
|
||
private String algorithmName; | ||
|
||
private ContentEncryptionAlgorithm(String algorithmName) { | ||
this.algorithmName = algorithmName; | ||
} | ||
|
||
public String getAlgorithm() { | ||
return algorithmName; | ||
} | ||
|
||
public static ContentEncryptionAlgorithm fromAlgorithm(String algorithmName) { | ||
return ContentEncryptionAlgorithm.valueOf(algorithmName.replaceAll("-", "_").replaceAll("\\+", "_")); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
implementation/src/main/java/io/smallrye/jwt/algorithm/KeyEncryptionAlgorithm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.smallrye.jwt.algorithm; | ||
|
||
/** | ||
* JWT JSON Web Key Encryption (Management) Algorithms. | ||
* | ||
* @see <a href="https://tools.ietf.org/html/rfc7518#section-4">https://tools.ietf.org/html/rfc7518#section-4</a> | ||
*/ | ||
public enum KeyEncryptionAlgorithm { | ||
RSA_OAEP_256("RSA-OAEP-256"), | ||
ECDH_ES_A256KW("ECDH-ES+A256KW"), | ||
A256KW("A256KW"); | ||
|
||
private String algorithmName; | ||
|
||
private KeyEncryptionAlgorithm(String algorithmName) { | ||
this.algorithmName = algorithmName; | ||
} | ||
|
||
public String getAlgorithm() { | ||
return algorithmName; | ||
} | ||
|
||
public static KeyEncryptionAlgorithm fromAlgorithm(String algorithmName) { | ||
return KeyEncryptionAlgorithm.valueOf(algorithmName.replaceAll("-", "_").replaceAll("\\+", "_")); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
implementation/src/main/java/io/smallrye/jwt/algorithm/SignatureAlgorithm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.smallrye.jwt.algorithm; | ||
|
||
/** | ||
* JWT JSON Web Signature Algorithms. | ||
* | ||
* @see <a href="https://tools.ietf.org/html/rfc7518#section-3">https://tools.ietf.org/html/rfc7518#section-3</a> | ||
*/ | ||
public enum SignatureAlgorithm { | ||
RS256, | ||
ES256, | ||
HS256; | ||
|
||
public String getAlgorithm() { | ||
return this.name(); | ||
} | ||
|
||
public static SignatureAlgorithm fromAlgorithm(String algorithmName) { | ||
return SignatureAlgorithm.valueOf(algorithmName); | ||
} | ||
} |
Oops, something went wrong.