import com.keepersecurity.secretsManager.core.*;
import java.io.FileOutputStream;
public static void main(String[] args){
// get pre-initialized storage
KeyValueStorage storage = new LocalConfigStorage("ksm-config.json");
SecretsManagerOptions options = new SecretsManagerOptions(storage);
// create a filter with the UID of the record we want
List<String> uidFilter = List.of("XXX");
// fetch secrets with the filter
KeeperSecrets secrets = SecretsManager.getSecrets(options, uidFilter);
// get the desired secret from the fetch results
KeeperRecord myCredentials = secrets.getRecords().get(0);
// get a file reference by filename from the record
KeeperFile file = myCredentials.getFileByName("acme.cer");
byte[] fileBytes = SecretsManager.downloadFile(file);
String filename = file.getData().getName();
FileOutputStream fos = new FileOutputStream(filename);
System.out.println("Downloaded File: " + filename);
System.out.println("KSM ran into an problem: " + e.getMessage());