Author: coheigea
Date: Wed Nov 13 17:03:39 2013
New Revision: 1541612
URL: http://svn.apache.org/r1541612
Log:
Set the attachment Id on the Callback
Modified:
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
Modified:
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java?rev=1541612&r1=1541611&r2=1541612&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
(original)
+++
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecEncrypt.java
Wed Nov 13 17:03:39 2013
@@ -371,7 +371,7 @@ public class WSSecEncrypt extends WSSecE
for (int part = 0; part < references.size(); part++) {
WSEncryptionPart encPart = references.get(part);
- if ("cid:Attachments".equals(encPart.getId())) {
+ if (encPart.getId() != null && encPart.getId().startsWith("cid:"))
{
continue;
}
@@ -415,7 +415,7 @@ public class WSSecEncrypt extends WSSecE
for (int part = 0; part < references.size(); part++) {
WSEncryptionPart encPart = references.get(part);
- if ("cid:Attachments".equals(encPart.getId())) {
+ if (encPart.getId() != null && encPart.getId().startsWith("cid:"))
{
if (attachmentCallbackHandler == null) {
throw new WSSecurityException(
@@ -425,6 +425,8 @@ public class WSSecEncrypt extends WSSecE
}
AttachmentRequestCallback attachmentRequestCallback = new
AttachmentRequestCallback();
+ String id = encPart.getId().substring(4);
+ attachmentRequestCallback.setAttachmentId(id);
try {
attachmentCallbackHandler.handle(new
Callback[]{attachmentRequestCallback});
} catch (Exception e) {
Modified:
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java?rev=1541612&r1=1541611&r2=1541612&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java
(original)
+++
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/WSSecSignatureBase.java
Wed Nov 13 17:03:39 2013
@@ -102,7 +102,7 @@ public class WSSecSignatureBase extends
List<javax.xml.crypto.dsig.Reference> attachmentReferenceList = new
ArrayList<javax.xml.crypto.dsig.Reference>();
for (WSEncryptionPart encPart : references) {
- if ("cid:Attachments".equals(encPart.getId())) {
+ if (encPart.getId() != null && encPart.getId().startsWith("cid:"))
{
if (attachmentCallbackHandler == null) {
throw new WSSecurityException(
@@ -114,6 +114,8 @@ public class WSSecSignatureBase extends
AttachmentRequestCallback attachmentRequestCallback = new
AttachmentRequestCallback();
//no mime type must be set for signature:
//attachmentCallback.setResultingMimeType(null);
+ String id = encPart.getId().substring(4);
+ attachmentRequestCallback.setAttachmentId(id);
try {
attachmentCallbackHandler.handle(new
Callback[]{attachmentRequestCallback});
} catch (Exception e) {
Modified:
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java?rev=1541612&r1=1541611&r2=1541612&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
(original)
+++
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
Wed Nov 13 17:03:39 2013
@@ -140,12 +140,14 @@ public class EncryptOutputProcessor exte
Map<Object, SecurePart> dynamicSecureParts =
outputProcessorChain.getSecurityContext().getAsMap(XMLSecurityConstants.ENCRYPTION_PARTS);
Iterator<Map.Entry<Object, SecurePart>> securePartsMapIterator =
dynamicSecureParts.entrySet().iterator();
+ String externalId = "";
while (securePartsMapIterator.hasNext()) {
Map.Entry<Object, SecurePart> securePartEntry =
securePartsMapIterator.next();
final SecurePart securePart = securePartEntry.getValue();
final String externalReference = securePart.getExternalReference();
- if (externalReference != null &&
"cid:Attachments".equals(externalReference)) {
+ if (externalReference != null &&
externalReference.startsWith("cid:")) {
attachmentSecurePart = securePart;
+ externalId = externalReference.substring(4);
break;
}
}
@@ -163,6 +165,7 @@ public class EncryptOutputProcessor exte
}
AttachmentRequestCallback attachmentRequestCallback = new
AttachmentRequestCallback();
+ attachmentRequestCallback.setAttachmentId(externalId);
try {
attachmentCallbackHandler.handle(new
Callback[]{attachmentRequestCallback});
} catch (Exception e) {
Modified:
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
URL:
http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java?rev=1541612&r1=1541611&r2=1541612&view=diff
==============================================================================
---
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
(original)
+++
webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
Wed Nov 13 17:03:39 2013
@@ -148,7 +148,7 @@ public class WSSSignatureOutputProcessor
OutputProcessorChain outputProcessorChain, SecurePart securePart)
throws XMLSecurityException, XMLStreamException {
- if ("cid:Attachments".equals(securePart.getExternalReference())) {
+ if (securePart.getExternalReference() != null &&
securePart.getExternalReference().startsWith("cid:")) {
CallbackHandler attachmentCallbackHandler =
((WSSSecurityProperties)
getSecurityProperties()).getAttachmentCallbackHandler();
@@ -160,6 +160,8 @@ public class WSSSignatureOutputProcessor
}
AttachmentRequestCallback attachmentRequestCallback = new
AttachmentRequestCallback();
+ String id = securePart.getExternalReference().substring(4);
+ attachmentRequestCallback.setAttachmentId(id);
try {
attachmentCallbackHandler.handle(new
Callback[]{attachmentRequestCallback});
} catch (Exception e) {