use of org.apache.cxf.rs.security.httpsignature.provider.KeyProvider in project cxf by apache.
the class AbstractSignatureOutFilter method createMessageSigner.
private MessageSigner createMessageSigner() {
Properties props = KeyManagementUtils.loadSignatureOutProperties();
if (props == null) {
throw new SignatureException("Signature properties are not configured correctly");
}
Message m = PhaseInterceptorChain.getCurrentMessage();
KeyProvider keyProvider = keyId -> KeyManagementUtils.loadPrivateKey(m, props);
String signatureAlgorithm = (String) m.getContextualProperty(HTTPSignatureConstants.RSSEC_SIGNATURE_ALGORITHM);
if (signatureAlgorithm == null) {
signatureAlgorithm = DefaultSignatureConstants.SIGNING_ALGORITHM;
}
String keyId = (String) m.getContextualProperty(HTTPSignatureConstants.RSSEC_HTTP_SIGNATURE_KEY_ID);
if (keyId == null) {
keyId = props.getProperty(HTTPSignatureConstants.RSSEC_HTTP_SIGNATURE_KEY_ID);
if (keyId == null) {
throw new SignatureException("The signature key id is a required configuration property");
}
}
List<String> signedHeaders = CastUtils.cast((List<?>) m.getContextualProperty(HTTPSignatureConstants.RSSEC_HTTP_SIGNATURE_OUT_HEADERS));
if (signedHeaders == null) {
signedHeaders = Collections.emptyList();
}
return new MessageSigner(signatureAlgorithm, keyProvider, keyId, signedHeaders);
}
Aggregations