Class KeyStoreFS

java.lang.Object
pygar.zoneable.KeyStoreFS
All Implemented Interfaces:
SessionKeyStore

@NotThreadSafe
public class KeyStoreFS
extends java.lang.Object
implements SessionKeyStore
This class contains methods to read and write a secret key stored in a file in the file system. We assume that the file is named "sessionkey" and that it is identified by the directory path. Consequently, we are also assuming that different sessions are stored in different file directories. Hence this class is intended for Pygar implementations that use the file system for managing session operations. Thread safety is dependent on the thread safety of the file system. Use only for testing - it does not distinguish session keys for different sessions.
  • Constructor Summary

    Constructors 
    Constructor Description
    KeyStoreFS​(java.lang.String keyStorePath)  
    KeyStoreFS​(java.lang.String keyStorePath, java.lang.String algorithm)  
  • Method Summary

    Modifier and Type Method Description
    javax.crypto.spec.SecretKeySpec getKey​(java.lang.String sessionid)
    Retrieve a key from a file named "sessionkey" in the directory given by path
    javax.crypto.spec.SecretKeySpec makeKey​(java.lang.String s)
    Create a key from a string value.
    javax.crypto.SecretKey newRandomKey()
    Create a new, random session key.
    void putKey​(java.lang.String sessionid, byte[] key)
    Put a key in a file named "sessionkey" in the directory given by path

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • KeyStoreFS

      public KeyStoreFS​(java.lang.String keyStorePath)
    • KeyStoreFS

      public KeyStoreFS​(java.lang.String keyStorePath, java.lang.String algorithm)
  • Method Details

    • putKey

      public void putKey​(java.lang.String sessionid, byte[] key) throws ConfigurationError
      Put a key in a file named "sessionkey" in the directory given by path
      Specified by:
      putKey in interface SessionKeyStore
      Parameters:
      path - the directory to put the key
      key - the key
      Throws:
      ConfigurationError
    • getKey

      public javax.crypto.spec.SecretKeySpec getKey​(java.lang.String sessionid) throws ConfigurationError
      Retrieve a key from a file named "sessionkey" in the directory given by path
      Specified by:
      getKey in interface SessionKeyStore
      Parameters:
      path -
      Returns:
      SecretKeySpec
      Throws:
      ConfigurationError
    • makeKey

      public javax.crypto.spec.SecretKeySpec makeKey​(java.lang.String s)
      Create a key from a string value.
      Parameters:
      s -
      Returns:
      SecretKeySpec
    • newRandomKey

      public javax.crypto.SecretKey newRandomKey()
      Create a new, random session key.
      Specified by:
      newRandomKey in interface SessionKeyStore