I have this method
public String getCredentials(String entry) throws IOException {
KeePassFile database = KeePassDatabase
.getInstance(config.getProperty("keyPassDataBasePath"))
.openDatabase(new File(config.getProperty("keyPassKeyPath")));
Entry sampleEntry = database.getEntryByTitle(entry);
return sampleEntry.getPassword();
}
Which is basically going to a KeePass DB, retrieves a password according to the title of its belonging account.
There are a LOT of methods that need 2 passwords, so 2 entries are used. I don't want to call that method everytime as I think it's a waste of resources. How can I save the returning value, and use it in other classes where the methods need those values?
Would this work? I feel like it's gonna make the method call several times anyways
private static String pwd1;
private static String pwd2;
public void setValues() throws IOException {
pwd1 = getCredentials("accountName1");
pwd2 = getCredentials("accountName2");
}
public String getPwd1(){
return pwd1;
}
public String getPwd2(){
return pwd2;
}