@@ -13,25 +13,25 @@ public class DecodedToken {
1313 private String scopes ;
1414 private String [] groups ;
1515 private String [] roles ;
16- private String [] permissions ;
16+ private String [] permissions ;
1717
18- public DecodedToken () {
19- this .authToken = null ;
20- this .scopes = null ;
21- this .groups = null ;
22- this .roles = null ;
23- this .permissions = null ;
24- }
18+ public DecodedToken () {
19+ this .authToken = null ;
20+ this .scopes = null ;
21+ this .groups = null ;
22+ this .roles = null ;
23+ this .permissions = null ;
24+ }
2525
26- public DecodedToken (HttpServletRequest request ) {
27- helper (request );
28- decodeClaims (this .authToken );
29- }
26+ public DecodedToken (HttpServletRequest request ) {
27+ helper (request );
28+ decodeClaims (this .authToken );
29+ }
3030
31- public DecodedToken (String token ) {
32- this .authToken = token ;
33- decodeClaims (token );
34- }
31+ public DecodedToken (String token ) {
32+ this .authToken = token ;
33+ decodeClaims (token );
34+ }
3535
3636 public String getToken () {
3737 return this .authToken ;
@@ -64,23 +64,23 @@ public void printScopes() {
6464 }
6565
6666 public void printGroups () {
67- System .out .println ("Groups: " + arrayToString (this .groups ));
67+ System .out .println ("Groups: " + arrayToString (this .groups ));
6868 }
6969
7070 public void printRoles () {
71- System .out .println ("Roles: " + arrayToString (this .roles ));
71+ System .out .println ("Roles: " + arrayToString (this .roles ));
7272 }
7373
7474 public void printPermissions () {
75- System .out .println ("Permissions: " + arrayToString (this .permissions ));
75+ System .out .println ("Permissions: " + arrayToString (this .permissions ));
7676 }
7777
7878 public void printUserInfo () {
7979 try {
80- printScopes ();
81- printGroups ();
82- printRoles ();
83- printPermissions ();
80+ printScopes ();
81+ printGroups ();
82+ printRoles ();
83+ printPermissions ();
8484 } catch (Exception e ) {
8585 System .err .println (e .getMessage ());
8686 }
@@ -96,24 +96,24 @@ private void helper(HttpServletRequest request) {
9696 }
9797
9898 private void decodeClaims (String token ) {
99- try {
100- DecodedJWT jwt = JWT .decode (token );
101- this .scopes = jwt .getClaim ("scope" ).asString ();
102- this .groups = jwt .getClaim (namespace + "groups" ).asArray (String .class );
103- this .roles = jwt .getClaim (namespace + "roles" ).asArray (String .class );
104- this .permissions = jwt .getClaim (namespace + "permissions" ).asArray (String .class );
105- } catch (NullPointerException e ) {
106- System .out .println ("Token is null." );
107- } catch (JWTDecodeException e ){
108- System .out .println ("Invalid token." );
109- }
99+ try {
100+ DecodedJWT jwt = JWT .decode (token );
101+ this .scopes = jwt .getClaim ("scope" ).asString ();
102+ this .groups = jwt .getClaim (namespace + "groups" ).asArray (String .class );
103+ this .roles = jwt .getClaim (namespace + "roles" ).asArray (String .class );
104+ this .permissions = jwt .getClaim (namespace + "permissions" ).asArray (String .class );
105+ } catch (NullPointerException e ) {
106+ System .out .println ("Token is null." );
107+ } catch (JWTDecodeException e ){
108+ System .out .println ("Invalid token." );
109+ }
110110 }
111111
112112 private String arrayToString (String [] array ) {
113- StringBuilder sb = new StringBuilder ();
114- for (String str : array ) {
115- sb .append (str ).append (" " );
116- }
117- return sb .toString ().trim ();
113+ StringBuilder sb = new StringBuilder ();
114+ for (String str : array ) {
115+ sb .append (str ).append (" " );
116+ }
117+ return sb .toString ().trim ();
118118 }
119- }
119+ }
0 commit comments