com.jFormTK
Class JCryptography

java.lang.Object
  extended by com.jFormTK.JCryptography
All Implemented Interfaces:
JConstants

public class JCryptography
extends java.lang.Object
implements JConstants

This class is designed to perform the Cryptography functions required by the 'jFormTK' System. Included are the following operations: 1) One-Way Hash function [encrypt] used to encrypt the 'jFormTK' passwords... Note that only the encrypted password is saved. When an End User password is entered, it is encrypted and the encrypted and saved encrypted passwords are compared. 2) Data-Encription-Standard [DES] Symmetric Encryption w/ derived Key [makeDESKey, desEncrypt, desDecrypt]. NOTE 1: Not currently used... NOTE 2: Fails Stress test because of problems with storing the Encrypted Data in a Java String. The encrypted String causes random "Padding" problems during the conversion from xxx to String cipherText... Bottom Line: NEEDS More work if ever used... 3) Password-Based-Encryption [PBE] Symmetric Encryption with give plain text key. [makePBEKey, pbeEncrypt, pbeDecrypt]. Used to encrypt / decrypt 'JFormField' Data Entry Text Strings... Kernel Usage: 1) TBD

Version:
1.00, 26 March 2007
Author:
Jim Crowell
Professional Computer Solutions [PCS]
URL: http://jFormTK.com/
E-Mail: JimCrowell@EMail.com

Copyright (c) 2008 by Professional Computer Solutions [PCS]
All Rights Reserved

Field Summary
static java.lang.String DES
           
static java.lang.String PBE_WITH_MD5_AND_DES
           
static java.lang.String UTF8
           
 
Fields inherited from interface com.jFormTK.JConstants
__, _AB, _AB_, _AField, _B, _BField, _CField, _CIField, _DField, _EU_, _H, _HEIGHT, _HEIGHT_INV, _HField, _I, _IField, _LField, _MField, _NField, _NotRequired, _PField, _PIField, _QField, _Required, _RField, _TAField, _TField, _WIDTH, _WIDTH_INV, _XField, AB, APP_TRACE_FOCUS, APP_TRACE_GET, APP_TRACE_SET, B_, BAR, BAR_, BB, BH, BI, BREAKPOINT_FOCUS, BREAKPOINT_GET, BREAKPOINT_SET, BVB, C_QUOTE, CLOSE, CLOSE_BRACKET, COLORS_DELIMITER, COMMA, COMMA_, D_ELEMENT, D_ELEMENT_N, D_ELEMENT_N1, D_ELEMENT_N2, D_ELEMENT_N3, D_FIELDS, D_FIELDS_N, D_FIELDS_N1, D_FIELDS_N2, D_FIELDS_N3, D_ITEMS, DASH, DOT, EOL, EOP, EOS, FIELD_TRACE_FOCUS, FIELD_TRACE_GET, FIELD_TRACE_SET, FONT_DELIMITER, H_, HB, HH, HI, I_, IB, IH, II, JLAF_DELIMITER, LF, LISTBRACKET, NO, OPEN, OPEN_BRACKET, pCheckboxGroup, QUOTE, SPACE_, TAB, YES
 
Constructor Summary
JCryptography()
           
 
Method Summary
static java.lang.String encrypt(java.lang.String plainTextIn, boolean lowerCase)
           Use the "SHA" Message Dialog to create a "One-Way hash function given the plain text String.
static boolean makeECrypt(JFormForm form, java.lang.String from)
           If the 'ECrypt' Parameters are 'NUll' Then Compute the 'eCrypt' parameters for the given 'JFormForm' Sub-Class and store them into the associates 'JFormInfo' instance...
static javax.crypto.SecretKey makePBEKey(java.lang.String password, byte[] salt, int iterationCount)
           
static void myDESCryptoTest(java.lang.String s)
           
static void myPBECryptoTest(java.lang.String password, java.lang.String s, byte[] salt, int iterationCount)
           
static java.lang.String pbeDecrypt(java.lang.String cipherText, javax.crypto.Cipher pbeCipher)
           
static java.lang.String pbeDecrypt(java.lang.String password, java.lang.String secret, byte[] salt, int iterationCount)
           
static java.lang.String pbeEncrypt(java.lang.String plainText, javax.crypto.Cipher pbeCipher)
           
static java.lang.String pbeEncrypt(java.lang.String password, java.lang.String plainText, byte[] salt, int iterationCount)
           
static void setOwnerPassword(java.lang.String pass)
           Set the Owner Password...
static java.lang.String XXXdesDecrypt(java.security.Key key, java.lang.String cipherText)
           
