org.sandev.basics.util
Interface SandEncryptor

All Known Implementing Classes:
NullEncryptor, SampleEncryptor

public interface SandEncryptor

Simplified interface for reversable string encryption used in messaging and other applications. Refer to the implementing class docs for details.


Method Summary
 java.lang.String decrypt(AuthUser user, java.lang.String cyphertext)
          Decrypt the cyphertext and return the plaintext.
 java.lang.String encrypt(AuthUser user, java.lang.String plaintext)
          Encrypt the plaintext and return the cyphertext.
 long getCypherUserID(java.lang.String cyphertext)
          Return the uniqueID of the user who encrypted this cyphertext.
 

Method Detail

encrypt

public java.lang.String encrypt(AuthUser user,
                                java.lang.String plaintext)
                         throws SandEncryptorException
Encrypt the plaintext and return the cyphertext. If the user is null, then the implementation may throw an exception or return cyphertext that can be decrypted with a null user.

Throws:
SandEncryptorException

decrypt

public java.lang.String decrypt(AuthUser user,
                                java.lang.String cyphertext)
                         throws SandEncryptorException
Decrypt the cyphertext and return the plaintext. If the user is null, then the encryptor may throw an exception, or attempt to decrypt assuming that the user was null on the corresponding encrypt method invocation.

Throws:
SandEncryptorException

getCypherUserID

public long getCypherUserID(java.lang.String cyphertext)
                     throws SandEncryptorException
Return the uniqueID of the user who encrypted this cyphertext. In messaging applications where a single receiver services multiple incoming users, it must be possible to retrieve the uniqueID of the requesting user so that the user instance can be found, and subsequently used to decrypt the cyphertext.

This method may throw, or return zero, if the implementation is being used only to secure a communications channel, and the required decryption information is already known or is unused.

Throws:
SandEncryptorException