Class CryptoServiceUser

java.lang.Object
de.das.encrypter.examples.CryptoServiceUser
All Implemented Interfaces:
DataReceiver, ActionListener, EventListener

public class CryptoServiceUser extends Object implements ActionListener, DataReceiver
This example requests a key from the Encrypter-X crypto service, encrypts an image, and writes it back encrypted to a file. The requested and used key is in memory only for a short time and only during use. After running this example, the encrypted file can be viewed using the Encrypter-X browser function.

The requirements for running this example are that the Encrypter-X is running on this or another machine, its crypto service is configured (port is defined), the Encrypter-X and this example know the same keyring, and this example knows the IP address of the crypto service's home (usually localhost="127.0.0.1").
  • Constructor Details

    • CryptoServiceUser

      public CryptoServiceUser() throws Exception
      Create a new instance of CryptoServiceUser.
      Throws:
      Exception - if the receiver port is not available.
  • Method Details

    • main

      public static void main(String[] args)
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      If the crypto service is not available or our request could not be fulfilled, the program will timeout.
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - an action event.
    • setData

      public void setData(String host, byte[] data)
      Incoming data from the crypto service.
      Specified by:
      setData in interface DataReceiver
      Parameters:
      host - the IP-address of the sender.
      data - the byte array sent by the sender.
    • setData

      public void setData(byte[] data)
      Incoming data from the crypto service. There can be three different types of messages. It can be a block of the requested data, where the first block initializes the reception, it can be an information why the request was rejected or it is the message that the transmission is finished.
      Specified by:
      setData in interface DataReceiver
      Parameters:
      data - the byte array sent by the sender.