- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<Map<String,VerificationResult>>
-
- org.eclipse.jgit.api.VerifySignatureCommand
-
- All Implemented Interfaces:
Callable<Map<String,VerificationResult>>
public class VerifySignatureCommand extends GitCommand<Map<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 static classVerifySignatureCommand.VerifyModeDescribes what kind of objects shall be handled by aVerifySignatureCommand.
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Constructor Description VerifySignatureCommand(Repository repo)Creates a newVerifySignatureCommandfor the givenRepository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VerifySignatureCommandaddName(String name)Add a name of an object (SHA-1, ref name; anything that can beresolved) to the command to have its signature verified.VerifySignatureCommandaddNames(String... names)Add names of objects (SHA-1, ref name; anything that can beresolved) to the command to have their signatures verified.VerifySignatureCommandaddNames(Collection<String> names)Add names of objects (SHA-1, ref name; anything that can beresolved) to the command to have their signatures verified.Map<String,VerificationResult>call()Resolvesall names added to the command to git objects and verifies their signature.GpgSignatureVerifiergetVerifier()Retrieves the currently setGpgSignatureVerifier.VerifySignatureCommandsetGpgConfig(GpgConfig config)Sets an externalGpgConfigto use.VerifySignatureCommandsetMode(VerifySignatureCommand.VerifyMode mode)Sets the mode of operation for this command.VerifySignatureCommandsetVerifier(GpgSignatureVerifier verifier)Sets theGpgSignatureVerifierto use.-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
VerifySignatureCommand
public VerifySignatureCommand(Repository repo)
Creates a newVerifySignatureCommandfor the givenRepository.- Parameters:
repo- to operate on
-
-
Method Detail
-
addName
public VerifySignatureCommand addName(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(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(Collection<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.VerifyModeto set- Returns:
this
-
setVerifier
public VerifySignatureCommand setVerifier(GpgSignatureVerifier verifier)
Sets theGpgSignatureVerifierto use.- Parameters:
verifier- theGpgSignatureVerifierto use, ornullto use the default verifier- Returns:
this
-
setGpgConfig
public VerifySignatureCommand setGpgConfig(GpgConfig config)
Sets an externalGpgConfigto 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 Map<String,VerificationResult> call() throws ServiceUnavailableException, WrongObjectTypeException
Resolvesall 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:
callin interfaceCallable<Map<String,VerificationResult>>- Specified by:
callin classGitCommand<Map<String,VerificationResult>>- Returns:
- a map of the given names to the corresponding
VerificationResult, excluding ignored or skipped objects. - Throws:
ServiceUnavailableException- if noGpgSignatureVerifierwas set and noGpgSignatureVerifierFactoryis availableWrongObjectTypeException- if a name resolves to an object of a type not allowed by thesetMode(VerifyMode)mode
-
-