Class CryptoServer

java.lang.Object
de.das.encrypter.cryptoservice.CryptoServer
All Implemented Interfaces:
DataReceiver, ResultReceiver, ActionListener, EventListener

public class CryptoServer extends Object implements DataReceiver, ActionListener, ResultReceiver
Keys can be requested via this server. It receives requests consisting of an encrypted string containing a key ID and the desired length of the key separated by a semicolon. If a key with this ID is available and it is possible to provide the required length, the server starts sending a key block by block.
  • Field Details

  • Constructor Details

  • Method Details

    • createInstance

      public static void createInstance(KeyFiles kfs, int port, EntryPointSupplier eps) throws Exception
      Throws:
      Exception
    • setCryptoKeyId

      public static void setCryptoKeyId(Long id)
      Sets the ID of the key bundle to be used to encrypt the key part to be returned based on the request.
      Parameters:
      id - the ID of a key bundle.
    • getCryptoKeyId

      public static Long getCryptoKeyId()
      Returns the current ID of the key used for encryption of requests and keys.
      Returns:
    • newPort

      public static void newPort(int port)
      Changes the port where the crypto service is offered.
      Parameters:
      port - the new port number.
    • setData

      public void setData(byte[] data)
      Unused interface methode.
      Specified by:
      setData in interface DataReceiver
      Parameters:
      data -
    • setData

      public void setData(String host, byte[] data)
      Receives data and checks if the data length is smaller than 80 bytes, the data is encrypted, if the required key for decryption is available and if a "crypto key ID" has been set for the encryption of the key to be sent. If these conditions are met, the received data will be passed for decryption and if executable to start the broadcast. If one of these conditions is not met, the request is ignored.
      Specified by:
      setData in interface DataReceiver
      Parameters:
      host - the IP-address of the receiver.
      data - received data via UDP service receiver.
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Receiver of an action event in case of a time out situation.
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - an action event.
    • setResult

      public void setResult(int result, String info)
      The result information coming from the transfer control instance.
      Specified by:
      setResult in interface ResultReceiver
      Parameters:
      result - an integer with information whether a transfer was successful or failed.
      info - an optional and additional information text.