Skip to content

Commit 5508eef

Browse files
committed
verified id token stored as message
1 parent c9b0155 commit 5508eef

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/main/java/org/oidc/msg/oidc/AccessTokenResponse.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public class AccessTokenResponse extends org.oidc.msg.oauth2.AccessTokenResponse
5555
private String issuer;
5656
/** Client ID to match the response to. */
5757
private String clientId;
58+
/** Verified id token.*/
59+
private IDToken verifiedIdToken;
5860

5961
{ // Set parameter requirements for message.
6062
paramVerDefs.put("id_token", ParameterVerification.SINGLE_OPTIONAL_JWT.getValue());
@@ -76,6 +78,14 @@ public AccessTokenResponse() {
7678
public AccessTokenResponse(Map<String, Object> claims) {
7779
super(claims);
7880
}
81+
82+
/**
83+
* Get verified id token.
84+
* @return verified id token
85+
*/
86+
public IDToken getVerifiedIdToken() {
87+
return verifiedIdToken;
88+
}
7989

8090
/**
8191
* Set the allowed id token encryption key transport algorithm.
@@ -209,6 +219,7 @@ protected void doVerify() {
209219
getError().getDetails().add(details);
210220
}
211221
}
222+
verifiedIdToken = idToken;
212223
} catch (DeserializationException | JWTDecodeException e) {
213224
getError().getDetails().add(new ErrorDetails("id_token", ErrorType.INVALID_VALUE_FORMAT,
214225
"Unable to verify id token signature", e));

src/main/java/org/oidc/msg/oidc/AuthenticationResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public class AuthenticationResponse extends AuthorizationResponse {
5656
private String encEnc;
5757
/** the allowed id token signing algorithm. */
5858
private String sigAlg;
59+
/** Verified id token. */
60+
private IDToken verifiedIdToken;
5961

6062
{
6163
paramVerDefs.put("access_token", ParameterVerification.SINGLE_OPTIONAL_STRING.getValue());
@@ -90,6 +92,15 @@ public AuthenticationResponse(Map<String, Object> claims) {
9092
super(claims);
9193
}
9294

95+
/**
96+
* Get verified id token.
97+
*
98+
* @return verified id token
99+
*/
100+
public IDToken getVerifiedIdToken() {
101+
return verifiedIdToken;
102+
}
103+
93104
/**
94105
* Set the allowed id token encryption key transport algorithm.
95106
*
@@ -211,6 +222,7 @@ protected void doVerify() {
211222
getError().getDetails().add(details);
212223
}
213224
}
225+
verifiedIdToken = idToken;
214226
} catch (DeserializationException | JWTDecodeException e) {
215227
getError().getDetails().add(new ErrorDetails("id_token", ErrorType.INVALID_VALUE_FORMAT,
216228
"Unable to verify id token signature", e));

src/test/java/org/oidc/msg/oidc/AccessTokenResponseTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public void testValidIdToken() throws InvalidClaimException, IllegalArgumentExce
5454
Assert.assertEquals("mockToken", message.getClaims().get("access_token"));
5555
Assert.assertEquals("mockType", message.getClaims().get("token_type"));
5656
Assert.assertEquals(jwt, message.getClaims().get("id_token"));
57+
Assert.assertNotNull(message.getVerifiedIdToken());
5758
}
5859

5960
@Test
@@ -62,6 +63,7 @@ public void testInvalidIdToken() throws InvalidClaimException {
6263
message.addClaim("token_type", "mockType");
6364
message.addClaim("id_token", "not_jwt");
6465
Assert.assertFalse(message.verify());
66+
Assert.assertNull(message.getVerifiedIdToken());
6567
}
6668

6769
}

src/test/java/org/oidc/msg/oidc/AuthenticationResponseTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public void testSuccessValidIdToken() throws InvalidClaimException, IllegalArgum
108108
Assert.assertTrue(idToken.verify());
109109
// Finally assert we really have the same jwt
110110
Assert.assertEquals(jwt, (String) respParsed.getClaims().get("id_token"));
111+
Assert.assertNotNull(respParsed.getVerifiedIdToken());
111112
}
112113

113114
@Test

0 commit comments

Comments
 (0)