{
EncryptionType[] configuredEncryptionTypes =
{ EncryptionType.AES128_CTS_HMAC_SHA1_96 };
config.setEncryptionTypes( configuredEncryptionTypes );
RequestBodyModifier modifier = new RequestBodyModifier();
modifier.setClientName( getPrincipalName( "hnelson" ) );
modifier.setServerName( getPrincipalName( "krbtgt/EXAMPLE.COM@EXAMPLE.COM" ) );
modifier.setRealm( "EXAMPLE.COM" );
Set<EncryptionType> encryptionTypes = new HashSet<EncryptionType>();
encryptionTypes.add( EncryptionType.AES128_CTS_HMAC_SHA1_96 );
modifier.setEType( encryptionTypes );
int nonce = random.nextInt();
modifier.setNonce( nonce );
modifier.setKdcOptions( new KdcOptions() );
long now = System.currentTimeMillis();
KerberosTime requestedEndTime = new KerberosTime( now + KerberosTime.DAY );
modifier.setTill( requestedEndTime );
String principalName = "hnelson@EXAMPLE.COM";
String passPhrase = "secret";
Set<EncryptionType> preAuthEncryptionTypes = new HashSet<EncryptionType>();
preAuthEncryptionTypes.add( EncryptionType.AES128_CTS_HMAC_SHA1_96 );
Map<EncryptionType, EncryptionKey> keyMap = KerberosKeyFactory.getKerberosKeys( principalName, passPhrase,
preAuthEncryptionTypes );
EncryptionKey clientKey = keyMap.get( EncryptionType.AES128_CTS_HMAC_SHA1_96 );
KerberosTime timeStamp = new KerberosTime();
PaData[] paData = getPreAuthEncryptedTimeStamp( clientKey, timeStamp );
KdcRequest message = new KdcRequest( KerberosConstants.KERBEROS_V5, KerberosMessageType.AS_REQ, paData, modifier.getRequestBody() );
handler.messageReceived( session, message );
AuthenticationReply reply = ( AuthenticationReply ) session.getMessage();