Return-Path: Delivered-To: apmail-ws-wss4j-dev-archive@www.apache.org Received: (qmail 19106 invoked from network); 2 Jun 2009 11:25:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Jun 2009 11:25:05 -0000 Received: (qmail 87141 invoked by uid 500); 2 Jun 2009 11:25:17 -0000 Delivered-To: apmail-ws-wss4j-dev-archive@ws.apache.org Received: (qmail 87009 invoked by uid 500); 2 Jun 2009 11:25:17 -0000 Mailing-List: contact wss4j-dev-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list wss4j-dev@ws.apache.org Received: (qmail 87000 invoked by uid 500); 2 Jun 2009 11:25:17 -0000 Delivered-To: apmail-ws-wss4j-cvs@ws.apache.org Received: (qmail 86997 invoked by uid 99); 2 Jun 2009 11:25:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jun 2009 11:25:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jun 2009 11:25:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E341123888A2; Tue, 2 Jun 2009 11:24:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r781003 - /webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java Date: Tue, 02 Jun 2009 11:24:54 -0000 To: wss4j-cvs@ws.apache.org From: coheigea@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090602112454.E341123888A2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: coheigea Date: Tue Jun 2 11:24:54 2009 New Revision: 781003 URL: http://svn.apache.org/viewvc?rev=781003&view=rev Log: [WSS-195] - More detailed exception thrown from CryptoBase.getPrivateKey() - Thanks to Aleksander for the patch, I applied it after some minor changes. Modified: webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java Modified: webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java?rev=781003&r1=781002&r2=781003&view=diff ============================================================================== --- webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java (original) +++ webservices/wss4j/trunk/src/org/apache/ws/security/components/crypto/CryptoBase.java Tue Jun 2 11:24:54 2009 @@ -211,15 +211,38 @@ throw new Exception("The keystore is null"); } if (alias == null || !keystore.isKeyEntry(alias)) { - log.error("Cannot find key for alias: " + alias); - throw new Exception("Cannot find key for alias: " + alias); + String msg = "Cannot find key for alias: [" + alias + "]"; + String logMsg = createKeyStoreErrorMessage(keystore); + log.error(msg + logMsg); + throw new Exception(msg); } Key keyTmp = keystore.getKey(alias, password.toCharArray()); if (!(keyTmp instanceof PrivateKey)) { - throw new Exception("Key is not a private key, alias: " + alias); + String msg = "Key is not a private key, alias: [" + alias + "]"; + String logMsg = createKeyStoreErrorMessage(keystore); + log.error(msg + logMsg); + throw new Exception(msg); } return (PrivateKey) keyTmp; } + + protected static String createKeyStoreErrorMessage(KeyStore keystore) throws KeyStoreException { + Enumeration aliases = keystore.aliases(); + StringBuilder sb = new StringBuilder(keystore.size() * 7); + boolean firstAlias = true; + while (aliases.hasMoreElements()) { + if (!firstAlias) { + sb.append(", "); + } + sb.append(aliases.nextElement()); + firstAlias = false; + } + String msg = " in keystore of type [" + keystore.getType() + + "] from provider [" + keystore.getProvider() + + "] with size [" + keystore.size() + "] and aliases: {" + + sb.toString() + "}"; + return msg; + } protected List splitAndTrim(String inString) { X509NameTokenizer nmTokens = new X509NameTokenizer(inString); --------------------------------------------------------------------- To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org For additional commands, e-mail: wss4j-dev-help@ws.apache.org