You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2013/01/16 10:13:18 UTC
svn commit: r1433865 -
/karaf/branches/karaf-2.3.x/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiKeystoreManager.java
Author: gnodet
Date: Wed Jan 16 09:13:18 2013
New Revision: 1433865
URL: http://svn.apache.org/viewvc?rev=1433865&view=rev
Log:
[KARAF-2117] Karaf ldap login module is broken
Modified:
karaf/branches/karaf-2.3.x/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiKeystoreManager.java
Modified: karaf/branches/karaf-2.3.x/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiKeystoreManager.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiKeystoreManager.java?rev=1433865&r1=1433864&r2=1433865&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiKeystoreManager.java (original)
+++ karaf/branches/karaf-2.3.x/jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/OsgiKeystoreManager.java Wed Jan 16 09:13:18 2013
@@ -110,14 +110,6 @@ public class OsgiKeystoreManager impleme
return context.getSocketFactory();
}
- private void sleep(long time) {
- try {
- Thread.sleep(time);
- } catch (InterruptedException e) {
-
- }
- }
-
/**
* Purely check for the availability of provided key stores and key
@@ -126,33 +118,34 @@ public class OsgiKeystoreManager impleme
* @param trustStore
* @param timeout
*/
- private boolean checkForKeystoresAvailability( String keyStore, String keyAlias, String trustStore, long timeout ) {
- boolean found = false;
- for (int i = 0 ; i < timeout/1000; ++i) {
+ private boolean checkForKeystoresAvailability( String keyStore, String keyAlias, String trustStore, long timeout ) throws GeneralSecurityException {
+ long start = System.currentTimeMillis();
+ while (true) {
KeystoreInstance keyInstance = getKeystore(keyStore);
- if (keyInstance == null || (keyInstance != null && keyInstance.isKeystoreLocked())) {
- sleep(1000);
- logger.info( "Looking for keystore: {}...", keyStore );
- continue;
- }
- if (keyInstance == null || (keyInstance != null && keyInstance.isKeyLocked(keyAlias))) {
- sleep(1000);
- logger.info( "Looking for keystore's key: {}...", keyAlias );
- continue;
- }
-
KeystoreInstance trustInstance = trustStore == null ? null : getKeystore(trustStore);
- if (trustInstance == null || (trustInstance != null && trustInstance.isKeystoreLocked())) {
- sleep(1000);
- logger.info( "Looking for truststore: {}...", trustStore );
- continue;
+ if (keyStore != null && keyInstance == null) {
+ logger.info( "Keystore {} not found", keyStore );
+ } else if (keyStore != null && keyInstance.isKeystoreLocked()) {
+ logger.info( "Keystore {} locked", keyStore );
+ } else if (keyStore != null && keyAlias != null && keyInstance.isKeyLocked(keyAlias)) {
+ logger.info( "Keystore's key {} locked", keyAlias );
+ } else if (trustStore != null && trustInstance == null) {
+ logger.info( "Truststore {} not found", trustStore );
+ } else if (trustStore != null && trustInstance.isKeystoreLocked()) {
+ logger.info( "Truststore {} locked", keyStore );
+ } else {
+ return true;
+ }
+ if (System.currentTimeMillis() - start < timeout) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ throw new GeneralSecurityException("Interrupted", e);
+ }
+ } else {
+ return false;
}
-
- found = true;
- break;
}
-
- return found;
}
}