Top Description Inners Fields Constructors Methods
org.eclipse.jgit.transport

public Class PushCertificateParser

extends Object
Class Inheritance
Static Imports
org.eclipse.jgit.transport.GitProtocolConstants.CAPABILITY_PUSH_CERT, .ReceivePack.parseCommand

Parser for signed push certificates.
Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static interface

Field Summary

Modifier and TypeField and Description
pack-priv static final String
private final List<ReceiveCommand>
private final Repository
db

Database we write the push certificate into.

private final boolean
pack-priv static final String
pack-priv static final String
pack-priv static final String
private final NonceGenerator
private final int
nonceSlopLimit

The maximum time difference which is acceptable between advertised nonce and received signed nonce.

private PushCertificate.NonceStatus
pack-priv static final String
private String
pack-priv static final String
private PushCertificateIdent
private boolean
private String
receivedNonce

The nonce the pusher signed.

private String
sentNonce

The nonce that was sent to the client.

private String
pack-priv static final String
private String
private static final String

Constructor Summary

AccessConstructor and Description
public
PushCertificateParser(Repository
destination repository for the push.
into
,
SignedPushConfig
configuration for signed push.
cfg
)

Constructor for PushCertificateParser.

private

Method Summary

Modifier and TypeMethod and Description
public void
addCommand(ReceiveCommand
the command.
cmd
)

Add a command to the signature.

public void
addCommand(String
the line read from the wire that produced this command, with optional trailing newline already trimmed.
line
)

Add a command to the signature.

public PushCertificate

Returns:

the parsed certificate, or null if push certificates are disabled.
build
()

Build the parsed certificate

public boolean

Returns:

if the repository is configured to use signed pushes in this context.
enabled
()

Whether the repository is configured to use signed pushes in this context.

public static PushCertificate

Returns:

the parsed certificate, or null if the reader was at EOF.
fromReader
(Reader
input reader; consumed only up until the end of the next signature in the input.
r
)

Parse a push certificate from a reader.

public static PushCertificate

Returns:

the parsed certificate.
fromString
(String
input string.
str
)

Parse a push certificate from a string.

public String

Returns:

the whole string for the nonce to be included into the capability advertisement, or null if push certificates are disabled.
getAdvertiseNonce
()

Get the whole string for the nonce to be included into the capability advertisement

public PushCertificate

Returns:

the parsed certificate, or null if the reader was at EOF.
parse
(Reader
input reader; consumed only up until the end of the next signature in the input.
r
)

Parse a push certificate from a reader.

private static String
private static String
public void
receiveHeader(PacketLineIn
where we take the push certificate header from.
pckIn
,
boolean
affects nonce verification. When stateless = true the NonceGenerator will allow for some time skew caused by clients disconnected and reconnecting in the stateless smart HTTP protocol.
stateless
)

Receive a list of commands from the input encapsulated in a push certificate.

private void
public void
receiveSignature(PacketLineIn
where we read the signature from.
pckIn
)

Read the PGP signature.

private void
private String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BEGIN_SIGNATUREback to summary
pack-priv static final String BEGIN_SIGNATURE
commandsback to summary
private final List<ReceiveCommand> commands
dbback to summary
private final Repository db

Database we write the push certificate into.

enabledback to summary
private final boolean enabled
END_CERTback to summary
pack-priv static final String END_CERT
END_SIGNATUREback to summary
pack-priv static final String END_SIGNATURE
NONCEback to summary
pack-priv static final String NONCE
nonceGeneratorback to summary
private final NonceGenerator nonceGenerator
nonceSlopLimitback to summary
private final int nonceSlopLimit

The maximum time difference which is acceptable between advertised nonce and received signed nonce.

nonceStatusback to summary
private PushCertificate.NonceStatus nonceStatus
PUSHEEback to summary
pack-priv static final String PUSHEE
pusheeback to summary
private String pushee
PUSHERback to summary
pack-priv static final String PUSHER
pusherback to summary
private PushCertificateIdent pusher
receivedback to summary
private boolean received
receivedNonceback to summary
private String receivedNonce

The nonce the pusher signed.

This may vary from sentNonce; see git-core documentation for reasons.

sentNonceback to summary
private String sentNonce

The nonce that was sent to the client.

signatureback to summary
private String signature
VERSIONback to summary
pack-priv static final String VERSION
versionback to summary
private String version
VERSION_0_1back to summary
private static final String VERSION_0_1

Constructor Detail

PushCertificateParserback to summary
public PushCertificateParser(Repository into, SignedPushConfig cfg)

Constructor for PushCertificateParser.

Parameters
into:Repository

destination repository for the push.

cfg:SignedPushConfig

configuration for signed push.

Since
4.1
PushCertificateParserback to summary
private PushCertificateParser()

Method Detail

addCommandback to summary
public void addCommand(ReceiveCommand cmd)

Add a command to the signature.

Parameters
cmd:ReceiveCommand

the command.

Since
4.1
addCommandback to summary
public void addCommand(String line) throws PackProtocolException

Add a command to the signature.

Parameters
line:String

the line read from the wire that produced this command, with optional trailing newline already trimmed.

Exceptions
PackProtocolException:
if the raw line cannot be parsed to a command.
Since
4.0
buildback to summary
public PushCertificate build() throws IOException

Build the parsed certificate

Returns:PushCertificate

the parsed certificate, or null if push certificates are disabled.

