Search in sources :

Example 1 with RetryableSecurityException

use of com.emc.storageos.security.exceptions.RetryableSecurityException in project coprhd-controller by CoprHD.

the class KeyStoreUtil method getViPRKeystore.

public static synchronized KeyStore getViPRKeystore(CoordinatorClient coordinator) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, InterruptedException {
    // make keystore singleton.
    if (keyStoreInst != null) {
        return keyStoreInst;
    }
    DistributedLoadKeyStoreParam loadStoreParam = new DistributedLoadKeyStoreParam();
    loadStoreParam.setCoordinator(coordinator);
    KeyStore viprKeyStore = KeyStore.getInstance(SecurityProvider.KEYSTORE_TYPE, new SecurityProvider());
    boolean continueLoading = true;
    int numberOfTries = 0;
    while (continueLoading && numberOfTries < MAX_NUMBER_OF_RETRIES) {
        try {
            viprKeyStore.load(loadStoreParam);
            continueLoading = false;
        } catch (RetryableSecurityException e) {
            numberOfTries++;
            log.info("Could not load keystore, waiting " + TIME_TO_WAIT_IN_MILLIS + " ms. Attempt #" + numberOfTries, e);
            Thread.sleep(TIME_TO_WAIT_IN_MILLIS);
        }
    }
    keyStoreInst = viprKeyStore;
    return viprKeyStore;
}
Also used : RetryableSecurityException(com.emc.storageos.security.exceptions.RetryableSecurityException) KeyStore(java.security.KeyStore)

Aggregations

RetryableSecurityException (com.emc.storageos.security.exceptions.RetryableSecurityException)1 KeyStore (java.security.KeyStore)1