/** @throws I2PException always */ @Override public void connect(SAMv3Handler handler, String dest, Properties props) throws I2PException { throw new I2PException("master session"); }
/** * Generate a random destination key. * Caller must close streams. Fails silently. * * @param priv Stream used to write the destination and private keys * @param pub Stream used to write the destination (may be null) * @param sigType what signature type * @since 0.9.14 */ public static void genRandomKey(OutputStream priv, OutputStream pub, SigType sigType) { //_log.debug("Generating random keys..."); try { I2PClient c = I2PClientFactory.createClient(); Destination d = c.createDestination(priv, sigType); priv.flush(); if (pub != null) { d.writeBytes(pub); pub.flush(); } } catch (I2PException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
tstype = SigType.parseSigType(ttype); if (tstype == null) throw new I2PException("Bad or unsupported -r option: " + ttype); Signature sign = DSAEngine.getInstance().sign(data, pkf.getSigningPrivKey()); if (sign == null) throw new I2PException("Sig fail"); e.printStackTrace(); System.exit(1); } catch (IOException e) {
if (_log.shouldLog(Log.ERROR)) _log.error("Error creating new destination", ie); log("Error creating new destination: " + ie.getMessage()); return false; } catch (IOException ioe) {
Emsg(e.toString(), out); } catch (ConnectException e) { Emsg(e.toString(), out);
private boolean execStreamAccept( Properties props ) { // Messages are NOT sent if SILENT=true, // The specs said that they were. boolean verbose = !Boolean.parseBoolean(props.getProperty("SILENT")); try { try { notifyStreamResult(verbose, "OK", null); ((SAMv3StreamSession)streamSession).accept(this, verbose); return true ; } catch (InterruptedIOException e) { if (_log.shouldLog(Log.DEBUG)) _log.debug("STREAM ACCEPT failed", e); notifyStreamResult( verbose, "TIMEOUT", e.getMessage() ); } catch (I2PException e) { if (_log.shouldLog(Log.DEBUG)) _log.debug("STREAM ACCEPT failed", e); notifyStreamResult ( verbose, "I2P_ERROR", e.getMessage() ); } catch (SAMException e) { if (_log.shouldLog(Log.DEBUG)) _log.debug("STREAM ACCEPT failed", e); notifyStreamResult ( verbose, "ALREADY_ACCEPTING", e.getMessage()); } } catch (IOException e) { } return false ; }
/** @since 0.9.21 */ private void verifySession(I2PSession session) throws I2PException { if (_isDestroyed.get()) throw new I2PException("Session was closed"); if (!session.isClosed()) return; session.connect(); }
/** * Read in the given destination, display it, and write it to the given location * Deprecated - only used by CLI * * @param readFrom stream to read the destination from * @param pubDest stream to write the destination to * @param l logger to send messages to */ private static void showKey(InputStream readFrom, OutputStream pubDest, Logging l) { try { Destination d = new Destination(); d.readBytes(readFrom); l.log("Destination: " + d.toBase32()); readFrom.close(); writePubKey(d, pubDest, l); } catch (I2PException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
if (_log.shouldLog(Log.DEBUG)) _log.debug("STREAM CONNECT failed", e); notifyStreamResult ( verbose, "I2P_ERROR", e.getMessage() );
/** * Verify the signature if necessary. * * @throws I2PException if the signature was necessary and it was invalid */ private void verifySignature(Packet packet, Connection con) throws I2PException { // verify the signature if necessary if (con.getOptions().getRequireFullySigned() || packet.isFlagSet(Packet.FLAG_SYNCHRONIZE | Packet.FLAG_CLOSE)) { // we need a valid signature Destination from = con.getRemotePeer(); if (from == null) from = packet.getOptionalFrom(); boolean sigOk = packet.verifySignature(_context, from, null); if (!sigOk) { throw new I2PException("Received unsigned / forged packet: " + packet); } } }
/** * Create a new destination, storing the destination and its private keys where * instructed. * Does NOT support non-default sig types. * Deprecated - only used by CLI * * @param writeTo location to store the destination and private keys * @param pubDest location to store the destination * @param l logger to send messages to */ private static void makeKey(OutputStream writeTo, OutputStream pubDest, Logging l) { try { l.log("Generating new keys..."); I2PClient client = I2PClientFactory.createClient(); Destination d = client.createDestination(writeTo); l.log("New destination: " + d.toBase32()); writeTo.flush(); writeTo.close(); writePubKey(d, pubDest, l); } catch (I2PException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } }
recv.notifyStreamOutgoingConnection ( id, "I2P_ERROR", e.getMessage() );
opts.setLocalPort(Integer.parseInt(fromPort)); } catch (NumberFormatException nfe) { throw new I2PException("Bad port " + fromPort); opts.setPort(Integer.parseInt(toPort)); } catch (NumberFormatException nfe) { throw new I2PException("Bad port " + toPort);
I2PServerSocket ci2pss = i2pss; if (ci2pss == null) throw new I2PException("I2PServerSocket closed");
signingKeys = KeyGenerator.getInstance().generateSigningKeys(type); } catch (GeneralSecurityException gse) { throw new I2PException("keygen fail", gse);
/** @since 0.9.21 */ private void verifySession(I2PSession session) throws I2PException { if (_isDestroyed.get()) throw new I2PException("Session was closed"); if (!session.isClosed()) return; session.connect(); }
/** * Verify the signature if necessary. * * @throws I2PException if the signature was necessary and it was invalid */ private void verifySignature(Packet packet, Connection con) throws I2PException { // verify the signature if necessary if (con.getOptions().getRequireFullySigned() || packet.isFlagSet(Packet.FLAG_SYNCHRONIZE | Packet.FLAG_CLOSE)) { // we need a valid signature Destination from = con.getRemotePeer(); if (from == null) from = packet.getOptionalFrom(); boolean sigOk = packet.verifySignature(_context, from, null); if (!sigOk) { throw new I2PException("Received unsigned / forged packet: " + packet); } } }