sam.cipher
Class Specification

java.lang.Object
  |
  +--sam.cipher.Specification

public class Specification
extends java.lang.Object

Class specifying a cipher with its associated password This basically reduces to a pair cipher name, password.


Field Summary
 java.lang.String name
          The choosen cipher name
 java.lang.String password
          The choosen password
 
Constructor Summary
Specification(java.lang.String cipher)
          Built a new specification without password.
Specification(java.lang.String cipher, java.lang.String password)
          Built a new specification with specified password.
 
Method Summary
static boolean areFullySpecified(sam.cipher.Specification[] specifications)
           
static sam.cipher.Specification[] dropEmpty(sam.cipher.Specification[] specifications)
          Drops all specifications whose password is null or empty
static sam.cipher.Specification[] fillIn(java.lang.String[] ciphers, java.lang.String[] passwords)
          Fills cipher and password specifications into an array of Specifications.
 sam.cipher.Cipher getCipher(boolean mode)
          Instantiates this specification to a proper Cipher
static sam.cipher.Cipher[] getCiphers(sam.cipher.Specification[] specifications, boolean mode)
          Instantiates a specification list to a proper Ciphers list.
 java.lang.String getDescription()
          Gets the human-readable description of this cipher.
static java.lang.String[] getNames(sam.cipher.Specification[] specifications)
          Gets the names of a stack of specifications.
static sam.cipher.Specification[] getRegisteredCiphers()
          Gets the list of all currently registerd ciphers as a Specification[] list.
 boolean isEmpty()
          Wether this specifications is empty, i.e.
 java.lang.String toString()
          Human-readable specification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public final java.lang.String name
The choosen cipher name


password

public final transient java.lang.String password
The choosen password

Constructor Detail

Specification

public Specification(java.lang.String cipher)
Built a new specification without password.

Parameters:
cipher - the name of a registered cipher

Specification

public Specification(java.lang.String cipher,
                     java.lang.String password)
Built a new specification with specified password.

Parameters:
cipher - the name of a registered cipher
password - the associated passphrase
Method Detail

isEmpty

public boolean isEmpty()
Wether this specifications is empty, i.e. has an empty cipher name or password


getCipher

public sam.cipher.Cipher getCipher(boolean mode)
                            throws java.lang.Error
Instantiates this specification to a proper Cipher

Parameters:
mode - wether the cipher should be a ciphering or a deciphering cipher
Returns:
null if passwords is null or empty
java.lang.Error

toString

public java.lang.String toString()
Human-readable specification. Warning: this includes the password in plain text !

Overrides:
toString in class java.lang.Object

getDescription

public java.lang.String getDescription()
Gets the human-readable description of this cipher.


getCiphers

public static sam.cipher.Cipher[] getCiphers(sam.cipher.Specification[] specifications,
                                             boolean mode)
Instantiates a specification list to a proper Ciphers list. This automatically drops ciphers whose password is null or empty

Parameters:
mode - wether the cipher should be a ciphering or a deciphering cipher
Returns:
null any instantiation fails due to an Error

areFullySpecified

public static boolean areFullySpecified(sam.cipher.Specification[] specifications)
Returns:
wether all required passwords are specified among passed specifications, or if specifications is null

getRegisteredCiphers

public static sam.cipher.Specification[] getRegisteredCiphers()
Gets the list of all currently registerd ciphers as a Specification[] list. No default password is ever supplied.

See Also:
Registry.getCiphers

dropEmpty

public static sam.cipher.Specification[] dropEmpty(sam.cipher.Specification[] specifications)
Drops all specifications whose password is null or empty


getNames

public static java.lang.String[] getNames(sam.cipher.Specification[] specifications)
Gets the names of a stack of specifications.


fillIn

public static sam.cipher.Specification[] fillIn(java.lang.String[] ciphers,
                                                java.lang.String[] passwords)
Fills cipher and password specifications into an array of Specifications. Cipher and passwords are matched one-by-one from the first element of each array. Note that some passwords are allowed to be missing in which case they will get empty; on the other hand there should not be more passwords than ciphers.

Parameters:
ciphers - the ordered list of ciphers
passwords - the ordered list of passwords