Exceptions
IOException:
if the push certificate has missing or invalid fields.
Since
4.1
enabledback to summary
public boolean enabled()

Whether the repository is configured to use signed pushes in this context.

Returns:boolean

if the repository is configured to use signed pushes in this context.

Since
4.0
fromReaderback to summary
public static PushCertificate fromReader(Reader r) throws PackProtocolException, IOException

Parse a push certificate from a reader.

Differences from the org.eclipse.jgit.transport.PacketLineIn receiver 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:Reader

input reader; consumed only up until the end of the next signature in the input.

Returns:PushCertificate

the parsed certificate, or null if the reader was at EOF.

Exceptions
PackProtocolException:
if the certificate is malformed.
IOException:
if there was an error reading from the input.
Since
4.1
fromStringback to summary
public static PushCertificate fromString(String str) throws PackProtocolException, IOException

Parse a push certificate from a string.

Parameters
str:String

input string.

Returns:PushCertificate

the parsed certificate.

Exceptions
PackProtocolException:
if the certificate is malformed.
IOException:
if there was an error reading from the input.
Since
4.1
See Also
fromReader(Reader)
getAdvertiseNonceback to summary
public String getAdvertiseNonce()

Get the whole string for the nonce to be included into the capability advertisement

Returns:String

the whole string for the nonce to be included into the capability advertisement, or null if push certificates are disabled.

Since
4.0
parseback to summary
public PushCertificate parse(Reader r) throws PackProtocolException, IOException

Parse a push certificate from a reader.

Parameters
r:Reader

input reader; consumed only up until the end of the next signature in the input.

Returns:PushCertificate

the parsed certificate, or null if the reader was at EOF.

Exceptions
PackProtocolException:
if the certificate is malformed.
IOException:
if there was an error reading from the input.
Since
4.1
See Also
fromReader(Reader)
parseHeaderback to summary
private static String parseHeader(PushCertificateParser.StringReader reader, String header) throws IOException
parseHeaderback to summary
private static String parseHeader(String s, String header) throws IOException
receiveHeaderback to summary
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:PacketLineIn

where we take the push certificate header from.

stateless:boolean

affects nonce verification. When stateless = true the NonceGenerator will allow for some time skew caused by clients disconnected and reconnecting in the stateless smart HTTP protocol.

Exceptions
IOException:
if the certificate from the client is badly malformed or the client disconnects before sending the entire certificate.
Since
4.0
receiveHeaderback to summary
private void receiveHeader(PushCertificateParser.StringReader reader, boolean stateless) throws IOException
receiveSignatureback to summary
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:PacketLineIn

where we read the signature from.

Exceptions
IOException:
if the signature is invalid.
Since
4.0
receiveSignatureback to summary
private void receiveSignature(PushCertificateParser.StringReader reader) throws IOException
sentNonceback to summary
private String sentNonce()
org.eclipse.jgit.transport back to summary

private Class PushCertificateParser.PacketLineReader

extends Object
implements StringReader
Class Inheritance
  • java.lang.Object
  • org.eclipse.jgit.transport.PushCertificateParser.PacketLineReader
All Implemented Interfaces
org.eclipse.jgit.transport.PushCertificateParser.StringReader

Field Summary

Modifier and TypeField and Description
private final PacketLineIn

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

pckInback to summary
private final PacketLineIn pckIn

Constructor Detail

PacketLineReaderback to summary
private PacketLineReader(PacketLineIn pckIn)

Method Detail

readback to summary
public String read() throws IOException

Implements org.eclipse.jgit.transport.PushCertificateParser.StringReader.read.

Returns:String

Doc from org.eclipse.jgit.transport.PushCertificateParser.StringReader.read.

the next string from the input, up to an optional newline, with newline stripped if present

Annotations
@Override
Exceptions
IOException:

Doc from org.eclipse.jgit.transport.PushCertificateParser.StringReader.read.

if an error occurred during reading.

org.eclipse.jgit.transport back to summary

private Class PushCertificateParser.StreamReader

extends Object
implements StringReader
Class Inheritance
  • java.lang.Object
  • org.eclipse.jgit.transport.PushCertificateParser.StreamReader
All Implemented Interfaces
org.eclipse.jgit.transport.PushCertificateParser.StringReader

Field Summary

Modifier and TypeField and Description
private final Reader

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

readerback to summary
private final Reader reader

Constructor Detail

StreamReaderback to summary
private StreamReader(Reader reader)

Method Detail

readback to summary
public String read() throws IOException

Implements org.eclipse.jgit.transport.PushCertificateParser.StringReader.read.

Returns:String

Doc from org.eclipse.jgit.transport.PushCertificateParser.StringReader.read.

the next string from the input, up to an optional newline, with newline stripped if present

Annotations
@Override
Exceptions
IOException:

Doc from org.eclipse.jgit.transport.PushCertificateParser.StringReader.read.

if an error occurred during reading.

org.eclipse.jgit.transport back to summary

private Interface PushCertificateParser.StringReader

Known Direct Implementers
org.eclipse.jgit.transport.PushCertificateParser.PacketLineReader, org.eclipse.jgit.transport.PushCertificateParser.StreamReader

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the next string from the input, up to an optional newline, with newline stripped if present
read
()

Method Detail

readback to summary
public String read() throws EOFException, IOException
Returns:String

the next string from the input, up to an optional newline, with newline stripped if present

Exceptions
EOFException:
if EOF was reached.
IOException:
if an error occurred during reading.