@@ -205,6 +205,90 @@ public function testJwtWithNoExpiration()
205205 );
206206 }
207207
208+ public function testParsedClaims ()
209+ {
210+ $ json = '{
211+ "iss" : "https://api.byu.edu",
212+ "exp" : ' . (time () + 10 ) . ',
213+ "http://wso2.org/claims/subscriber" : "BYU/gds2",
214+ "http://wso2.org/claims/applicationid" : "2350",
215+ "http://wso2.org/claims/applicationname" : "dockerlocalhost",
216+ "http://wso2.org/claims/applicationtier" : "Unlimited",
217+ "http://wso2.org/claims/apicontext" : "/domains/byusa/clubs/v1",
218+ "http://wso2.org/claims/version" : "v1",
219+ "http://wso2.org/claims/tier" : "Unlimited",
220+ "http://wso2.org/claims/keytype" : "SANDBOX",
221+ "http://wso2.org/claims/usertype" : "APPLICATION_USER",
222+ "http://wso2.org/claims/enduser" : "[email protected] ", 223+ "http://wso2.org/claims/enduserTenantId" : "-1234",
224+ "http://byu.edu/claims/resourceowner_suffix" : " ",
225+ "http://byu.edu/claims/client_rest_of_name" : "Glen D",
226+ "http://byu.edu/claims/resourceowner_person_id" : "578205422",
227+ "http://byu.edu/claims/resourceowner_byu_id" : "268188640",
228+ "http://wso2.org/claims/client_id" : "PcnfjpwGZUjQVeItRzfWbY8AAw0a",
229+ "http://byu.edu/claims/resourceowner_net_id" : "tave",
230+ "http://byu.edu/claims/resourceowner_surname" : "Sawyer",
231+ "http://byu.edu/claims/client_person_id" : "420206942",
232+ "http://byu.edu/claims/client_sort_name" : "Sawyer, Glen D",
233+ "http://byu.edu/claims/client_claim_source" : "CLIENT_SUBSCRIBER",
234+ "http://byu.edu/claims/client_net_id" : "gds2",
235+ "http://byu.edu/claims/client_subscriber_net_id" : "gds2",
236+ "http://byu.edu/claims/resourceowner_prefix" : " ",
237+ "http://byu.edu/claims/resourceowner_surname_position" : "L",
238+ "http://byu.edu/claims/resourceowner_rest_of_name" : "Octavia Cathryn",
239+ "http://byu.edu/claims/client_name_suffix" : " ",
240+ "http://byu.edu/claims/client_surname" : "Sawyer",
241+ "http://byu.edu/claims/client_name_prefix" : " ",
242+ "http://byu.edu/claims/client_surname_position" : "L",
243+ "http://byu.edu/claims/resourceowner_preferred_first_name" : "Octavia",
244+ "http://byu.edu/claims/client_byu_id" : "617894086",
245+ "http://byu.edu/claims/client_preferred_first_name" : "Glen",
246+ "http://byu.edu/claims/resourceowner_sort_name" : "Sawyer, Octavia Cathryn"
247+ } ' ;
248+ $ data = json_decode ($ json );
249+
250+ $ jwt = JWT ::encode ($ data , static ::$ privateKey , 'RS256 ' );
251+ $ decodedJwt = $ this ->BYUJWT ->decode ($ jwt );
252+
253+ $ this ->assertEquals ("617894086 " , $ decodedJwt ['byu ' ]['client ' ]['byuId ' ]);
254+ $ this ->assertEquals ("CLIENT_SUBSCRIBER " , $ decodedJwt ['byu ' ]['client ' ]['claimSource ' ]);
255+ $ this ->assertEquals ("gds2 " , $ decodedJwt ['byu ' ]['client ' ]['netId ' ]);
256+ $ this ->assertEquals ("420206942 " , $ decodedJwt ['byu ' ]['client ' ]['personId ' ]);
257+ $ this ->assertEquals ("Glen " , $ decodedJwt ['byu ' ]['client ' ]['preferredFirstName ' ]);
258+ $ this ->assertEquals (" " , $ decodedJwt ['byu ' ]['client ' ]['prefix ' ]);
259+ $ this ->assertEquals ("Glen D " , $ decodedJwt ['byu ' ]['client ' ]['restOfName ' ]);
260+ $ this ->assertEquals ("Sawyer, Glen D " , $ decodedJwt ['byu ' ]['client ' ]['sortName ' ]);
261+ $ this ->assertEquals ("gds2 " , $ decodedJwt ['byu ' ]['client ' ]['subscriberNetId ' ]);
262+ $ this ->assertEquals (" " , $ decodedJwt ['byu ' ]['client ' ]['suffix ' ]);
263+ $ this ->assertEquals ("Sawyer " , $ decodedJwt ['byu ' ]['client ' ]['surname ' ]);
264+ $ this ->assertEquals ("L " , $ decodedJwt ['byu ' ]['client ' ]['surnamePosition ' ]);
265+ $ this ->assertEquals ("268188640 " , $ decodedJwt ['byu ' ]['resourceOwner ' ]['byuId ' ]);
266+ $ this ->assertEquals ("tave " , $ decodedJwt ['byu ' ]['resourceOwner ' ]['netId ' ]);
267+ $ this ->assertEquals ("578205422 " , $ decodedJwt ['byu ' ]['resourceOwner ' ]['personId ' ]);
268+ $ this ->assertEquals ("Octavia " , $ decodedJwt ['byu ' ]['resourceOwner ' ]['preferredFirstName ' ]);
269+ $ this ->assertEquals (" " , $ decodedJwt ['byu ' ]['resourceOwner ' ]['prefix ' ]);
270+ $ this ->assertEquals ("Octavia Cathryn " , $ decodedJwt ['byu ' ]['resourceOwner ' ]['restOfName ' ]);
271+ $ this ->assertEquals ("Sawyer, Octavia Cathryn " , $ decodedJwt ['byu ' ]['resourceOwner ' ]['sortName ' ]);
272+ $ this ->assertEquals (" " , $ decodedJwt ['byu ' ]['resourceOwner ' ]['suffix ' ]);
273+ $ this ->assertEquals ("Sawyer " , $ decodedJwt ['byu ' ]['resourceOwner ' ]['surname ' ]);
274+ $ this ->assertEquals ("L " , $ decodedJwt ['byu ' ]['resourceOwner ' ]['surnamePosition ' ]);
275+ $ this ->assertEquals ("268188640 " , $ decodedJwt ['byu ' ]['webresCheck ' ]['byuId ' ]);
276+ $ this ->assertEquals ("tave " , $ decodedJwt ['byu ' ]['webresCheck ' ]['netId ' ]);
277+ $ this ->assertEquals ("578205422 " , $ decodedJwt ['byu ' ]['webresCheck ' ]['personId ' ]);
278+ $ this ->assertEquals ("/domains/byusa/clubs/v1 " , $ decodedJwt ['wso2 ' ]['apiContext ' ]);
279+ $ this ->assertEquals ("2350 " , $ decodedJwt ['wso2 ' ]['application ' ]['id ' ]);
280+ $ this ->assertEquals ("dockerlocalhost " , $ decodedJwt ['wso2 ' ]['application ' ]['name ' ]);
281+ $ this ->assertEquals ("Unlimited " , $ decodedJwt ['wso2 ' ]['application ' ]['tier ' ]);
282+ $ this ->assertEquals ("PcnfjpwGZUjQVeItRzfWbY8AAw0a " , $ decodedJwt ['wso2 ' ]['clientId ' ]);
283+ $ this ->
assertEquals (
"[email protected] " ,
$ decodedJwt[
'wso2 ' ][
'endUser ' ]);
284+ $ this ->assertEquals ("-1234 " , $ decodedJwt ['wso2 ' ]['endUserTenantId ' ]);
285+ $ this ->assertEquals ("SANDBOX " , $ decodedJwt ['wso2 ' ]['keyType ' ]);
286+ $ this ->assertEquals ("BYU/gds2 " , $ decodedJwt ['wso2 ' ]['subscriber ' ]);
287+ $ this ->assertEquals ("Unlimited " , $ decodedJwt ['wso2 ' ]['tier ' ]);
288+ $ this ->assertEquals ("APPLICATION_USER " , $ decodedJwt ['wso2 ' ]['userType ' ]);
289+ $ this ->assertEquals ("v1 " , $ decodedJwt ['wso2 ' ]['version ' ]);
290+ }
291+
208292 public function testRealWellKnown ()
209293 {
210294 //one "live" test to https://api.byu.edu
0 commit comments