static java.lang.String XXXdesEncrypt(java.security.Key key, java.lang.String plainText)
           
static java.security.Key XXXmakeDESKey()
           
static char[] XXXreadPasswd(java.io.InputStream in)
          Reads user password from given input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DES

public static final java.lang.String DES
See Also:
Constant Field Values

UTF8

public static final java.lang.String UTF8
See Also:
Constant Field Values

PBE_WITH_MD5_AND_DES

public static final java.lang.String PBE_WITH_MD5_AND_DES
See Also:
Constant Field Values
Constructor Detail

JCryptography

public JCryptography()
Method Detail

encrypt

public static java.lang.String encrypt(java.lang.String plainTextIn,
                                       boolean lowerCase)
        Use the "SHA" Message Dialog to create a "One-Way hash function given
        the plain text String. Convert the plain text to lower case if requested.
        Return the encrypted One-Way hash...

        Kernel Usage:
        1)      'JRegistration.processRegistry' method to perform a One-Way hash on the
                'Owner' Password prior to storage in the Registration Storage Medium...
        2)      'JRegistration.verifyApplication' method to verify the End User Entered
                'Owner' Password during the 'jFormTK' Authorization phase...
        3)      'JRegistration.doJCryptographyTest' DEBUG code to test various passwords...
        

Parameters:
plainTextIn - The plane text [String] to be encrypted...
lowerCase - Flag [Boolean]...
Returns:
Encrypted One=Way hash String... // @throws Exception

XXXmakeDESKey

public static java.security.Key XXXmakeDESKey()

XXXdesEncrypt

public static java.lang.String XXXdesEncrypt(java.security.Key key,
                                             java.lang.String plainText)

XXXdesDecrypt

public static java.lang.String XXXdesDecrypt(java.security.Key key,
                                             java.lang.String cipherText)

XXXreadPasswd

public static char[] XXXreadPasswd(java.io.InputStream in)
                            throws java.io.IOException
Reads user password from given input stream.

Throws:
java.io.IOException

myDESCryptoTest

public static void myDESCryptoTest(java.lang.String s)

makeECrypt

public static boolean makeECrypt(JFormForm form,
                                 java.lang.String from)
        If the 'ECrypt' Parameters are 'NUll'
        Then
                Compute the 'eCrypt' parameters for the given 'JFormForm' Sub-Class and store
                them into the associates 'JFormInfo' instance...

        Also, return a flag [boolean] that indicates if new 'ECrypt' parameters were built...

        Kernel Usage:
        1)      'JFormFrame.loadFormFieldsVector' after the 'form.init' method has created
                the initial 'JFormForm' Sub-Class instance...
        2)      'JFormForm.getFormFields' when a 'JFormForm' Sub-Class is loaded into the
                'jFormTK' Show Panel...
        

Parameters:
form - The 'JFormForm' Sub-Class to create the 'eCrypt' Control for...
from - DEBUG Annotation to inform where this method was envoked...
Returns:
Flag [boolean] = true iff new 'ECrypt' Parameters are built...

makePBEKey

public static javax.crypto.SecretKey makePBEKey(java.lang.String password,
                                                byte[] salt,
                                                int iterationCount)

pbeEncrypt

public static java.lang.String pbeEncrypt(java.lang.String password,
                                          java.lang.String plainText,
                                          byte[] salt,
                                          int iterationCount)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

pbeEncrypt

public static java.lang.String pbeEncrypt(java.lang.String plainText,
                                          javax.crypto.Cipher pbeCipher)

pbeDecrypt

public static java.lang.String pbeDecrypt(java.lang.String password,
                                          java.lang.String secret,
                                          byte[] salt,
                                          int iterationCount)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

pbeDecrypt

public static java.lang.String pbeDecrypt(java.lang.String cipherText,
                                          javax.crypto.Cipher pbeCipher)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

myPBECryptoTest

public static void myPBECryptoTest(java.lang.String password,
                                   java.lang.String s,
                                   byte[] salt,
                                   int iterationCount)

setOwnerPassword

public static void setOwnerPassword(java.lang.String pass)
        Set the Owner Password...
        NOTE:
        This is the One-Way Hash encrypted password used for 'jFormTK' Owner
        Authorization...

        Kernel Usage:
        1)      'JRegistration.processRegistry' method iff the registry is successfully
                installed...
        2)      'JRegistration.verifyApplication' method iff a Registere3d Name .reg file is found.
                The password is set into 'this' instance for further usage in the
                'jFormTK' Application [TBD]...
        

Parameters:
pass - One-Way Hash encrypted password String...