Package org.eclipse.jgit.transport
Class PushCertificateParser
- java.lang.Object
-
- org.eclipse.jgit.transport.PushCertificateParser
-
public class PushCertificateParser extends Object
Parser for signed push certificates.- Since:
- 4.0
-
-
Constructor Summary
Constructors Constructor Description PushCertificateParser(Repository into, SignedPushConfig cfg)Constructor for PushCertificateParser.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCommand(String line)Add a command to the signature.voidaddCommand(ReceiveCommand cmd)Add a command to the signature.PushCertificatebuild()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.StringgetAdvertiseNonce()Get the whole string for the nonce to be included into the capability advertisementPushCertificateparse(Reader r)Parse 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 Detail
-
PushCertificateParser
public PushCertificateParser(Repository into, SignedPushConfig cfg)
Constructor for PushCertificateParser.
- Parameters:
into- destination repository for the push.cfg- configuration for signed push.- Since:
- 4.1
-
-
Method Detail
-
fromReader
public static PushCertificate fromReader(Reader r) throws PackProtocolException, IOException
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
public static PushCertificate fromString(String str) throws PackProtocolException, IOException
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:
fromReader(Reader)
-
parse
public PushCertificate parse(Reader r) throws PackProtocolException, IOException
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:
fromReader(Reader)
-
build
public PushCertificate build() throws IOException
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
public String 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
public void receiveHeader(PacketLineIn pckIn, boolean stateless) throws IOException
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
public void receiveSignature(PacketLineIn pckIn) throws IOException
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
public void addCommand(ReceiveCommand cmd)
Add a command to the signature.- Parameters:
cmd- the command.- Since:
- 4.1
-
addCommand
public void addCommand(String line) throws PackProtocolException
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
-
-