java.lang.Object
org.eclipse.jgit.transport.PushCertificateParser
Parser for signed push certificates.
- Since:
- 4.0
-
Constructor Summary
ConstructorsConstructorDescriptionPushCertificateParser(Repository into, SignedPushConfig cfg) Constructor for PushCertificateParser. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommand(String line) Add a command to the signature.voidaddCommand(ReceiveCommand cmd) Add a command to the signature.build()Build the parsed certificatebooleanenabled()Whether the repository is configured to use signed pushes in this context.static PushCertificatefromReader(Reader r) Parse a push certificate from a reader.static PushCertificatefromString(String str) Parse a push certificate from a string.Get the whole string for the nonce to be included into the capability advertisementParse a push certificate from a reader.voidreceiveHeader(PacketLineIn pckIn, boolean stateless) Receive a list of commands from the input encapsulated in a push certificate.voidreceiveSignature(PacketLineIn pckIn) Read the PGP signature.
-
Constructor Details
-
PushCertificateParser
Constructor for PushCertificateParser.
- Parameters:
into- destination repository for the push.cfg- configuration for signed push.- Since:
- 4.1
-
-
Method Details
-
fromReader
Parse a push certificate from a reader.Differences from the
PacketLineInreceiver methods:- Does not use pkt-line framing.
- Reads an entire cert in one call rather than depending on a loop in the caller.
- Does not assume a
"push-cert-end"line.
- Parameters:
r- input reader; consumed only up until the end of the next signature in the input.- Returns:
- the parsed certificate, or null if the reader was at EOF.
- Throws:
PackProtocolException- if the certificate is malformed.IOException- if there was an error reading from the input.- Since:
- 4.1
-
fromString
Parse a push certificate from a string.- Parameters:
str- input string.- Returns:
- the parsed certificate.
- Throws:
PackProtocolException- if the certificate is malformed.IOException- if there was an error reading from the input.- Since:
- 4.1
- See Also:
-
parse
Parse a push certificate from a reader.- Parameters:
r- input reader; consumed only up until the end of the next signature in the input.- Returns:
- the parsed certificate, or null if the reader was at EOF.
- Throws:
PackProtocolException- if the certificate is malformed.IOException- if there was an error reading from the input.- Since:
- 4.1
- See Also:
-
build
Build the parsed certificate- Returns:
- the parsed certificate, or null if push certificates are disabled.
- Throws:
IOException- if the push certificate has missing or invalid fields.- Since:
- 4.1
-
enabled
public boolean enabled()Whether the repository is configured to use signed pushes in this context.- Returns:
- if the repository is configured to use signed pushes in this context.
- Since:
- 4.0
-
getAdvertiseNonce
Get the whole string for the nonce to be included into the capability advertisement- Returns:
- the whole string for the nonce to be included into the capability advertisement, or null if push certificates are disabled.
- Since:
- 4.0
-
receiveHeader
Receive a list of commands from the input encapsulated in a push certificate.This method doesn't parse the first line
"push-cert \NUL <capabilities>", but assumes the first line including the capabilities has already been handled by the caller.- Parameters:
pckIn- where we take the push certificate header from.stateless- affects nonce verification. Whenstateless = truetheNonceGeneratorwill allow for some time skew caused by clients disconnected and reconnecting in the stateless smart HTTP protocol.- Throws:
IOException- if the certificate from the client is badly malformed or the client disconnects before sending the entire certificate.- Since:
- 4.0
-
receiveSignature
Read the PGP signature.This method assumes the line
"-----BEGIN PGP SIGNATURE-----"has already been parsed, and continues parsing until an"-----END PGP SIGNATURE-----"is found, followed by"push-cert-end".- Parameters:
pckIn- where we read the signature from.- Throws:
IOException- if the signature is invalid.- Since:
- 4.0
-
addCommand
Add a command to the signature.- Parameters:
cmd- the command.- Since:
- 4.1
-
addCommand
Add a command to the signature.- Parameters:
line- the line read from the wire that produced this command, with optional trailing newline already trimmed.- Throws:
PackProtocolException- if the raw line cannot be parsed to a command.- Since:
- 4.0
-