cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [4/5] cxf git commit: Also cater for null aliases
Date Tue, 21 Apr 2015 15:06:52 GMT
Also cater for null aliases


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

Branch: refs/heads/3.0.x-fixes
Commit: a12ca523115c572f123727b8e9691da3e713c6fb
Parents: 0391f12
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue Apr 21 15:18:29 2015 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue Apr 21 15:54:03 2015 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/common/util/crypto/CryptoUtils.java   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a12ca523/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java b/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
index ce9bc18..2c22adf 100644
--- a/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/crypto/CryptoUtils.java
@@ -653,8 +653,11 @@ public final class CryptoUtils {
     }
     public static Certificate loadCertificate(KeyStore keyStore, String alias) {
         try {
+            if (alias == null) {
+                throw new SecurityException("No keystore alias was defined");
+            }
             if (!keyStore.containsAlias(alias)) {
-                throw new SecurityException("No alias exists in the keystore for the given
alias: " + alias);
+                throw new SecurityException("No alias exists in the keystore for: " + alias);
             }
             return keyStore.getCertificate(alias);
         } catch (Exception ex) { 
@@ -705,6 +708,12 @@ public final class CryptoUtils {
                                             char[] keyPassword, 
                                             String alias) {
         try {
+            if (alias == null) {
+                throw new SecurityException("No keystore alias was defined");
+            }
+            if (!keyStore.containsAlias(alias)) {
+                throw new SecurityException("No alias exists in the keystore for: " + alias);
+            }
             KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry)
                 keyStore.getEntry(alias, new KeyStore.PasswordProtection(keyPassword));
             return pkEntry.getPrivateKey();


Mime
View raw message