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 2014/04/28 19:42:20 UTC

[1/2] git commit: Avoid a NPE on no Crypto instance

Repository: cxf
Updated Branches:
  refs/heads/master b9a7d7dd2 -> 1b0e2fe2d


Avoid a NPE on no Crypto instance


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

Branch: refs/heads/master
Commit: 099c710c1b83e6dc91ebfde728dd05a445feaee6
Parents: b9a7d7d
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Mon Apr 28 16:36:51 2014 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Mon Apr 28 16:37:12 2014 +0100

----------------------------------------------------------------------
 .../java/org/apache/cxf/rs/security/common/SecurityUtils.java     | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/099c710c/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/SecurityUtils.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/SecurityUtils.java b/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/SecurityUtils.java
index f849bf8..51db0d2 100644
--- a/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/SecurityUtils.java
+++ b/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/SecurityUtils.java
@@ -88,6 +88,9 @@ public final class SecurityUtils {
     
     public static X509Certificate[] getCertificates(Crypto crypto, String user)
         throws Exception {
+        if (crypto == null) {
+            throw new Exception("Crypto instance is null");
+        }
         CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
         cryptoType.setAlias(user);
         X509Certificate[] issuerCerts = crypto.getX509Certificates(cryptoType);


[2/2] git commit: Minor change

Posted by co...@apache.org.
Minor change


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

Branch: refs/heads/master
Commit: 1b0e2fe2d41956f2a5936be6e58da5fa9792213b
Parents: 099c710
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Mon Apr 28 18:42:04 2014 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Mon Apr 28 18:42:04 2014 +0100

----------------------------------------------------------------------
 .../policy/interceptors/NegotiationUtils.java   | 28 +++++++++++++++-----
 1 file changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1b0e2fe2/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
----------------------------------------------------------------------
diff --git a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
index 71c7b35..be7c05b 100644
--- a/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
+++ b/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
@@ -81,19 +81,19 @@ final class NegotiationUtils {
     }
 
     static Trust10 getTrust10(AssertionInfoMap aim) {
-        Collection<AssertionInfo> ais = getAllAssertionsByLocalname(aim, SPConstants.TRUST_10);
-        if (ais.isEmpty()) {
+        AssertionInfo ai = getFirstAssertionByLocalname(aim, SPConstants.TRUST_10);
+        if (ai == null) {
             return null;
         }
-        return (Trust10)ais.iterator().next().getAssertion();
+        return (Trust10)ai.getAssertion();
     }
     
     static Trust13 getTrust13(AssertionInfoMap aim) {
-        Collection<AssertionInfo> ais = getAllAssertionsByLocalname(aim, SPConstants.TRUST_13);
-        if (ais.isEmpty()) {
+        AssertionInfo ai = getFirstAssertionByLocalname(aim, SPConstants.TRUST_13);
+        if (ai == null) {
             return null;
         }
-        return (Trust13)ais.iterator().next().getAssertion();
+        return (Trust13)ai.getAssertion();
     }
     
     static TokenStore getTokenStore(Message message) {
@@ -331,6 +331,22 @@ final class NegotiationUtils {
         return Collections.emptySet();
     }
     
+    static AssertionInfo getFirstAssertionByLocalname(
+        AssertionInfoMap aim, String localname
+    ) {
+        Collection<AssertionInfo> sp11Ais = aim.get(new QName(SP11Constants.SP_NS, localname));
+        if (sp11Ais != null && !sp11Ais.isEmpty()) {
+            return sp11Ais.iterator().next();
+        }
+
+        Collection<AssertionInfo> sp12Ais = aim.get(new QName(SP12Constants.SP_NS, localname));
+        if (sp12Ais != null && !sp12Ais.isEmpty()) {
+            return sp12Ais.iterator().next();
+        }
+
+        return null;
+    }
+    
     static boolean isThereAnAssertionByLocalname(
         AssertionInfoMap aim,
         String localname