Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;

import com.bettercloud.vault.Vault;
Expand Down Expand Up @@ -314,30 +315,45 @@ private boolean isDir(String key) {
}

protected void lookup(){
log.info("Beginning Vault lookup...");
try {
log.info("Will try to lookup self...");
LookupResponse lookupSelf = getVaultClient().auth().lookupSelf();
Comment on lines +318 to 321
if (lookupSelf.getTTL() <= guaranteedTokenValidity || lookupSelf.getNumUses() < 0) {
loginVault(clientProvider);
}
} catch (VaultException e) {
log.log(Level.WARNING, "Caught VaultException: " + e.getMessage(), e);

if(e.getHttpStatusCode() == 403){//try login again
log.info("Received 403, will try login again");
loginVault(clientProvider);
} else {
log.log(Level.WARNING, "Not a 403 error: " + e.getMessage(), e);
e.printStackTrace();
}
} catch (ConfigurationException e) {
log.log(Level.WARNING, "Caught ConfigurationException: " + e.getMessage(), e);
e.printStackTrace();
} catch (Exception e) {
log.log(Level.WARNING, "Caught Exception: " + e.getMessage(), e);
e.printStackTrace();
Comment on lines 333 to 340
}
log.info("Finished Vault lookup succesfully.");
}
Comment on lines 341 to 343

private void loginVault(VaultClientProvider provider){
log.info("Logging into Vault...");
try{
log.info("Getting Vault Client from provider");
vaultClient = provider.getVaultClient();
log.info("Calling vaultClient logical");
vault = vaultClient.logical();
}
catch (Exception ignored){

catch (Exception e){
log.log(Level.WARNING, "Error logging into Vault: " + e.getMessage(), e);
}
log.info("Logged into Vault successfully");
}
Comment on lines 345 to 357

private boolean isVaultDir(String key) {
Expand Down
Loading