You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2015/06/18 15:12:57 UTC
[2/3] cxf git commit: [CXF-6464] - Minor refactor of applied patch.
This closes #77
[CXF-6464] - Minor refactor of applied patch. This closes #77
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e9e4d0bf
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e9e4d0bf
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e9e4d0bf
Branch: refs/heads/master
Commit: e9e4d0bf842d4f391d4e223f0d5068ef86d15fa7
Parents: bb0a947
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Thu Jun 18 12:27:29 2015 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Thu Jun 18 14:12:37 2015 +0100
----------------------------------------------------------------------
.../policyhandlers/SymmetricBindingHandler.java | 54 +++++++++-----------
1 file changed, 23 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/e9e4d0bf/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
index 8068e34..6b4c4e8 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
@@ -486,23 +486,11 @@ public class SymmetricBindingHandler extends AbstractBindingBuilder {
Element encrDKTokenElem = null;
encrDKTokenElem = dkEncr.getdktElement();
addDerivedKeyElement(encrDKTokenElem);
+
Element refList = dkEncr.encryptForExternalRef(null, encrParts);
List<Element> attachments = dkEncr.getAttachmentEncryptedDataElements();
- if (atEnd) {
- this.insertBeforeBottomUp(refList);
- if (attachments != null) {
- for (Element attachment : attachments) {
- this.insertBeforeBottomUp(attachment);
- }
- }
- } else {
- this.addDerivedKeyElement(refList);
- if (attachments != null) {
- for (Element attachment : attachments) {
- this.addDerivedKeyElement(attachment);
- }
- }
- }
+ addAttachmentsForEncryption(atEnd, refList, attachments);
+
return dkEncr;
} catch (Exception e) {
LOG.log(Level.FINE, e.getMessage(), e);
@@ -608,21 +596,7 @@ public class SymmetricBindingHandler extends AbstractBindingBuilder {
Element refList = encr.encryptForRef(null, encrParts);
List<Element> attachments = encr.getAttachmentEncryptedDataElements();
- if (atEnd) {
- this.insertBeforeBottomUp(refList);
- if (attachments != null) {
- for (Element attachment : attachments) {
- this.insertBeforeBottomUp(attachment);
- }
- }
- } else {
- this.addDerivedKeyElement(refList);
- if (attachments != null) {
- for (Element attachment : attachments) {
- this.addDerivedKeyElement(attachment);
- }
- }
- }
+ addAttachmentsForEncryption(atEnd, refList, attachments);
return encr;
} catch (WSSecurityException e) {
@@ -632,7 +606,25 @@ public class SymmetricBindingHandler extends AbstractBindingBuilder {
}
}
return null;
- }
+ }
+
+ private void addAttachmentsForEncryption(boolean atEnd, Element refList, List<Element> attachments) {
+ if (atEnd) {
+ this.insertBeforeBottomUp(refList);
+ if (attachments != null) {
+ for (Element attachment : attachments) {
+ this.insertBeforeBottomUp(attachment);
+ }
+ }
+ } else {
+ this.addDerivedKeyElement(refList);
+ if (attachments != null) {
+ for (Element attachment : attachments) {
+ this.addDerivedKeyElement(attachment);
+ }
+ }
+ }
+ }
private byte[] doSignatureDK(List<WSEncryptionPart> sigs,
AbstractTokenWrapper policyAbstractTokenWrapper,