Class KeyMaterialFactory
- java.lang.Object
-
- org.jenkinsci.plugins.docker.commons.credentials.KeyMaterialFactory
-
- Direct Known Subclasses:
CompositeKeyMaterialFactory
,NullKeyMaterialFactory
,RegistryKeyMaterialFactory
,ServerHostKeyMaterialFactory
,ServerKeyMaterialFactory
public abstract class KeyMaterialFactory extends Object
Represents a locally extracted credentials information.Whenever you want to fork off docker directly or indirectly, use this object to set up environment variables so that docker will talk to the right daemon.
- Author:
- Kohsuke Kawaguchi
- See Also:
DockerServerEndpoint.newKeyMaterialFactory(AbstractBuild)
,DockerRegistryEndpoint.newKeyMaterialFactory(AbstractBuild)
-
-
Field Summary
Fields Modifier and Type Field Description static KeyMaterialFactory
NULL
-
Constructor Summary
Constructors Constructor Description KeyMaterialFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkContextualized()
KeyMaterialFactory
contextualize(KeyMaterialContext context)
Sets theKeyMaterialContext
within which thisKeyMaterialFactory
canmaterialize()
KeyMaterial
instances.protected FilePath
createSecretsDirectory()
Creates a read-protected directory insideKeyMaterialContext.getBaseDir()
suitable for storing secret files.protected KeyMaterialContext
getContext()
abstract KeyMaterial
materialize()
Builds the key material environment variables needed to be passed when docker runs, to accessDockerServerCredentials
that this object was created from.KeyMaterialFactory
plus(KeyMaterialFactory... factories)
Merge additionalKeyMaterialFactory
s into one.
-
-
-
Field Detail
-
NULL
public static final KeyMaterialFactory NULL
-
-
Method Detail
-
checkContextualized
protected void checkContextualized()
-
contextualize
public KeyMaterialFactory contextualize(@NonNull KeyMaterialContext context)
Sets theKeyMaterialContext
within which thisKeyMaterialFactory
canmaterialize()
KeyMaterial
instances. Can only be called once.- Parameters:
context
- theKeyMaterialContext
.- Returns:
- must return
this
(which is only returned to simplify use via method chaining)
-
getContext
@NonNull protected KeyMaterialContext getContext()
-
materialize
public abstract KeyMaterial materialize() throws IOException, InterruptedException
Builds the key material environment variables needed to be passed when docker runs, to accessDockerServerCredentials
that this object was created from.When you are done using the credentials, call
KeyMaterial.close()
to allow sensitive information to be removed from the disk.- Throws:
IOException
InterruptedException
-
createSecretsDirectory
protected final FilePath createSecretsDirectory() throws IOException, InterruptedException
Creates a read-protected directory insideKeyMaterialContext.getBaseDir()
suitable for storing secret files. Be sure toFilePath.deleteRecursive()
this inKeyMaterial.close()
.- Throws:
IOException
InterruptedException
-
plus
public KeyMaterialFactory plus(@Nullable KeyMaterialFactory... factories)
Merge additionalKeyMaterialFactory
s into one.
-
-