Accessing settings in the keystore

(Ivan Brusic) #1

How can properties be read from the keystore from inside a plugin? The only
current usage in the main repo is the s3 repository, but that code is
complex (in terms of the amount of calls) and I rather not have to debug
it. Simply want to read the value.

I am still on 5.x if that matters.



(Ryan Ernst) #2

Are you wanting to read an existing secure setting, or your own plugins setting? If your own, you need to create a SecureSetting instance, return that from getSettings() on your plugin, and then use that Setting object to read the value of the setting from Settings once your plugin is initialized.

(Ivan Brusic) #3

I already found out the answer, but since this mailing list does not send
an email to the sender, I could not reply. Not sure if I can reply to my
original sent email or would that create a new thread.

At first I got it working but creating a KeystoreWrapper and then
decrypting it with an empty password, but I thought that surely that method
cannot be correct. Then I found the SecureString class.

There should be a development mailing list for those that like work on the
coughundocumentedcough internals. :wink:



(Ivan Brusic) #4

Not sure if this is a bug that has been resolved or not, but the keystore
only saves one of the values. Using version 5.5.3

integTestCluster {
keystoreSetting 'foo', 'abc'
keystoreSetting 'bar', 'xyz'
keystoreSetting 'baz', 'qwerty'

public class MyPlugin extends Plugin implements IngestPlugin {

static final Setting<SecureString> FOO =

SecureSetting.secureString("foo", null);
static final Setting BAR =
SecureSetting.secureString("bar", null);
static final Setting BAZ =
SecureSetting.secureString("baz", null);

public Map<String, Processor.Factory>

getProcessors(Processor.Parameters parameters) {
Logger logger = Loggers.getLogger(getClass());

    SecureString foo = FOO.get(parameters.env.settings());
    SecureString bar = BAR.get(parameters.env.settings());
    SecureString baz = BAZ.get(parameters.env.settings());

    logger.warn("all settings {}",

logger.warn("foo: {} for {}", foo, FOO.getKey());
logger.warn("bar: {} for {}", bar, BAR.getKey());
logger.warn("baz: {} for {}", bar, BAZ.getKey());

    return new HashMap<>();

public List<Setting<?>> getSettings() {
    return Arrays.asList(FOO, BAR, BAZ);


foo: qwerty for foo
bar: qwerty for bar
baz: qwerty for baz

integTestCluster {
keystoreSetting 'foo', '1'
keystoreSetting 'bar', '2'
keystoreSetting 'baz', '3'

foo: 3 for foo
bar: 3 for bar
baz: 3 for baz

Hopefully you can comment before I open an issue.



(Ivan Brusic) #5

And just to eliminate gradle issues:

project.afterEvaluate {

[bar:2, foo:1, baz:3]

(Ryan Ernst) #6

I believe this was already fixed. Let me find the issue.

(Ryan Ernst) #7

Here you go, fixed in 5.6.0:

(Ivan Brusic) #8

Looks like I need to ugprade, at least it is not to 6.x. I looked for
"keystore" issues, so this one escaped me. Although it makes sense, that
bug would have taken me a bit to find!

(Ryan Ernst) #9

Groovy is a horrible drug. :slight_smile:

(system) #10

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.