Tabnine Logo
SessionId.writeBytes
Code IndexAdd Tabnine to your IDE (free)

How to use
writeBytes
method
in
net.i2p.data.i2cp.SessionId

Best Java code snippets using net.i2p.data.i2cp.SessionId.writeBytes (Showing top 12 results out of 315)

origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_sessionId == null)
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(64);
  try {
    _sessionId.writeBytes(os);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_sessionId == null)
    throw new I2CPMessageException("No data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(256);
  try {
    _sessionId.writeBytes(os);
    DataHelper.writeLong(os, 1, _endpoints.size());
    for (int i = 0; i < _endpoints.size(); i++) {
      _endpoints.get(i).writeBytes(os);
    }
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_sessionId == null || _sessionConfig == null)
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(64);
  try {
    _sessionId.writeBytes(os);
    _sessionConfig.writeBytes(os);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_sessionId == null)
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(64);
  try {
    _sessionId.writeBytes(os);
    DataHelper.writeLong(os, 1, _status);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}

origin: i2p/i2p.i2p

protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  int len = 7;
  if (_code == RESULT_SUCCESS) {
    if (_dest == null)
      throw new I2CPMessageException("Unable to write out the message as there is not enough data");
    len += _dest.size();
  }
  ByteArrayOutputStream os = new ByteArrayOutputStream(len);
  try {
    _sessionId.writeBytes(os);
    DataHelper.writeLong(os, 4, _reqID);
    DataHelper.writeLong(os, 1, _code);
    if (_code == RESULT_SUCCESS)
      _dest.writeBytes(os);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("bad data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_sessionId == null)
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(256);
  try {
    _sessionId.writeBytes(os);
    DataHelper.writeLong(os, 1, _endpoints.size());
    for (int i = 0; i < _endpoints.size(); i++) {
      Hash router = getRouter(i);
      router.writeBytes(os);
      TunnelId tunnel = getTunnelId(i);
      tunnel.writeBytes(os);
    }
    DataHelper.writeDate(os, _end);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if ((_sessionId == null) || (_severity == null) || (_reason == null))
    throw new I2CPMessageException("Not enough information to construct the message");
  ByteArrayOutputStream os = new ByteArrayOutputStream(32);
  try {
    _sessionId.writeBytes(os);
    _severity.writeBytes(os);
    _reason.writeBytes(os);
    if (_messageId == null) {
      _messageId = new MessageId();
      _messageId.setMessageId(0);
    }
    _messageId.writeBytes(os);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if ((_sessionId == null) || (_signingPrivateKey == null) || (_privateKey == null) || (_leaseSet == null))
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  int size = 4 // sessionId
       + _signingPrivateKey.length()
       + PrivateKey.KEYSIZE_BYTES
       + _leaseSet.size();
  ByteArrayOutputStream os = new ByteArrayOutputStream(size);
  try {
    _sessionId.writeBytes(os);
    _signingPrivateKey.writeBytes(os);
    _privateKey.writeBytes(os);
    _leaseSet.writeBytes(os);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  int len;
  if (_lookupType == LOOKUP_HASH) {
    if (_hash == null)
      throw new I2CPMessageException("Unable to write out the message as there is not enough data");
    len = 11 + Hash.HASH_LENGTH;
  } else if (_lookupType == LOOKUP_HOST) {
    if (_host == null)
      throw new I2CPMessageException("Unable to write out the message as there is not enough data");
    len = 12 + _host.length();
  } else {
    throw new I2CPMessageException("bad type");
  }
  ByteArrayOutputStream os = new ByteArrayOutputStream(len);
  try {
    _sessionId.writeBytes(os);
    DataHelper.writeLong(os, 4, _reqID);
    DataHelper.writeLong(os, 4, _timeout);
    DataHelper.writeLong(os, 1, _lookupType);
    if (_lookupType == LOOKUP_HASH) {
      _hash.writeBytes(os);
    } else {
      DataHelper.writeString(os, _host);
    }
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("bad data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  int type = _leaseSet.getType();
  if (_sessionId == null || _leaseSet == null ||
    (type != DatabaseEntry.KEY_TYPE_META_LS2 && (_signingPrivateKey == null || _privateKey == null)))
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  int size = 4 // sessionId
       + 1 // type
       + _leaseSet.size()
       + _signingPrivateKey.length()
       + _privateKey.length();
  ByteArrayOutputStream os = new ByteArrayOutputStream(size);
  try {
    _sessionId.writeBytes(os);
    os.write(_leaseSet.getType());
    _leaseSet.writeBytes(os);
    if (type != DatabaseEntry.KEY_TYPE_META_LS2) {
      _signingPrivateKey.writeBytes(os);
      for (PrivateKey pk : getPrivateKeys()) {
        pk.writeBytes(os);
      }
    }
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

/**
 * Write out the full message to the stream, including the 4 byte size and 1 
 * byte type header.  Override the parent so we can be more mem efficient
 *
 * @throws IOException 
 */
@Override
public void writeMessage(OutputStream out) throws I2CPMessageException, IOException {
  if (_sessionId == null)
    throw new I2CPMessageException("No session ID");
  if (_destination == null)
    throw new I2CPMessageException("No dest");
  if (_payload == null)
    throw new I2CPMessageException("No payload");
  if (_nonce < 0)
    throw new I2CPMessageException("No nonce");
  int len = 2 + _destination.size() + _payload.getSize() + 4 + 4;
  
  try {
    DataHelper.writeLong(out, 4, len);
    out.write((byte) getType());
    _sessionId.writeBytes(out);
    _destination.writeBytes(out);
    _payload.writeBytes(out);
    DataHelper.writeLong(out, 4, _nonce);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing the msg", dfe);
  }
}

origin: i2p/i2p.i2p

DataHelper.writeLong(out, 4, len);
out.write((byte) MESSAGE_TYPE);
_sessionId.writeBytes(out);
_destination.writeBytes(out);
_payload.writeBytes(out);
net.i2p.data.i2cpSessionIdwriteBytes

Popular methods of SessionId

  • <init>
  • getSessionId
  • equals
  • readBytes
  • setSessionId

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • getContentResolver (Context)
  • findViewById (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Permission (java.security)
    Legacy security code; do not use.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now