use of com.nimbusds.oauth2.sdk.auth.verifier.ClientCredentialsSelector in project di-authentication-api by alphagov.
the class TokenService method generateClientCredentialsSelector.
private ClientCredentialsSelector<?> generateClientCredentialsSelector(String publicKey) {
return new ClientCredentialsSelector<>() {
@Override
public List<Secret> selectClientSecrets(ClientID claimedClientID, ClientAuthenticationMethod authMethod, com.nimbusds.oauth2.sdk.auth.verifier.Context context) {
return null;
}
@Override
public List<PublicKey> selectPublicKeys(ClientID claimedClientID, ClientAuthenticationMethod authMethod, JWSHeader jwsHeader, boolean forceRefresh, com.nimbusds.oauth2.sdk.auth.verifier.Context context) {
byte[] decodedKey = Base64.getMimeDecoder().decode(publicKey);
try {
X509EncodedKeySpec x509publicKey = new X509EncodedKeySpec(decodedKey);
KeyFactory kf = KeyFactory.getInstance("RSA");
return Collections.singletonList(kf.generatePublic(x509publicKey));
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
};
}
Aggregations