The JVM SDK currently only supports legacy versions of Nitric prior to v1. This version is maintained for compatibility with existing projects and not recommended for new projects. New projects should be started using a supported SDK (presented automatically using the `nitric new` command) orget in touch to request an update to the latest version.
JVM - secret.version()
Returns a reference to a known version of a secret.
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;
public class Application {
public static void main(String[] args) {
var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);
var keyVersion = secrets.version("the-version-id");
Nitric.INSTANCE.run();
}
}
Parameters
- Name
version
- Required
- Required
- Type
- String
- Description
The version ID. This value is returned from secret.put().
Examples
Return a reference to a known secret version
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;
public class Application {
public static void main(String[] args) {
var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);
var keyVersion = secrets.version("the-version-id");
Nitric.INSTANCE.run();
}
}
Access the value of a known secret version
import io.nitric.Nitric;
import io.nitric.resources.SecretPermission;
public class Application {
public static void main(String[] args) {
var secrets = Nitric.INSTANCE.secret("encryptionKey").with(SecretPermission.Access);
var contents = secrets.version("the-version-id").access();
System.out.println(contents.toString());
Nitric.INSTANCE.run();
}
}