// 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( encTicketPartModifier, serverPrincipal, serverKey );
RequestBodyModifier modifier = new RequestBodyModifier();
modifier.setServerName( getPrincipalName( "hnelson" ) );
modifier.setRealm( "EXAMPLE.COM" );
modifier.setEType( config.getEncryptionTypes() );
modifier.setNonce( random.nextInt() );
KdcOptions kdcOptions = new KdcOptions();
kdcOptions.set( KdcOptions.VALIDATE );
modifier.setKdcOptions( kdcOptions );
long currentTime = System.currentTimeMillis();
KerberosTime requestedEndTime = new KerberosTime( currentTime + KerberosTime.DAY );
modifier.setTill( requestedEndTime );
RequestBody requestBody = modifier.getRequestBody();
KdcRequest message = getKdcRequest( tgt, requestBody );
handler.messageReceived( session, message );
TicketGrantReply reply = ( TicketGrantReply ) session.getMessage();
KerberosTime expectedRenewTillTime = tgt.getEncTicketPart().getRenewTill();
boolean isClose = Math.abs( reply.getRenewTill().getTime() - expectedRenewTillTime.getTime() ) < 5000;
assertTrue( "Expected renew till time", isClose );
}