kdcReqBody.setKdcOptions( new KdcOptions() );
long now = System.currentTimeMillis();
KerberosTime requestedEndTime = new KerberosTime( now + KerberosTime.DAY );
kdcReqBody.setTill( requestedEndTime );
KerberosPrincipal clientPrincipal = new KerberosPrincipal( "hnelson@EXAMPLE.COM" );
String passPhrase = "secret";
PaData[] paDatas = getPreAuthEncryptedTimeStamp( clientPrincipal, passPhrase );
KdcReq message = new AsReq();
message.setKdcReqBody( kdcReqBody );
for ( PaData paData : paDatas )
{
message.addPaData( paData );
}
handler.messageReceived( session, message );
Object msg = session.getMessage();
assertEquals( "session.getMessage() instanceOf", AsRep.class, msg.getClass() );
AsRep reply = ( AsRep ) msg;
KerberosTime expectedStartTime = new KerberosTime( now );
boolean isClose = reply.getStartTime() == null
|| Math.abs( reply.getStartTime().getTime() - expectedStartTime.getTime() ) < 5000;
assertTrue( "Expected start time", isClose );
}