]> source.dussan.org Git - jgit.git/commitdiff
PushCertificateParser: throw PackProtocolException in more cases 95/50295/6
authorDave Borowitz <dborowitz@google.com>
Mon, 15 Jun 2015 19:48:22 +0000 (15:48 -0400)
committerDave Borowitz <dborowitz@google.com>
Thu, 18 Jun 2015 13:50:12 +0000 (09:50 -0400)
This is the subclass of IOException already thrown by
BaseReceivePack#recvCommands when encountering an invalid value on
the wire. That's what PushCertificateParser is doing too, so use the
same subclass.

Change-Id: I1d323909ffe70757ea56e511556080695b1a0c11

org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateParser.java

index ccc82da64fe50d62dea2b76e058d75491f14a9fb..e302c0db41b00e1079d0dfb13f2044e0614a9646 100644 (file)
@@ -54,6 +54,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
+import org.eclipse.jgit.errors.PackProtocolException;
 import org.eclipse.jgit.internal.JGitText;
 import org.eclipse.jgit.lib.PersonIdent;
 import org.eclipse.jgit.lib.Repository;
@@ -183,7 +184,7 @@ public class PushCertificateParser {
                if (s.length() <= header.length()
                                || !s.startsWith(header)
                                || s.charAt(header.length()) != ' ') {
-                       throw new IOException(MessageFormat.format(
+                       throw new PackProtocolException(MessageFormat.format(
                                        JGitText.get().pushCertificateInvalidHeader, header));
                }
                return s.substring(header.length() + 1);
@@ -214,13 +215,13 @@ public class PushCertificateParser {
                try {
                        version = parseHeader(pckIn, VERSION);
                        if (!version.equals(VERSION_0_1)) {
-                               throw new IOException(MessageFormat.format(
+                               throw new PackProtocolException(MessageFormat.format(
                                                JGitText.get().pushCertificateInvalidFieldValue, VERSION, version));
                        }
                        String pusherStr = parseHeader(pckIn, PUSHER);
                        pusher = RawParseUtils.parsePersonIdent(pusherStr);
                        if (pusher == null) {
-                               throw new IOException(MessageFormat.format(
+                               throw new PackProtocolException(MessageFormat.format(
                                                JGitText.get().pushCertificateInvalidFieldValue,
                                                PUSHER, pusherStr));
                        }
@@ -228,11 +229,11 @@ public class PushCertificateParser {
                        receivedNonce = parseHeader(pckIn, NONCE);
                        // An empty line.
                        if (!pckIn.readString().isEmpty()) {
-                               throw new IOException(
+                               throw new PackProtocolException(
                                                JGitText.get().pushCertificateInvalidHeader);
                        }
                } catch (EOFException eof) {
-                       throw new IOException(
+                       throw new PackProtocolException(
                                        JGitText.get().pushCertificateInvalidHeader, eof);
                }
                nonceStatus = nonceGenerator != null
@@ -264,10 +265,11 @@ public class PushCertificateParser {
                        }
                        signature = sig.toString();
                        if (!pckIn.readStringRaw().equals(END_CERT)) {
-                               throw new IOException(JGitText.get().pushCertificateInvalidSignature);
+                               throw new PackProtocolException(
+                                               JGitText.get().pushCertificateInvalidSignature);
                        }
                } catch (EOFException eof) {
-                       throw new IOException(
+                       throw new PackProtocolException(
                                        JGitText.get().pushCertificateInvalidSignature, eof);
                }
        }