// Seal the ticket for the server.
KerberosPrincipal serverPrincipal = new KerberosPrincipal( "krbtgt/EXAMPLE.COM@EXAMPLE.COM" );
String passPhrase = "randomKey";
EncryptionKey serverKey = getEncryptionKey( serverPrincipal, passPhrase );
Ticket tgt = getTicket( encTicketPart, serverPrincipal, serverKey );
KdcReqBody kdcReqBody = new KdcReqBody();
kdcReqBody.setSName( getPrincipalName( "hnelson" ) );
kdcReqBody.setRealm( "EXAMPLE.COM" );
kdcReqBody.setEType( config.getEncryptionTypes() );
kdcReqBody.setNonce( random.nextInt() );
KdcOptions kdcOptions = new KdcOptions();
kdcOptions.set( KdcOptions.VALIDATE );
kdcReqBody.setKdcOptions( kdcOptions );
long currentTime = System.currentTimeMillis();
KerberosTime requestedEndTime = new KerberosTime( currentTime + KerberosTime.DAY );
kdcReqBody.setTill( requestedEndTime );
KdcReq message = getKdcRequest( tgt, kdcReqBody );
handler.messageReceived( session, message );
Object msg = session.getMessage();
assertEquals( "session.getMessage() instanceOf", TgsRep.class, msg.getClass() );
TgsRep reply = ( TgsRep ) msg;
KerberosTime expectedRenewTillTime = tgt.getEncTicketPart().getRenewTill();
boolean isClose = Math.abs( reply.getRenewTill().getTime() - expectedRenewTillTime.getTime() ) < 5000;
assertTrue( "Expected renew till time", isClose );
}