|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.ucf.cs.courses.cop4610l.beans.crypto.Crypto
A JavaBean that encapsulates common encryption functions. It takes as an
argument an InputStream
and returns (via an event) another
InputStream
that can be consumed by another object.
Field Summary | |
private static java.lang.String |
KEY_PASSWORD
Password for individual keys in the keystore. |
private static java.lang.String |
KEY_PREFIX
Prefix for all keys created by beans of this type. |
private static java.lang.String |
KEYSTORE_FILENAME
Filename of the keystore of type "JCEKS" which holds all keys generated by any beans of this type. |
private static java.lang.String |
KEYSTORE_PASSWORD
Password for keystore in KEYSTORE_FILENAME . |
private java.util.Set |
listeners
Listeners of TransformCompletedEvent s. |
private java.lang.String |
symmetricCipherName
The symmetric algorithm for this bean to use (default is "DES"). |
private java.io.InputStream |
symmetricTransformedStream
The stream that is consumed by listeners when a TransformCompletedEvent is fired. |
Constructor Summary | |
Crypto()
|
Method Summary | |
void |
addTransformCompletedListener(TransformCompletedListener listener)
This bean currently can only support one listener. |
void |
doSymmetricDecrypt(java.io.InputStream in)
Decrypts contents of in using the algorithm specified by
symmetricCipherName . |
void |
doSymmetricEncrypt(java.io.InputStream in)
Encrypts contents of in using the algorithm specified by
symmetricCipherName . |
private void |
doSymmetricTransform(java.io.InputStream in,
int cipherMode)
Used by both doSymmmetricEncrypt and
doSymmetricDecrypt . |
private java.security.Key |
findKey(java.lang.String cipherName)
This method does the following: Loads keystore if it exists on disk. |
private void |
fireTransformCompleted(TransformCompletedEvent e)
|
java.lang.String |
getSymmetricCipherName()
|
java.io.InputStream |
getSymmetricTransformedStream()
There is only a getter method for this property since it is read-only. |
void |
removeTransformCompletedListener(TransformCompletedListener listener)
|
void |
setSymmetricCipherName(java.lang.String symmetricCipherName)
|
Methods inherited from class java.lang.Object |
|
Field Detail |
private java.lang.String symmetricCipherName
private static final java.lang.String KEYSTORE_FILENAME
private static final java.lang.String KEYSTORE_PASSWORD
KEYSTORE_FILENAME
.private static final java.lang.String KEY_PASSWORD
private static final java.lang.String KEY_PREFIX
private java.util.Set listeners
TransformCompletedEvent
s.private java.io.InputStream symmetricTransformedStream
TransformCompletedEvent
is fired.Constructor Detail |
public Crypto()
Method Detail |
public java.io.InputStream getSymmetricTransformedStream()
TransformCompletedEvent
.public java.lang.String getSymmetricCipherName()
public void setSymmetricCipherName(java.lang.String symmetricCipherName)
public void doSymmetricEncrypt(java.io.InputStream in)
in
using the algorithm specified by
symmetricCipherName
. A TransformCompletedEvent
is fired when done.in
- the stream to encryptpublic void doSymmetricDecrypt(java.io.InputStream in)
in
using the algorithm specified by
symmetricCipherName
. A TransformCompletedEvent
is fired when done.in
- the stream to decryptprivate java.security.Key findKey(java.lang.String cipherName) throws java.lang.Exception
cipherName
exists,
it returns it. Otherwise it creates a new key with the given algorithm,
stores it in the keystore, then saves the updated keystore.cipherName
- algorithm of key to look forprivate void doSymmetricTransform(java.io.InputStream in, int cipherMode)
doSymmmetricEncrypt
and
doSymmetricDecrypt
. The only difference between the two
methods is the Cipher
mode.in
- cipherMode
- public void addTransformCompletedListener(TransformCompletedListener listener) throws java.util.TooManyListenersException
listener
- java.util.TooManyListenersException
- if more than one listener attempts to addpublic void removeTransformCompletedListener(TransformCompletedListener listener)
private void fireTransformCompleted(TransformCompletedEvent e)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |