/** * @param payload 4 bytes minimum if non-null * @throws DataFormatException */ public KeyCertificate(byte[] payload) throws DataFormatException { super(CERTIFICATE_TYPE_KEY, payload); if (payload != null && payload.length < HEADER_LENGTH) throw new DataFormatException("data"); }
/** * For inbound packets * @param con may be null */ public void write(Packet pkt, Connection con) throws IOException { try { wrt(pkt, con, true); } catch (DataFormatException dfe) { dfe.printStackTrace(); throw new IOException(dfe.toString()); } }
/** without sig! */ @Override protected byte[] getBytes() { if (_byteified != null) return _byteified; if (_destination == null) return null; int len = size(); ByteArrayOutputStream out = new ByteArrayOutputStream(len); try { writeBytesWithoutSig(out); } catch (IOException ioe) { ioe.printStackTrace(); return null; } catch (DataFormatException dfe) { dfe.printStackTrace(); return null; } byte rv[] = out.toByteArray(); // if we are floodfill and this was published to us if (_receivedAsPublished) _byteified = rv; return rv; }
Emsg(e.toString(), out); } catch (IOException ex) {
IOException ioe = new IOException(dfe.getMessage()); ioe.initCause(dfe); throw ioe;
} catch (DataFormatException e) { System.err.println("Error writing keys:"); e.printStackTrace(); return false; } finally {
return e.toString(); } catch (DataFormatException e) { return e.toString(); } catch (SAMException e) { return e.toString();
return writeString("SESSION STATUS RESULT=INVALID_KEY", e.getMessage()); } catch (I2PSessionException e) { _log.error("Failed to start SAM session", e);
public PacketACKBitfield(int start) throws DataFormatException { _start = start; _bitfieldStart = start + 4; int bfsz = 1; // bitfield is an array of bytes where the high bit is 1 if // further bytes in the bitfield follow while ((_message[_bitfieldStart + bfsz - 1] & UDPPacket.BITFIELD_CONTINUATION) != 0x0) { bfsz++; //if (bfsz > InboundMessageState.MAX_PARTIAL_BITFIELD_BYTES) // throw new DataFormatException(); } if (bfsz > InboundMessageState.MAX_PARTIAL_BITFIELD_BYTES) throw new DataFormatException("bitfield size: " + bfsz); _bitfieldSize = bfsz; }
/** * For outbound packets */ public void write(PacketLocal pkt) throws IOException { try { wrt(pkt, pkt.getConnection(), false); } catch (DataFormatException dfe) { dfe.printStackTrace(); throw new IOException(dfe.toString()); } }
private static void storeMyInfo(RouterInfo info) { File infoDir = getInfoDir(); if (!infoDir.exists()) infoDir.mkdirs(); FileOutputStream fos = null; File infoFile = new File(infoDir, info.getIdentity().calculateHash().toBase64()); infoFile.deleteOnExit(); try { fos = new FileOutputStream(infoFile); info.writeBytes(fos); } catch (IOException ioe) { ioe.printStackTrace(); } catch (DataFormatException dfe) { dfe.printStackTrace(); } finally { if (fos != null) try { fos.close(); } catch (IOException ioe) {} } System.out.println("Our info stored at: " + infoFile.getAbsolutePath()); }
return writeString("SESSION STATUS RESULT=INVALID_KEY", e.getMessage()); } catch (I2PSessionException e) { _log.error("Failed to start SAM session", e);
public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_data == null) throw new DataFormatException("No data to write out"); out.write(_data); }
/** * For inbound packets * @param con may be null */ public void write(Packet pkt, Connection con) throws IOException { try { wrt(pkt, con, true); } catch (DataFormatException dfe) { dfe.printStackTrace(); throw new IOException(dfe.toString()); } }
} catch (DataFormatException dfe) { System.err.println("Corrupt " + peerFiles[i].getAbsolutePath()); dfe.printStackTrace();
if (_log.shouldLog(Log.DEBUG)) _log.debug("Invalid destination in STREAM CONNECT message"); notifyStreamResult ( verbose, "INVALID_KEY", e.getMessage()); } catch (ConnectException e) { if (_log.shouldLog(Log.DEBUG))
public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_severityId < 0) throw new DataFormatException("Invalid abuse severity: " + _severityId); out.write((byte) _severityId); }
/** * For outbound packets */ public void write(PacketLocal pkt) throws IOException { try { wrt(pkt, pkt.getConnection(), false); } catch (DataFormatException dfe) { dfe.printStackTrace(); throw new IOException(dfe.toString()); } }
return false; } catch (DataFormatException dfe) { dfe.printStackTrace(); return false;
recv.notifyStreamOutgoingConnection ( id, "INVALID_KEY", e.getMessage() );