Storage converters can modify file contents and metadata uploaded to the Key Storage via the Key Storage API.
When installed, Storage Converter plugins can be configured to apply to all storage requests for a certain Path, or matching a certain metadata selector. This lets you apply plugins to only a subset of storage requests.
A typical example is to apply some form of encryption to the Key Storage stored under the /keys
path. In this case you can also have the plugin apply only to Private keys, by using the metadata selector.
See: Configuring the Storage Converter Plugin.
The plugin interface is StorageConverterPlugin.
The service name is StorageConverter
.
import com.dtolabs.rundeck.core.plugins.Plugin;
import com.dtolabs.rundeck.core.storage.ResourceMetaBuilder;
import com.dtolabs.rundeck.plugins.ServiceNameConstants;
import com.dtolabs.rundeck.plugins.storage.StorageConverterPlugin;
import org.rundeck.storage.api.HasInputStream;
import org.rundeck.storage.api.Path;
@Plugin(name="myprovider", service=ServiceNameConstants.StorageConverter)
public class MyProvider implements StorageConverterPlugin {
/** read the stored data, decrypt if necessary */
HasInputStream readResource(Path path, ResourceMetaBuilder
resourceMetaBuilder, HasInputStream hasInputStream){
return null;
}
/** encrypt data to be stored if necessary */
HasInputStream createResource(Path path, ResourceMetaBuilder
resourceMetaBuilder, HasInputStream hasInputStream){
return null;
}
/** encrypt data to be stored if necessary */
HasInputStream updateResource(Path path, ResourceMetaBuilder
resourceMetaBuilder, HasInputStream hasInputStream){
return null;
}
}
The three methods are called when a resource is read, created, or updated, respectively.
Your plugin can do any of the following:
HasInputStream
object, and returning a new HasInputStream
object which will provide the modified data.
ResourceMetaBuilder
object. This object will provide the metadata values that would be written/read. You can change the values by setting new values in the object.Example code under the examples/
directory:
example-java-storage-converter-plugin