use of com.nimbusds.jose.KeyLengthException in project knox by apache.
the class DefaultTokenAuthorityService method signTokenWithHMAC.
private void signTokenWithHMAC(final JWT token) throws TokenServiceException {
try {
final JWSSigner signer = new MACSigner(getHmacSecret());
token.sign(signer);
} catch (KeyLengthException e) {
throw new TokenServiceException(e);
}
}
use of com.nimbusds.jose.KeyLengthException in project knox by apache.
the class TokenResource method setSignatureAlogrithm.
private void setSignatureAlogrithm() throws AliasServiceException, KeyLengthException {
final String configuredSigAlg = context.getInitParameter(TOKEN_SIG_ALG);
final GatewayConfig config = (GatewayConfig) request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
final GatewayServices services = (GatewayServices) request.getServletContext().getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
AliasService aliasService = services.getService(ServiceType.ALIAS_SERVICE);
signatureAlgorithm = TokenUtils.getSignatureAlgorithm(configuredSigAlg, aliasService, config.getSigningKeystoreName());
char[] hmacSecret = aliasService.getPasswordFromAliasForGateway(TokenUtils.SIGNING_HMAC_SECRET_ALIAS);
if (hmacSecret != null && !isAlgCompatibleWithSecret(signatureAlgorithm, hmacSecret)) {
throw new KeyLengthException(JWSAlgorithm.parse(signatureAlgorithm));
}
}
Aggregations