org.universAAL.middleware.connectors.communication.jgroups.util
Class CryptUtil

Package class diagram package CryptUtil
java.lang.Object
  extended by org.universAAL.middleware.connectors.communication.jgroups.util.CryptUtil

public class CryptUtil
extends Object

A utility class for managing private/public keys and encrypting/decrypting strings

Author:
mtazari - Saied Tazari

Constructor Summary
CryptUtil()
           
 
Method Summary
static String decrypt(String cipher)
          decrypt the parameter string with the shared key read during initialization
static String encrypt(String clear)
          encrypt the parameter string with the shared key read during initialization
 void generateKeyPair()
          generate a pair of keys - public and private, and write them to the files with the names "public.key" and "private.key"
static String init(String dir, Codec codec)
          Initialization method - reads the shared key from the file system or generates a new shared key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CryptUtil

public CryptUtil()
Method Detail

init

public static String init(String dir,
                          Codec codec)
                   throws Exception
Initialization method - reads the shared key from the file system or generates a new shared key

Parameters:
String - dir - the directory where the shared key file resides
codec - the codec to be used for encoding and decoding messages (e.g. Base64)
Throws:
Exception

decrypt

public static String decrypt(String cipher)
                      throws Exception
decrypt the parameter string with the shared key read during initialization

Parameters:
String - chiper - the string to decrypt
Returns:
the decrypted string
Throws:
Exception

encrypt

public static String encrypt(String clear)
                      throws Exception
encrypt the parameter string with the shared key read during initialization

Parameters:
String - clear - the string to encrypt
Returns:
the encrypted string
Throws:
Exception

generateKeyPair

public void generateKeyPair()
                     throws Exception
generate a pair of keys - public and private, and write them to the files with the names "public.key" and "private.key"

Throws:
Exception


Copyright © 2014 universAAL Consortium. All Rights Reserved.