You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/01/29 17:05:48 UTC
svn commit: r1780826 - in
/axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder:
AsymmetricBindingBuilder.java BindingBuilder.java
Author: veithen
Date: Sun Jan 29 17:05:48 2017
New Revision: 1780826
URL: http://svn.apache.org/viewvc?rev=1780826&view=rev
Log:
RAMPART-287: Apply patch provided by Suresh Attanayake.
Modified:
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder/AsymmetricBindingBuilder.java
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder/BindingBuilder.java
Modified: axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder/AsymmetricBindingBuilder.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder/AsymmetricBindingBuilder.java?rev=1780826&r1=1780825&r2=1780826&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder/AsymmetricBindingBuilder.java (original)
+++ axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder/AsymmetricBindingBuilder.java Sun Jan 29 17:05:48 2017
@@ -284,8 +284,8 @@ public class AsymmetricBindingBuilder ex
+", Signature tool :" + (t2 - t1) );
}
- // Check for signature protection
- if (rpd.isSignatureProtection() && this.mainSigId != null) {
+ // Check for signature protection and encrypted supporting tokens
+ if (rpd.isSignatureProtection() && this.mainSigId != null || !encryptedTokensIdList.isEmpty()) {
long t3 = 0, t4 = 0;
if(tlog.isDebugEnabled()){
t3 = System.currentTimeMillis();
@@ -293,9 +293,10 @@ public class AsymmetricBindingBuilder ex
List<WSEncryptionPart> secondEncrParts = new ArrayList<WSEncryptionPart>();
- // Now encrypt the signature using the above token
- secondEncrParts.add(new WSEncryptionPart(this.mainSigId,
- "Element"));
+ if (rpd.isSignatureProtection() && this.mainSigId != null) {
+ // Now encrypt the signature using the above token
+ secondEncrParts.add(new WSEncryptionPart(this.mainSigId, "Element"));
+ }
if(rmd.isInitiator()) {
for (String anEncryptedTokensIdList : encryptedTokensIdList) {
@@ -303,38 +304,37 @@ public class AsymmetricBindingBuilder ex
}
}
- Element secondRefList = null;
+ if (!secondEncrParts.isEmpty()) {
- if (encryptionToken.isDerivedKeys()) {
- try {
+ Element secondRefList = null;
- secondRefList = dkEncr.encryptForExternalRef(null,
- secondEncrParts);
- RampartUtil.insertSiblingAfter(rmd, encrDKTokenElem,
- secondRefList);
-
- } catch (WSSecurityException e) {
- throw new RampartException("errorCreatingEncryptedKey",
- e);
- }
- } else {
- try {
- // Encrypt, get hold of the ref list and add it
- secondRefList = encr.encryptForExternalRef(null,
- secondEncrParts);
-
- // Insert the ref list after the encrypted key elem
- this.setInsertionLocation(RampartUtil
- .insertSiblingAfter(rmd, encrTokenElement,
- secondRefList));
- } catch (WSSecurityException e) {
- throw new RampartException("errorInEncryption", e);
- }
- }
- if(tlog.isDebugEnabled()){
- t4 = System.currentTimeMillis();
- tlog.debug("Signature protection took :" + (t4 - t3));
- }
+ if (encryptionToken.isDerivedKeys()) {
+ try {
+
+ secondRefList = dkEncr.encryptForExternalRef(null, secondEncrParts);
+ RampartUtil.insertSiblingAfter(rmd, encrDKTokenElem, secondRefList);
+
+ } catch (WSSecurityException e) {
+ throw new RampartException("errorCreatingEncryptedKey", e);
+ }
+ } else {
+ try {
+ // Encrypt, get hold of the ref list and add it
+ secondRefList = encr.encryptForRef(null, secondEncrParts);
+
+ // Insert the ref list after the encrypted key elem
+ this.setInsertionLocation(RampartUtil.insertSiblingAfter(rmd,
+ encrTokenElement, secondRefList));
+ } catch (WSSecurityException e) {
+ throw new RampartException("errorInEncryption", e);
+ }
+ }
+
+ if (tlog.isDebugEnabled()) {
+ t4 = System.currentTimeMillis();
+ tlog.debug("Signature protection took :" + (t4 - t3));
+ }
+ }
}
}
Modified: axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder/BindingBuilder.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder/BindingBuilder.java?rev=1780826&r1=1780825&r2=1780826&view=diff
==============================================================================
--- axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder/BindingBuilder.java (original)
+++ axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/builder/BindingBuilder.java Sun Jan 29 17:05:48 2017
@@ -227,8 +227,8 @@ public abstract class BindingBuilder {
RampartUtil.setEncryptionUser(rmd, encrKey);
//TODO we do not need to pass keysize as it is taken from algorithm it self - verify
- encrKey.setKeyEncAlgo(rpd.getAlgorithmSuite().getAsymmetricKeyWrap());
-
+ encrKey.setKeyEncAlgo(rpd.getAlgorithmSuite().getAsymmetricKeyWrap());
+ encrKey.setSymmetricEncAlgorithm(rpd.getAlgorithmSuite().getEncryption());
encrKey.prepare(doc, RampartUtil.getEncryptionCrypto(rpd.getRampartConfig(), rmd.getCustomClassLoader()));
return encrKey;