The Cipher service uses the Automation Orchestrator encryption algorithms to encrypt and decrypt strings. You can use this service when a plug-in stores sensitive data.
Procedure
- Access the service.
- If the plug-in is Spring-enabled:
//Object must be declared in the spring context
public class MyDomainObject {
@Autowired
private ICipher cipherService;
}
- If the plug-in is not Spring-enabled:
public class PluginAdaptor implements IServiceRegistryAdaptor {
private IServiceRegistry registry;
private ICipher cipherService;
@Override
public void setServiceRegistry(IServiceRegistry registry) {
this.registry = registry;
}
public ICipher getCipherService() {
if (cipherService == null) {
cipherService =
registry.getService(IServiceRegistry.CIPHER_SERVICE);
}
return cipherService;
}
}
- Invoke the encrypt and decrypt methods.
public class MyCustomModelClass {
private ICipher cipherService;
//Encrypts a string
cipherService.encrypt("text-to-encrypt");
//Decrypt a vRO encrypted string
cipherService.decrypt("..."); // the string for decryption
}
Note: If the decryption fails, it falls back to the legacy decryption algorithm that is available in earlier versions of
Automation Orchestrator.