private PackProtocolException duplicateAdvertisement(String name) { return new PackProtocolException(transport.uri, MessageFormat.format(JGitText.get().duplicateAdvertisementsOf, name)); }
private static String parseHeader(String s, String header) throws IOException { if (s.isEmpty()) { throw new EOFException(); } if (s.length() <= header.length() || !s.startsWith(header) || s.charAt(header.length()) != ' ') { throw new PackProtocolException(MessageFormat.format( JGitText.get().pushCertificateInvalidField, header)); } return s.substring(header.length() + 1); }
private PackProtocolException duplicateAdvertisement(String name) { return new PackProtocolException(uri, MessageFormat.format(JGitText.get().duplicateAdvertisementsOf, name)); }
private PackProtocolException invalidAdvertisement(String n) { return new PackProtocolException(MessageFormat.format(JGitText.get().invalidAdvertisementOf, n)); }
private PackProtocolException invalidRefAdvertisementLine(String line) { return new PackProtocolException(uri, MessageFormat.format(JGitText.get().invalidRefAdvertisementLine, line)); }
private PackProtocolException outOfOrderAdvertisement(String n) { return new PackProtocolException(MessageFormat.format(JGitText.get().advertisementOfCameBefore, n, n)); }
private PackProtocolException duplicateAdvertisement(String n) { return new PackProtocolException(MessageFormat.format(JGitText.get().duplicateAdvertisementsOf, n)); }
private void receiveSignature(StringReader reader) throws IOException { received = true; try { StringBuilder sig = new StringBuilder(BEGIN_SIGNATURE).append('\n'); String line; while (!(line = reader.read()).equals(END_SIGNATURE)) { sig.append(line).append('\n'); } signature = sig.append(END_SIGNATURE).append('\n').toString(); } catch (EOFException eof) { throw new PackProtocolException( JGitText.get().pushCertificateInvalidSignature, eof); } }
static long filterLine(String blobLine) throws PackProtocolException { long blobLimit = -1; if (blobLine.equals("blob:none")) { //$NON-NLS-1$ blobLimit = 0; } else if (blobLine.startsWith("blob:limit=")) { //$NON-NLS-1$ try { blobLimit = Long .parseLong(blobLine.substring("blob:limit=".length())); //$NON-NLS-1$ } catch (NumberFormatException e) { throw new PackProtocolException(MessageFormat .format(JGitText.get().invalidFilter, blobLine)); } } /* * We must have (1) either "blob:none" or "blob:limit=" set (because we * only support blob size limits for now), and (2) if the latter, then * it must be nonnegative. Throw if (1) or (2) is not met. */ if (blobLimit < 0) { throw new PackProtocolException( MessageFormat.format(JGitText.get().invalidFilter, blobLine)); } return blobLimit; }
private void parseShallow(String idStr) throws PackProtocolException { ObjectId id; try { id = ObjectId.fromString(idStr); } catch (InvalidObjectIdException e) { throw new PackProtocolException(e.getMessage(), e); } clientShallowCommits.add(id); }
private boolean okToGiveUpImp() throws PackProtocolException { if (commonBase.isEmpty()) return false; try { for (RevObject obj : wantAll) { if (!wantSatisfied(obj)) return false; } return true; } catch (IOException e) { throw new PackProtocolException(JGitText.get().internalRevisionError, e); } }
AckNackResult readACK(MutableObjectId returnedId) throws IOException { final String line = readString(); if (line.length() == 0) throw new PackProtocolException(JGitText.get().expectedACKNAKFoundEOF); if ("NAK".equals(line)) //$NON-NLS-1$ return AckNackResult.NAK; if (line.startsWith("ACK ")) { //$NON-NLS-1$ returnedId.fromString(line.substring(4, 44)); if (line.length() == 44) return AckNackResult.ACK; final String arg = line.substring(44); if (arg.equals(" continue")) //$NON-NLS-1$ return AckNackResult.ACK_CONTINUE; else if (arg.equals(" common")) //$NON-NLS-1$ return AckNackResult.ACK_COMMON; else if (arg.equals(" ready")) //$NON-NLS-1$ return AckNackResult.ACK_READY; } if (line.startsWith("ERR ")) //$NON-NLS-1$ throw new PackProtocolException(line.substring(4)); throw new PackProtocolException(MessageFormat.format(JGitText.get().expectedACKNAKGot, line)); }
String opt = line.substring(45); if (!opt.startsWith(" ")) { //$NON-NLS-1$ throw new PackProtocolException(JGitText.get().wantNoSpaceWithCapabilities);
static ReceiveCommand parseCommand(String line) throws PackProtocolException { if (line == null || line.length() < 83) { throw new PackProtocolException( JGitText.get().errorInvalidProtocolWantedOldNewRef); } String oldStr = line.substring(0, 40); String newStr = line.substring(41, 81); ObjectId oldId, newId; try { oldId = ObjectId.fromString(oldStr); newId = ObjectId.fromString(newStr); } catch (InvalidObjectIdException e) { throw new PackProtocolException( JGitText.get().errorInvalidProtocolWantedOldNewRef, e); } String name = line.substring(82); if (!Repository.isValidRefName(name)) { throw new PackProtocolException( JGitText.get().errorInvalidProtocolWantedOldNewRef); } return new ReceiveCommand(oldId, newId, name); }
private boolean serveOneCommandV2() throws IOException { String command; try { command = pckIn.readString(); } catch (EOFException eof) { /* EOF when awaiting command is fine */ return true; } if (command == PacketLineIn.END) { // A blank request is valid according // to the protocol; do nothing in this // case. return true; } if (command.equals("command=" + COMMAND_LS_REFS)) { //$NON-NLS-1$ lsRefsV2(); return false; } if (command.equals("command=" + COMMAND_FETCH)) { //$NON-NLS-1$ fetchV2(); return false; } throw new PackProtocolException(MessageFormat .format(JGitText.get().unknownTransportCommand, command)); }
/** * Read the PGP signature. * <p> * This method assumes the line * {@code "-----BEGIN PGP SIGNATURE-----"} has already been parsed, * and continues parsing until an {@code "-----END PGP SIGNATURE-----"} is * found, followed by {@code "push-cert-end"}. * * @param pckIn * where we read the signature from. * @throws java.io.IOException * if the signature is invalid. * @since 4.0 */ public void receiveSignature(PacketLineIn pckIn) throws IOException { StringReader reader = new PacketLineReader(pckIn); receiveSignature(reader); if (!reader.read().equals(END_CERT)) { throw new PackProtocolException( JGitText.get().pushCertificateInvalidSignature); } }
throw new PackProtocolException(MessageFormat.format( JGitText.get().pushCertificateInvalidFieldValue, VERSION, version)); pusher = PushCertificateIdent.parse(rawPusher); if (pusher == null) { throw new PackProtocolException(MessageFormat.format( JGitText.get().pushCertificateInvalidFieldValue, PUSHER, rawPusher)); throw new PackProtocolException( JGitText.get().pushCertificateInvalidHeader); throw new PackProtocolException( JGitText.get().pushCertificateInvalidHeader, eof);
private void needDataPacket() throws IOException { if (eof || (channel == CH_DATA && available > 0)) return; for (;;) { available = pckIn.readLength(); if (available == 0) { eof = true; return; } channel = rawIn.read() & 0xff; available -= HDR_SIZE; // length header plus channel indicator if (available == 0) continue; switch (channel) { case CH_DATA: return; case CH_PROGRESS: progress(readString(available)); continue; case CH_ERROR: eof = true; throw new TransportException(remote(readString(available))); default: throw new PackProtocolException( MessageFormat.format(JGitText.get().invalidChannel, Integer.valueOf(channel))); } } }
private void verifyClientShallow(Set<ObjectId> shallowCommits) throws IOException, PackProtocolException { AsyncRevObjectQueue q = walk.parseAny(shallowCommits, true); try { for (;;) { try { // Shallow objects named by the client must be commits. RevObject o = q.next(); if (o == null) { break; } if (!(o instanceof RevCommit)) { throw new PackProtocolException( MessageFormat.format( JGitText.get().invalidShallowObject, o.name())); } } catch (MissingObjectException notCommit) { // shallow objects not known at the server are ignored // by git-core upload-pack, match that behavior. shallowCommits.remove(notCommit.getObjectId()); continue; } } } finally { q.release(); } }
throw new PackProtocolException(uri, MessageFormat.format( JGitText.get().statelessRPCRequiresOptionToBeEnabled, OPTION_MULTI_ACK_DETAILED)); throw new PackProtocolException(uri, JGitText.get().filterRequiresCapability);