Package org.eclipse.jgit.api
Class VerifySignatureCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<java.util.Map<java.lang.String,VerificationResult>>
-
- org.eclipse.jgit.api.VerifySignatureCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<java.util.Map<java.lang.String,VerificationResult>>
public class VerifySignatureCommand extends GitCommand<java.util.Map<java.lang.String,VerificationResult>>
A command to verify GPG signatures on tags or commits.- Since:
- 5.11
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
VerifySignatureCommand.Result
static class
VerifySignatureCommand.VerifyMode
Describes what kind of objects shall be handled by aVerifySignatureCommand
.
-
Field Summary
Fields Modifier and Type Field Description private GpgConfig
config
private VerifySignatureCommand.VerifyMode
mode
private java.util.Set<java.lang.String>
namesToCheck
private boolean
ownVerifier
private GpgSignatureVerifier
verifier
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Constructor Description VerifySignatureCommand(Repository repo)
Creates a newVerifySignatureCommand
for the givenRepository
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VerifySignatureCommand
addName(java.lang.String name)
Add a name of an object (SHA-1, ref name; anything that can beresolved
) to the command to have its signature verified.VerifySignatureCommand
addNames(java.lang.String... names)
Add names of objects (SHA-1, ref name; anything that can beresolved
) to the command to have their signatures verified.VerifySignatureCommand
addNames(java.util.Collection<java.lang.String> names)
Add names of objects (SHA-1, ref name; anything that can beresolved
) to the command to have their signatures verified.java.util.Map<java.lang.String,VerificationResult>
call()
Resolves
all names added to the command to git objects and verifies their signature.GpgSignatureVerifier
getVerifier()
Retrieves the currently setGpgSignatureVerifier
.VerifySignatureCommand
setGpgConfig(GpgConfig config)
Sets an externalGpgConfig
to use.VerifySignatureCommand
setMode(VerifySignatureCommand.VerifyMode mode)
Sets the mode of operation for this command.VerifySignatureCommand
setVerifier(GpgSignatureVerifier verifier)
Sets theGpgSignatureVerifier
to use.private VerificationResult
verifyOne(RevObject object)
-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Field Detail
-
namesToCheck
private final java.util.Set<java.lang.String> namesToCheck
-
mode
private VerifySignatureCommand.VerifyMode mode
-
verifier
private GpgSignatureVerifier verifier
-
config
private GpgConfig config
-
ownVerifier
private boolean ownVerifier
-
-
Constructor Detail
-
VerifySignatureCommand
public VerifySignatureCommand(Repository repo)
Creates a newVerifySignatureCommand
for the givenRepository
.- Parameters:
repo
- to operate on
-
-
Method Detail
-
addName
public VerifySignatureCommand addName(java.lang.String name)
Add a name of an object (SHA-1, ref name; anything that can beresolved
) to the command to have its signature verified.- Parameters:
name
- to add- Returns:
this
-
addNames
public VerifySignatureCommand addNames(java.lang.String... names)
Add names of objects (SHA-1, ref name; anything that can beresolved
) to the command to have their signatures verified.- Parameters:
names
- to add; duplicates will be ignored- Returns:
this
-
addNames
public VerifySignatureCommand addNames(java.util.Collection<java.lang.String> names)
Add names of objects (SHA-1, ref name; anything that can beresolved
) to the command to have their signatures verified.- Parameters:
names
- to add; duplicates will be ignored- Returns:
this
-
setMode
public VerifySignatureCommand setMode(@NonNull VerifySignatureCommand.VerifyMode mode)
Sets the mode of operation for this command.- Parameters:
mode
- theVerifySignatureCommand.VerifyMode
to set- Returns:
this
-
setVerifier
public VerifySignatureCommand setVerifier(GpgSignatureVerifier verifier)
Sets theGpgSignatureVerifier
to use.- Parameters:
verifier
- theGpgSignatureVerifier
to use, ornull
to use the default verifier- Returns:
this
-
setGpgConfig
public VerifySignatureCommand setGpgConfig(GpgConfig config)
Sets an externalGpgConfig
to use. Whether it will be used it at the discretion of thesetVerifier(GpgSignatureVerifier)
.- Parameters:
config
- to set; ifnull
, the config will be loaded from the git config of the repository- Returns:
this
- Since:
- 5.11
-
getVerifier
public GpgSignatureVerifier getVerifier()
Retrieves the currently setGpgSignatureVerifier
. Can be used after a successfulcall()
to get the verifier that was used.- Returns:
- the
GpgSignatureVerifier
-
call
@NonNull public java.util.Map<java.lang.String,VerificationResult> call() throws ServiceUnavailableException, WrongObjectTypeException
Resolves
all names added to the command to git objects and verifies their signature. Non-existing objects are ignored.Depending on the
setMode(VerifyMode)
, only tags or commits or any kind of objects are allowed.Unsigned objects are silently skipped.
- Specified by:
call
in interfacejava.util.concurrent.Callable<java.util.Map<java.lang.String,VerificationResult>>
- Specified by:
call
in classGitCommand<java.util.Map<java.lang.String,VerificationResult>>
- Returns:
- a map of the given names to the corresponding
VerificationResult
, excluding ignored or skipped objects. - Throws:
ServiceUnavailableException
- if noGpgSignatureVerifier
was set and noGpgSignatureVerifierFactory
is availableWrongObjectTypeException
- if a name resolves to an object of a type not allowed by thesetMode(VerifyMode)
mode
-
verifyOne
private VerificationResult verifyOne(RevObject object) throws WrongObjectTypeException, java.io.IOException
- Throws:
WrongObjectTypeException
java.io.IOException
-
-