问题描述
我有一个 WCF Web 服务,带有用 C# 编写的 ws-security 策略。 此服务对 X509 证书使用加密和签名策略。
此外,我使用 Apache CXF 用 Java 编写了一个客户端。 我的客户端代码如下:
Notification notification = new NotificationCompat.Builder(this,"channel01")
.setSmallIcon(android.R.drawable.ic_dialog_info)
.setContentTitle("Test")
.setContentText("You see me!")
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_HIGH) // heads-up
.build();
notificationmanagerCompat notificationmanager = notificationmanagerCompat.from(this);
notificationmanager.notify(0,notification);
我已尝试正确设置signatureParts 和encryptionParts。我需要对 Body 和一些 header 属性 进行签名并加密整个正文。我尝试了一些模式,但出现以下错误:
URL wsdlURL = Service.WSDL_LOCATION;
if (args.length > 0 && args[0] != null && !"".equals(args[0])) {
File wsdlFile = new File(args[0]);
try {
if (wsdlFile.exists()) {
wsdlURL = wsdlFile.toURI().toURL();
} else {
wsdlURL = new URL(args[0]);
}
} catch (MalformedURLException e) {
e.printstacktrace();
}
}
Map<String,Object> outProps = new HashMap<String,Object>();
outProps.put("action","Timestamp Signature Encrypt");
outProps.put("passwordType","PasswordDigest");
outProps.put("signatureUser","user1");
outProps.put("passwordCallbackClass","cxfSign.PasswordCallback");
outProps.put("encryptionUser","user2");
outProps.put("encryptionPropFile","Client_Encrypt.properties");
outProps.put("encryptionKeyIssuerSerial","serial");
/* I don't kNow how to set this part */
outProps.put("encryptionParts","???");
outProps.put("signaturePropFile","Client_Sign.properties");
outProps.put("signatureKeyIssuerSerial","serial2");
/* I don't kNow how to set this part */
outProps.put("signatureParts","???");
outProps.put("encryptionKeyTransportAlgorithm","http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p");
outProps.put("signatureAlgorithm","http://www.w3.org/2000/09/xmldsig#rsa-sha1");
Map<String,Object> inProps = new HashMap<String,Object>();
inProps.put("action","Timestamp Signature Encrypt");
inProps.put("passwordType","PasswordText");
inProps.put("passwordCallbackClass","cxfSign.PasswordCallback");
inProps.put("decryptionPropFile","Client_Sign.properties");
inProps.put("encryptionKeyIssuerSerial","7ee54c1e1474ce64429fd47d24bf294c3422b7dd");
inProps.put("signaturePropFile","Client_Encrypt.properties");
inProps.put("signatureKeyIssuerSerial","6f36d23c8d8ad90b62380d465ca70099d4762201");
inProps.put("encryptionKeyTransportAlgorithm","http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p");
inProps.put("signatureAlgorithm","http://www.w3.org/2000/09/xmldsig#rsa-sha1");
DefaultCryptoCoverageChecker coverageChecker = new DefaultCryptoCoverageChecker();
coverageChecker.setSignBody(true);
coverageChecker.setSignTimestamp(true);
coverageChecker.setEncryptBody(true);
Service ss = new Service(wsdlURL,SERVICE_NAME);
IService port = ss.getCustomBindingIService();
Client client = ClientProxy.getClient(port);
client.getininterceptors().add(new WSS4JInInterceptor(inProps));
client.getoutInterceptors().add(new WSS4JOutInterceptor(outProps));
client.getininterceptors().add(coverageChecker);
{
// calling the method
}
有人知道如何解决这个问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)