protected final Properties generateLTPAKeys ( byte [ ] keyPasswordBytes , final String realm ) throws Exception { Properties expProps = null ; try { KeyEncryptor encryptor = new KeyEncryptor ( keyPasswordBytes ) ; LTPAKeyPair pair = LTPADigSignature . generateLTPAKeyPair ( ) ; byte [ ] publicKey = pair . getPublic ( ) . getEncoded ( ) ; byte [ ] privateKey = pair . getPrivate ( ) . getEncoded ( ) ; byte [ ] encryptedPrivateKey = encryptor . encrypt ( privateKey ) ; byte [ ] sharedKey = LTPACrypto . generate3DESKey ( ) ; // key length is 24 for 3DES byte [ ] encryptedSharedKey = encryptor . encrypt ( sharedKey ) ; String tmpShared = Base64Coder . base64EncodeToString ( encryptedSharedKey ) ; String tmpPrivate = Base64Coder . base64EncodeToString ( encryptedPrivateKey ) ; String tmpPublic = Base64Coder . base64EncodeToString ( publicKey ) ; expProps = new Properties ( ) ; expProps . put ( KEYIMPORT_SECRETKEY , tmpShared ) ; expProps . put ( KEYIMPORT_PRIVATEKEY , tmpPrivate ) ; expProps . put ( KEYIMPORT_PUBLICKEY , tmpPublic ) ; expProps . put ( KEYIMPORT_REALM , realm ) ; expProps . put ( CREATION_HOST_PROPERTY , "localhost" ) ; expProps . put ( LTPA_VERSION_PROPERTY , "1.0" ) ; expProps . put ( CREATION_DATE_PROPERTY , ( new java . util . Date ( ) ) . toString ( ) ) ; } catch ( Exception e ) { throw e ; } return expProps ; }
Generates the LTPA keys and stores them into a Properties object .