cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/6] cxf git commit: Allow setting the signature properties directly
Date Fri, 06 Nov 2015 15:14:20 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes dc88f7385 -> b79272c09


Allow setting the signature properties directly


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/52a6c734
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/52a6c734
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/52a6c734

Branch: refs/heads/3.1.x-fixes
Commit: 52a6c7344a89eccca94c92475e0e5651f7867c0a
Parents: dc88f73
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Fri Nov 6 12:19:01 2015 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Fri Nov 6 15:14:02 2015 +0000

----------------------------------------------------------------------
 .../jose/common/KeyManagementUtils.java         |  2 +-
 .../security/jose/jws/JwsCompactProducer.java   | 22 +++++++++++++++-----
 .../cxf/rs/security/jose/jws/JwsUtils.java      |  2 +-
 3 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/52a6c734/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/KeyManagementUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/KeyManagementUtils.java
b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/KeyManagementUtils.java
index bb771a6..a53e7a8 100644
--- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/KeyManagementUtils.java
+++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/common/KeyManagementUtils.java
@@ -311,7 +311,7 @@ public final class KeyManagementUtils {
     }
     public static String getKeyAlgorithm(Message m, Properties props, String propName, String
defaultAlg) {
         String algo = props.getProperty(propName);
-        if (algo == null) {
+        if (algo == null && m != null) {
             algo = (String)m.getContextualProperty(propName);
         }
         if (algo == null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/52a6c734/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactProducer.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactProducer.java
b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactProducer.java
index 8ed3dc6..5fba635 100644
--- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactProducer.java
+++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsCompactProducer.java
@@ -37,6 +37,7 @@ public class JwsCompactProducer {
     private String plainJwsPayload;
     private String signature;
     private boolean detached;
+    private Properties signatureProperties;
     public JwsCompactProducer(String plainJwsPayload) {
         this(plainJwsPayload, false);
     }
@@ -138,12 +139,10 @@ public class JwsCompactProducer {
         return getJwsHeaders().getSignatureAlgorithm();
     }
     private void checkAlgorithm() {
-        if (getAlgorithm() == null && PhaseInterceptorChain.getCurrentMessage() !=
null) {
+        if (getAlgorithm() == null) {
+            Properties sigProps = getSignatureProperties();
             Message m = PhaseInterceptorChain.getCurrentMessage();
-            Properties props = KeyManagementUtils.loadStoreProperties(m, false, 
-                                                                      JoseConstants.RSSEC_SIGNATURE_OUT_PROPS,

-                                                                      JoseConstants.RSSEC_SIGNATURE_PROPS);
-            String signatureAlgo = JwsUtils.getSignatureAlgo(m, props, null, null);
+            String signatureAlgo = JwsUtils.getSignatureAlgo(m, sigProps, null, null);
             if (signatureAlgo != null) {
                 getJwsHeaders().setSignatureAlgorithm(SignatureAlgorithm.getAlgorithm(signatureAlgo));
             }
@@ -153,4 +152,17 @@ public class JwsCompactProducer {
             throw new JwsException(JwsException.Error.INVALID_ALGORITHM);
         }
     }
+    public Properties getSignatureProperties() {
+        if (signatureProperties == null && PhaseInterceptorChain.getCurrentMessage()
!= null) {
+            Message m = PhaseInterceptorChain.getCurrentMessage();
+            signatureProperties = KeyManagementUtils.loadStoreProperties(m, false, 
+                                                                      JoseConstants.RSSEC_SIGNATURE_OUT_PROPS,

+                                                                      JoseConstants.RSSEC_SIGNATURE_PROPS);
+            
+        }
+        return signatureProperties;
+    }
+    public void setSignatureProperties(Properties signatureProperties) {
+        this.signatureProperties = signatureProperties;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/52a6c734/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
index fcebd84..b9f0001 100644
--- a/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
+++ b/rt/rs/security/jose-parent/jose/src/main/java/org/apache/cxf/rs/security/jose/jws/JwsUtils.java
@@ -400,7 +400,7 @@ public final class JwsUtils {
             
             // Check for deprecated identifier first
             String sigAlgo = props.getProperty(JoseConstants.DEPR_RSSEC_SIGNATURE_ALGORITHM);
-            if (sigAlgo == null) {
+            if (sigAlgo == null && m != null) {
                 sigAlgo = (String)m.getContextualProperty(JoseConstants.DEPR_RSSEC_SIGNATURE_ALGORITHM);
             }
             if (sigAlgo != null) {


Mime
View raw message