sample java api

<auto97841-revL73yDgGBWk0Htik3J/[email protected]> Tue, 15 Jul 2003 08:14:47 -0700
Newsgroups gmane.comp.security.invisiblenet.iip.devel
Message-ID <[email protected]>
well, I got a message from nop late last night (well, 8am my time ;)
and I think he was asking for me to doc up how an API to this schebang
would work, so here's a sample based in Java.  

(note: as for name stuff, I've got I2P rather than IIP standing for invisible
internet project rather than invisible irc project, respectively.  we'll
discuss this evening, I just want something with a different acro ;)

So, an example use of that API could be:
  I2PClient client = new I2PClient();
  I2PSession sess = client.createSession("destKeyfile.cfg", options);
  sess.sendMessage(msgDest, "Hello I2P".getBytes());
  sess.destroySession();

Again, this is just an example.  If you're familiar with Java's JMS API,
 you'll notice that this is, well, identical.

Anyway, see y'all tonight
-jrandom
javaApi.txt (text/plain, 1.6 KB)
//Example Java API:

public interface I2PClient {
  Destination      createDestination(String keyFileToSaveTo);
  Destination      createDestination(String keyFileToSaveTo, Certificate paymentCert);
  I2PSession       createSession(String keyFileToLoadFrom, Properties options);
  I2PAdminSession  createSession(String adminPassword, Properties options);
}

public interface I2PSession {
  boolean sendMessage(Destination dest, byte[] payload);
  byte[]  recieveMessage(int msgId);
  void    reportAbuse(int msgId, int severity);
  void    setSessionListener(I2PSessionListener lsnr);
  void    destroySession();
}

public interface I2PSessionListener {
  void messageAvailable(I2PSession session, int msgId, long size);
  void reportAbuse(I2PSession session, int severity);
}

public interface I2PAdminSession {
  void            forceTunnelRotation();
  void            setBandwidthLimits(BandwidthLimits limits);
  BandwidthLimits getBandwidthLimits();
  void            setPassphrase(String old, String new);
  void            addPeerReferences(String peerSeedsFile);
  void            exportPeerReferences(String peerSeedsFile);
  void            clearPeerReferences();
  void            addTrustedPeerReferences(String peerSeedsFile);
  void            exportTrustedPeerReferences(String peerSeedsFile);
  void            clearTrustedPeerReferences();
  void            setAddressVisibility(boolean isVisible);
  boolean         getAddressVisibility();
  void            setAddressRotationPeriod(int numHours);
  int             getAddressRotationPeriod();
  void            forceAddressRotation();
}