@@ -13,7 +13,7 @@ class KeyParser {
1313 static KeyContainer parse (InputStream stream ) {
1414 JsonObject json = JsonParser .parseReader (new InputStreamReader (stream )).getAsJsonObject ();
1515 JsonElement bodyElement = json .get ("body" );
16- if (bodyElement .isJsonArray ()) { // key/latest response, which will become legacy
16+ if (bodyElement .isJsonArray ()) { // key/latest response, which is now become legacy. We can remove this block once all tests use key/sharing JSON instead
1717 List <Key > keys = new ArrayList <>();
1818 JsonArray body = json .getAsJsonArray ("body" );
1919 for (JsonElement item : body ) {
@@ -34,7 +34,12 @@ static KeyContainer parse(InputStream stream) {
3434 int callerSiteId = getAsInt (body ,"caller_site_id" );
3535 int masterKeysetId = getAsInt (body ,"master_keyset_id" );
3636 int defaultKeysetId = getAsInt (body ,"default_keyset_id" );
37- long tokenExpirySeconds = getAsLong (body ,"token_expiry_seconds" );
37+ long maxBidstreamLifetimeSeconds = getAsLongOrDefault (body , "max_bidstream_lifetime_seconds" , Long .MAX_VALUE );
38+ long maxSharingLifetimeSeconds = getAsLongOrDefault (body , "max_sharing_lifetime_seconds" , Long .MAX_VALUE );
39+ long allowClockSkewSeconds = getAsLongOrDefault (body , "allow_clock_skew_seconds" , 1800 );
40+ IdentityScope identityScope = getAsIdentityScopeOrDefault (body , "identity_scope" , IdentityScope .UID2 );
41+
42+ long tokenExpirySeconds = getAsLongOrDefault (body ,"token_expiry_seconds" , 0 );
3843 if (tokenExpirySeconds == 0 ) {
3944 final short defaultTokenExpiryDays = 30 ;
4045 tokenExpirySeconds = defaultTokenExpiryDays * 24 * 60 * 60 ;
@@ -56,7 +61,7 @@ static KeyContainer parse(InputStream stream) {
5661 keys .add (key );
5762 }
5863
59- return new KeyContainer (callerSiteId , masterKeysetId , defaultKeysetId , tokenExpirySeconds , keys );
64+ return new KeyContainer (callerSiteId , masterKeysetId , defaultKeysetId , tokenExpirySeconds , keys , identityScope , maxBidstreamLifetimeSeconds , maxSharingLifetimeSeconds , allowClockSkewSeconds );
6065 }
6166 }
6267
@@ -65,9 +70,14 @@ static private int getAsInt(JsonObject body, String memberName) {
6570 return isNull (element ) ? 0 : element .getAsInt ();
6671 }
6772
68- static private long getAsLong (JsonObject body , String memberName ) {
73+ static private long getAsLongOrDefault (JsonObject body , String memberName , long defaultVal ) {
74+ JsonElement element = body .get (memberName );
75+ return isNull (element ) ? defaultVal : element .getAsLong ();
76+ }
77+
78+ static private IdentityScope getAsIdentityScopeOrDefault (JsonObject body , String memberName , IdentityScope defaultVal ) {
6979 JsonElement element = body .get (memberName );
70- return isNull (element ) ? 0 : element . getAsLong () ;
80+ return isNull (element ) ? defaultVal : body . get ( "identity_scope" ). getAsString (). equals ( "EUID" ) ? IdentityScope . EUID : IdentityScope . UID2 ;
7181 }
7282
7383 static private boolean isNull (JsonElement jo ) {
0 commit comments