forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy changes from quarkusio#1490 to the JWT guide
- Loading branch information
Showing
1 changed file
with
12 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -359,21 +359,25 @@ import java.util.Arrays; | |
import java.util.HashSet; | ||
import org.eclipse.microprofile.jwt.Claims; | ||
import io.smallrye.jwt.build.Jwt; | ||
/** | ||
* A utility class to generate and print a JWT token string to stdout. | ||
*/ | ||
public class GenerateToken { | ||
/** | ||
* Generate JWT token | ||
* Generates and prints a JWT token. | ||
*/ | ||
public static void main(String[] args) { | ||
String token = | ||
Jwt.issuer("https://example.com/issuer") // <1> | ||
.upn("[email protected]") // <2> | ||
.groups(new HashSet<>(Arrays.asList("User", "Admin"))) // <3> | ||
.claim(Claims.birthdate.name(), "2001-07-13") // <4> | ||
.sign(); | ||
String token = Jwt.issuer("https://example.com/issuer") | ||
.upn("[email protected]") | ||
.groups(new HashSet<>(Arrays.asList("User", "Admin"))) | ||
.claim(Claims.birthdate.name(), "2001-07-13") | ||
.sign(); | ||
System.out.println(token); | ||
System.exit(0); | ||
} | ||
} | ||
---- | ||
|