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/04/21 16:20:46 UTC

[4/5] cxf git commit: Also cater for null aliases

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/57f74751
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/57f74751
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/57f74751

Branch: refs/heads/master
Commit: 57f74751675a5339e0cacf48a480be994f4ee064
Parents: 4fdb951
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Tue Apr 21 15:18:29 2015 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Tue Apr 21 15:20:29 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/57f74751/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 5495fbc..7cbda36 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
@@ -637,8 +637,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) { 
@@ -689,6 +692,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();