diff --git a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/SignedAuthRequestUrlBuilder.java b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/SignedAuthRequestUrlBuilder.java index 93957b5ad..d9d5efb1a 100644 --- a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/SignedAuthRequestUrlBuilder.java +++ b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/SignedAuthRequestUrlBuilder.java @@ -55,12 +55,7 @@ public class SignedAuthRequestUrlBuilder implements AuthRequestUrlBuilder { SignedJWT jwt = new SignedJWT(new JWSHeader(signingAndValidationService.getDefaultSigningAlgorithm()), claims); - try { - signingAndValidationService.signJwt(jwt); - } catch (NoSuchAlgorithmException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + signingAndValidationService.signJwt(jwt); try { URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); diff --git a/openid-connect-common/src/main/java/org/mitre/jwt/signer/service/JwtSigningAndValidationService.java b/openid-connect-common/src/main/java/org/mitre/jwt/signer/service/JwtSigningAndValidationService.java index 6b8f0bea7..e4b20ae57 100644 --- a/openid-connect-common/src/main/java/org/mitre/jwt/signer/service/JwtSigningAndValidationService.java +++ b/openid-connect-common/src/main/java/org/mitre/jwt/signer/service/JwtSigningAndValidationService.java @@ -20,12 +20,13 @@ import java.security.PublicKey; import java.util.Map; import com.nimbusds.jose.JWSAlgorithm; +import com.nimbusds.jose.jwk.JWK; import com.nimbusds.jwt.SignedJWT; public interface JwtSigningAndValidationService { /** - * Get all public keys for this service, mapped by their ID + * Get all public keys for this service, mapped by their Key ID */ public Map getAllPublicKeys(); @@ -48,13 +49,13 @@ public interface JwtSigningAndValidationService { * @return the signed jwt * @throws NoSuchAlgorithmException */ - public void signJwt(SignedJWT jwt) throws NoSuchAlgorithmException; + public void signJwt(SignedJWT jwt); /** * Get the default signing algorithm for use when nothing else has been specified. * @return */ - JWSAlgorithm getDefaultSigningAlgorithm(); + public JWSAlgorithm getDefaultSigningAlgorithm(); /** * Sign a jwt using the selected algorithm. The algorithm is selected using the String parameter values specified diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/token/JwtAssertionTokenGranter.java b/openid-connect-server/src/main/java/org/mitre/oauth2/token/JwtAssertionTokenGranter.java index 66396624b..edc9d7207 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/token/JwtAssertionTokenGranter.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/token/JwtAssertionTokenGranter.java @@ -55,9 +55,6 @@ public class JwtAssertionTokenGranter extends AbstractTokenGranter { /* (non-Javadoc) * @see org.springframework.security.oauth2.provider.token.AbstractTokenGranter#getOAuth2Authentication(org.springframework.security.oauth2.provider.AuthorizationRequest) */ - /** - * @throws NoSuchAlgorithmException - */ @Override protected OAuth2AccessToken getAccessToken(AuthorizationRequest authorizationRequest) throws AuthenticationException, InvalidTokenException { // read and load up the existing token @@ -101,15 +98,7 @@ public class JwtAssertionTokenGranter extends AbstractTokenGranter { SignedJWT newIdToken = new SignedJWT((JWSHeader) idToken.getHeader(), claims); - try { - jwtService.signJwt(newIdToken); - } catch (NoSuchAlgorithmException e) { - // TODO how to handle this exception? - // Because of the abstract class's method signature, cannot add "throws" - // declaration to this class, but printing a stack trace is not a good - // fallback. - e.printStackTrace(); - } + jwtService.signJwt(newIdToken); newIdTokenEntity.setJwt(newIdToken); newIdTokenEntity.setAuthenticationHolder(incomingToken.getAuthenticationHolder()); diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/token/ConnectTokenEnhancer.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/token/ConnectTokenEnhancer.java index 13f91d310..315c95e43 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/token/ConnectTokenEnhancer.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/token/ConnectTokenEnhancer.java @@ -78,12 +78,7 @@ public class ConnectTokenEnhancer implements TokenEnhancer { SignedJWT signed = new SignedJWT(new JWSHeader(jwtService.getDefaultSigningAlgorithm()), claims); - try { - jwtService.signJwt(signed); - } catch (NoSuchAlgorithmException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } + jwtService.signJwt(signed); token.setJwt(signed); @@ -129,13 +124,7 @@ public class ConnectTokenEnhancer implements TokenEnhancer { //TODO: check for client's preferred signer alg and use that - try { - jwtService.signJwt(idToken); - } catch (NoSuchAlgorithmException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - + jwtService.signJwt(idToken); idTokenEntity.setJwt(idToken);