public class PushCertificateParser
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
PushCertificateParser.PacketLineReader |
private static class |
PushCertificateParser.StreamReader |
private static interface |
PushCertificateParser.StringReader |
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String |
BEGIN_SIGNATURE |
private java.util.List<ReceiveCommand> |
commands |
private Repository |
db
Database we write the push certificate into.
|
private boolean |
enabled |
(package private) static java.lang.String |
END_CERT |
(package private) static java.lang.String |
END_SIGNATURE |
(package private) static java.lang.String |
NONCE |
private NonceGenerator |
nonceGenerator |
private int |
nonceSlopLimit
The maximum time difference which is acceptable between advertised nonce
and received signed nonce.
|
private PushCertificate.NonceStatus |
nonceStatus |
private java.lang.String |
pushee |
(package private) static java.lang.String |
PUSHEE |
private PushCertificateIdent |
pusher |
(package private) static java.lang.String |
PUSHER |
private boolean |
received |
private java.lang.String |
receivedNonce
The nonce the pusher signed.
|
private java.lang.String |
sentNonce
The nonce that was sent to the client.
|
private java.lang.String |
signature |
private java.lang.String |
version |
(package private) static java.lang.String |
VERSION |
private static java.lang.String |
VERSION_0_1 |
Modifier | Constructor and Description |
---|---|
private |
PushCertificateParser() |
|
PushCertificateParser(Repository into,
SignedPushConfig cfg)
Constructor for PushCertificateParser.
|
Modifier and Type | Method and Description |
---|---|
void |
addCommand(ReceiveCommand cmd)
Add a command to the signature.
|
void |
addCommand(java.lang.String line)
Add a command to the signature.
|
PushCertificate |
build()
Build the parsed certificate
|
boolean |
enabled()
Whether the repository is configured to use signed pushes in this
context.
|
static PushCertificate |
fromReader(java.io.Reader r)
Parse a push certificate from a reader.
|
static PushCertificate |
fromString(java.lang.String str)
Parse a push certificate from a string.
|
java.lang.String |
getAdvertiseNonce()
Get the whole string for the nonce to be included into the capability
advertisement
|
PushCertificate |
parse(java.io.Reader r)
Parse a push certificate from a reader.
|
private static java.lang.String |
parseHeader(PushCertificateParser.StringReader reader,
java.lang.String header) |
private static java.lang.String |
parseHeader(java.lang.String s,
java.lang.String header) |
void |
receiveHeader(PacketLineIn pckIn,
boolean stateless)
Receive a list of commands from the input encapsulated in a push
certificate.
|
private void |
receiveHeader(PushCertificateParser.StringReader reader,
boolean stateless) |
void |
receiveSignature(PacketLineIn pckIn)
Read the PGP signature.
|
private void |
receiveSignature(PushCertificateParser.StringReader reader) |
private java.lang.String |
sentNonce() |
static final java.lang.String BEGIN_SIGNATURE
static final java.lang.String END_SIGNATURE
static final java.lang.String VERSION
static final java.lang.String PUSHER
static final java.lang.String PUSHEE
static final java.lang.String NONCE
static final java.lang.String END_CERT
private static final java.lang.String VERSION_0_1
private boolean received
private java.lang.String version
private PushCertificateIdent pusher
private java.lang.String pushee
private java.lang.String sentNonce
private java.lang.String receivedNonce
This may vary from sentNonce
; see git-core documentation for
reasons.
private PushCertificate.NonceStatus nonceStatus
private java.lang.String signature
private final Repository db
private final int nonceSlopLimit
private final boolean enabled
private final NonceGenerator nonceGenerator
private final java.util.List<ReceiveCommand> commands
public PushCertificateParser(Repository into, SignedPushConfig cfg)
Constructor for PushCertificateParser.
into
- destination repository for the push.cfg
- configuration for signed push.private PushCertificateParser()
public static PushCertificate fromReader(java.io.Reader r) throws PackProtocolException, java.io.IOException
Differences from the PacketLineIn
receiver methods:
"push-cert-end"
line.r
- input reader; consumed only up until the end of the next
signature in the input.PackProtocolException
- if the certificate is malformed.java.io.IOException
- if there was an error reading from the input.public static PushCertificate fromString(java.lang.String str) throws PackProtocolException, java.io.IOException
str
- input string.PackProtocolException
- if the certificate is malformed.java.io.IOException
- if there was an error reading from the input.fromReader(Reader)
public PushCertificate parse(java.io.Reader r) throws PackProtocolException, java.io.IOException
r
- input reader; consumed only up until the end of the next
signature in the input.PackProtocolException
- if the certificate is malformed.java.io.IOException
- if there was an error reading from the input.fromReader(Reader)
public PushCertificate build() throws java.io.IOException
java.io.IOException
- if the push certificate has missing or invalid fields.public boolean enabled()
public java.lang.String getAdvertiseNonce()
private java.lang.String sentNonce()
private static java.lang.String parseHeader(PushCertificateParser.StringReader reader, java.lang.String header) throws java.io.IOException
java.io.IOException
private static java.lang.String parseHeader(java.lang.String s, java.lang.String header) throws java.io.IOException
java.io.IOException
public void receiveHeader(PacketLineIn pckIn, boolean stateless) throws java.io.IOException
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.
pckIn
- where we take the push certificate header from.stateless
- 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.java.io.IOException
- if the certificate from the client is badly malformed or the
client disconnects before sending the entire certificate.private void receiveHeader(PushCertificateParser.StringReader reader, boolean stateless) throws java.io.IOException
java.io.IOException
public void receiveSignature(PacketLineIn pckIn) throws java.io.IOException
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"
.
pckIn
- where we read the signature from.java.io.IOException
- if the signature is invalid.private void receiveSignature(PushCertificateParser.StringReader reader) throws java.io.IOException
java.io.IOException
public void addCommand(ReceiveCommand cmd)
cmd
- the command.public void addCommand(java.lang.String line) throws PackProtocolException
line
- the line read from the wire that produced this
command, with optional trailing newline already trimmed.PackProtocolException
- if the raw line cannot be parsed to a command.