cleaned up spurious nosuchalgorithm exceptions, addresses #285
parent
5f7c46aecd
commit
e2ad4d2e8f
|
@ -55,12 +55,7 @@ public class SignedAuthRequestUrlBuilder implements AuthRequestUrlBuilder {
|
||||||
|
|
||||||
SignedJWT jwt = new SignedJWT(new JWSHeader(signingAndValidationService.getDefaultSigningAlgorithm()), claims);
|
SignedJWT jwt = new SignedJWT(new JWSHeader(signingAndValidationService.getDefaultSigningAlgorithm()), claims);
|
||||||
|
|
||||||
try {
|
|
||||||
signingAndValidationService.signJwt(jwt);
|
signingAndValidationService.signJwt(jwt);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri());
|
URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri());
|
||||||
|
|
|
@ -20,12 +20,13 @@ import java.security.PublicKey;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.nimbusds.jose.JWSAlgorithm;
|
import com.nimbusds.jose.JWSAlgorithm;
|
||||||
|
import com.nimbusds.jose.jwk.JWK;
|
||||||
import com.nimbusds.jwt.SignedJWT;
|
import com.nimbusds.jwt.SignedJWT;
|
||||||
|
|
||||||
public interface JwtSigningAndValidationService {
|
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<String, PublicKey> getAllPublicKeys();
|
public Map<String, PublicKey> getAllPublicKeys();
|
||||||
|
|
||||||
|
@ -48,13 +49,13 @@ public interface JwtSigningAndValidationService {
|
||||||
* @return the signed jwt
|
* @return the signed jwt
|
||||||
* @throws NoSuchAlgorithmException
|
* @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.
|
* Get the default signing algorithm for use when nothing else has been specified.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
JWSAlgorithm getDefaultSigningAlgorithm();
|
public JWSAlgorithm getDefaultSigningAlgorithm();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign a jwt using the selected algorithm. The algorithm is selected using the String parameter values specified
|
* Sign a jwt using the selected algorithm. The algorithm is selected using the String parameter values specified
|
||||||
|
|
|
@ -55,9 +55,6 @@ public class JwtAssertionTokenGranter extends AbstractTokenGranter {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.springframework.security.oauth2.provider.token.AbstractTokenGranter#getOAuth2Authentication(org.springframework.security.oauth2.provider.AuthorizationRequest)
|
* @see org.springframework.security.oauth2.provider.token.AbstractTokenGranter#getOAuth2Authentication(org.springframework.security.oauth2.provider.AuthorizationRequest)
|
||||||
*/
|
*/
|
||||||
/**
|
|
||||||
* @throws NoSuchAlgorithmException
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected OAuth2AccessToken getAccessToken(AuthorizationRequest authorizationRequest) throws AuthenticationException, InvalidTokenException {
|
protected OAuth2AccessToken getAccessToken(AuthorizationRequest authorizationRequest) throws AuthenticationException, InvalidTokenException {
|
||||||
// read and load up the existing token
|
// read and load up the existing token
|
||||||
|
@ -101,15 +98,7 @@ public class JwtAssertionTokenGranter extends AbstractTokenGranter {
|
||||||
|
|
||||||
|
|
||||||
SignedJWT newIdToken = new SignedJWT((JWSHeader) idToken.getHeader(), claims);
|
SignedJWT newIdToken = new SignedJWT((JWSHeader) idToken.getHeader(), claims);
|
||||||
try {
|
|
||||||
jwtService.signJwt(newIdToken);
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
newIdTokenEntity.setJwt(newIdToken);
|
newIdTokenEntity.setJwt(newIdToken);
|
||||||
newIdTokenEntity.setAuthenticationHolder(incomingToken.getAuthenticationHolder());
|
newIdTokenEntity.setAuthenticationHolder(incomingToken.getAuthenticationHolder());
|
||||||
|
|
|
@ -78,12 +78,7 @@ public class ConnectTokenEnhancer implements TokenEnhancer {
|
||||||
|
|
||||||
SignedJWT signed = new SignedJWT(new JWSHeader(jwtService.getDefaultSigningAlgorithm()), claims);
|
SignedJWT signed = new SignedJWT(new JWSHeader(jwtService.getDefaultSigningAlgorithm()), claims);
|
||||||
|
|
||||||
try {
|
|
||||||
jwtService.signJwt(signed);
|
jwtService.signJwt(signed);
|
||||||
} catch (NoSuchAlgorithmException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
token.setJwt(signed);
|
token.setJwt(signed);
|
||||||
|
|
||||||
|
@ -129,13 +124,7 @@ public class ConnectTokenEnhancer implements TokenEnhancer {
|
||||||
|
|
||||||
//TODO: check for client's preferred signer alg and use that
|
//TODO: check for client's preferred signer alg and use that
|
||||||
|
|
||||||
try {
|
|
||||||
jwtService.signJwt(idToken);
|
jwtService.signJwt(idToken);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
idTokenEntity.setJwt(idToken);
|
idTokenEntity.setJwt(idToken);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue