added key id to id token, closes #725

pull/873/head
Justin Richer 10 years ago
parent 0396157543
commit 3513289b00

@ -74,6 +74,8 @@ public interface JwtSigningAndValidationService {
*/
public void signJwt(SignedJWT jwt, JWSAlgorithm alg);
public String getDefaultSignerKeyId();
/**
* TODO: method to sign a jwt using a specified algorithm and a key id
*/

@ -113,6 +113,7 @@ public class DefaultJwtSigningAndValidationService implements JwtSigningAndValid
/**
* @return the defaultSignerKeyId
*/
@Override
public String getDefaultSignerKeyId() {
return defaultSignerKeyId;
}

@ -166,16 +166,21 @@ public class DefaultOIDCTokenService implements OIDCTokenService {
} else {
// signed ID token
idToken = new SignedJWT(new JWSHeader(signingAlg), idClaims);
if (signingAlg.equals(JWSAlgorithm.HS256)
|| signingAlg.equals(JWSAlgorithm.HS384)
|| signingAlg.equals(JWSAlgorithm.HS512)) {
idToken = new SignedJWT(new JWSHeader(signingAlg), idClaims);
JwtSigningAndValidationService signer = symmetricCacheService.getSymmetricValidtor(client);
// sign it with the client's secret
signer.signJwt((SignedJWT) idToken);
} else {
idClaims.setCustomClaim("kid", jwtService.getDefaultSignerKeyId());
idToken = new SignedJWT(new JWSHeader(signingAlg), idClaims);
// sign it with the server's key
jwtService.signJwt((SignedJWT) idToken);

Loading…
Cancel
Save