]> source.dussan.org Git - jgit.git/commit
Rewrite push certificate parsing 66/49966/7
authorDave Borowitz <dborowitz@google.com>
Wed, 10 Jun 2015 00:23:03 +0000 (17:23 -0700)
committerDave Borowitz <dborowitz@google.com>
Thu, 11 Jun 2015 15:52:42 +0000 (11:52 -0400)
commita85e817dc29a1d6a96beeb92383aa265b0303415
tree8475768f98414b5cbd3b0d97d5e8d17df6847ca1
parentd43703624ce4ac3379a4632b3dbf1049cd96c918
Rewrite push certificate parsing

- Consistently return structured data, such as actual ReceiveCommands,
  which is more useful for callers that are doing things other than
  verifying the signature, e.g. recording the set of commands.
- Store the certificate version field, as this is required to be part
  of the signed payload.
- Add a toText() method to recreate the actual payload for signature
  verification. This requires keeping track of the un-chomped command
  strings from the original protocol stream.
- Separate the parser from the certificate itself, so the actual
  PushCertificate object can be immutable. Make a fair attempt at deep
  immutability, but this is not possible with the current mutable
  ReceiveCommand structure.
- Use more detailed error messages that don't involve NON-NLS strings.
- Document null return values more thoroughly. Instead of having the
  undocumented behavior of throwing NPE from certain methods if they
  are not first guarded by enabled(), eliminate enabled() and return
  null from those methods.
- Add tests for parsing a push cert from a section of pkt-line stream
  using a real live stream captured with Wireshark (which, it should
  be noted, uncovered several simply incorrect statements in C git's
  Documentation/technical/pack-protocol.txt).

This is a slightly breaking API change to classes that were
technically public and technically released in 4.0. However, it is
highly unlikely that people were actually depending on public
behavior, since there were no public methods to create
PushCertificates with anything other than null field values, or a
PushCertificateParser that did anything other than infinite loop or
throw exceptions when reading.

Change-Id: I5382193347a8eb1811032d9b32af9651871372d0
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/PushCertificateParserTest.java [new file with mode: 0644]
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificate.java
org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java