Skip to main content
Version: 10.2.4

Secrets Vault

ODF 2 provides SecretsVaultService to isolate operations with Secrets Vault.

SecretsVaultService.java ODF 2 interface
package com.workfusion.odf2.core.webharvest.service.vault;

import com.workfusion.bot.service.SecureEntryDTO;

public interface SecretsVaultService {

SecureEntryDTO getEntry(String var1);

boolean saveEntry(String var1, String var2, String var3);

boolean updateEntry(String var1, String var2, String var3);

boolean resetEntry(String var1);

boolean deleteEntry(String var1);
}

To use SecretsVaultService in your Java-based Bot Task, inject it into the constructor and set as the Bot Task's private property.

    private final SecretsVaultService secretsVault;

@Inject
public SomeCustomTask(RpaFactory rpaFactory, SecretsVaultService secretsVault, InvoiceRepository invoiceRepository, Logger logger) {
rpaRunner = rpaFactory.builder(RpaDriver.CHROME)
.closeOnCompletion(true)
.maximizeOnStartup(true)
.startInPrivate(true)
.build();
this.secretsVault = secretsVault;
this.invoiceRepository = invoiceRepository;
this.logger = logger;
}

@Override
public void processBusinessEntities(Collection<Invoice> invoices) {
rpaRunner.execute(driver -> {
InvoicePlaneRobot robot = new InvoicePlaneRobot(driver, secretsVault, logger);
for (Invoice invoice : invoices) {
robot.processInvoice(invoice);
}
});
}

Now, you can pass SecretsVaultService to another class that uses it directly to retrieve Secrets Vault items by an alias.

    public static final String INVOICEPLANE_CREDENTIALS_ALIAS = "robotCredentials";

public InvoicePlaneRobot(Driver driver, SecretsVaultService secretsVault, Logger logger) {
this.driver = Objects.requireNonNull(driver);
this.secretsVault = Objects.requireNonNull(secretsVault);
this.logger = logger;
}

public void processInvoice(Invoice invoice) {
driver.navigate().to(INVOICEPLANE_ADDRESS);
SecureEntryDTO secureEntry = secretsVault.getEntry(INVOICEPLANE_CREDENTIALS_ALIAS);
loginPage.login(secureEntry.getKey(), secureEntry.getValue());
}