本文整理汇总了Java中org.springframework.ws.soap.SoapMessage.setDocument方法的典型用法代码示例。如果您正苦于以下问题:Java SoapMessage.setDocument方法的具体用法?Java SoapMessage.setDocument怎么用?Java SoapMessage.setDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.ws.soap.SoapMessage
的用法示例。
在下文中一共展示了SoapMessage.setDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: secureMessage
import org.springframework.ws.soap.SoapMessage; //导入方法依赖的package包/类
@Override
protected void secureMessage(final SoapMessage soapMessage, final MessageContext messageContext) throws WsSecuritySecurementException {
boolean noSecurity = securementActionsVector.isEmpty() || securementActionsVector.contains(0);
if (noSecurity && !enableSignatureConfirmation) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug("Securing message [" + soapMessage + "] with actions [" + securementActions + "]");
}
RequestData requestData = initializeRequestData(messageContext);
requestData.setAttachmentCallbackHandler(new AttachmentCallbackHandler(soapMessage));
Document envelopeAsDocument = soapMessage.getDocument();
try {
// In case on signature confirmation with no other securement
// action, we need to pass an empty securementActionsVector to avoid
// NPE
if (noSecurity) {
securementActionsVector = new ArrayList<Integer>(0);
}
handler.doSenderAction(envelopeAsDocument, requestData, WSSecurityUtil.decodeHandlerAction(securementActions, wssConfig), true);
} catch (WSSecurityException ex) {
throw new Wss4jSecuritySecurementException(ex.getMessage(), ex);
}
soapMessage.setDocument(envelopeAsDocument);
}
示例2: validateMessage
import org.springframework.ws.soap.SoapMessage; //导入方法依赖的package包/类
@Override
protected void validateMessage(final SoapMessage soapMessage, final MessageContext messageContext)
throws WsSecurityValidationException {
if (logger.isDebugEnabled()) {
logger.debug("Validating message [" + soapMessage + "] with actions [" + validationActions + "]");
}
if (validationActionsVector.isEmpty() || validationActionsVector.contains(WSConstants.NO_SECURITY)) {
return;
}
Document envelopeAsDocument = soapMessage.getDocument();
// Header processing
try {
RequestData requestData = new RequestData();
requestData.setAttachmentCallbackHandler(new AttachmentCallbackHandler(soapMessage));
requestData.setWssConfig(wssConfig);
requestData.setSigVerCrypto(validationSignatureCrypto);
requestData.setCallbackHandler(validationCallbackHandler);
requestData.setSubjectCertConstraints(OrgnummerExtractor.PATTERNS);
AlgorithmSuite algorithmSuite = new AlgorithmSuite();
algorithmSuite.addDigestAlgorithm(digestAlgorithm);
algorithmSuite.addSignatureMethod(securementSignatureAlgorithm);
algorithmSuite.addC14nAlgorithm(CanonicalizationMethod.EXCLUSIVE);
//algorithmSuite.addTransformAlgorithm("http://www.w3.org/2001/10/xml-exc-c14n#");
//algorithmSuite.addTransformAlgorithm("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-swa-profile-1.0#Attachment-Complete-Transform");
requestData.setAlgorithmSuite(algorithmSuite);
requestData.setEnableTimestampReplayCache(false);
WSHandlerResult handlerResult = securityEngine.processSecurityHeader(envelopeAsDocument, requestData);
// Results verification
if (handlerResult == null) {
throw new Wss4jSecurityValidationException("No WS-Security header found");
}
updateMessageContextWithCertificate(messageContext, handlerResult);
checkResults(handlerResult.getResults(), validationActionsVector);
validateEbmsMessagingIsSigned(envelopeAsDocument, handlerResult.getResults());
validateTimestampIsSigned(envelopeAsDocument, handlerResult.getResults());
// puts the results in the context
// useful for Signature Confirmation
updateContextWithResults(messageContext, handlerResult);
verifyCertificateTrust(handlerResult);
verifyTimestamp(handlerResult);
} catch (WSSecurityException ex) {
throw new Wss4jSecurityValidationException(ex.getMessage(), ex);
}
soapMessage.setDocument(envelopeAsDocument);
soapMessage.getEnvelope().getHeader().removeHeaderElement(WS_SECURITY_NAME);
}