// Seal the ticket for the server.
KerberosPrincipal serverPrincipal = new KerberosPrincipal( "ldap/ldap.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( "ldap/ldap.example.com@EXAMPLE.COM" ) );
modifier.setRealm( "EXAMPLE.COM" );
modifier.setEType( config.getEncryptionTypes() );
modifier.setNonce( random.nextInt() );
KdcOptions kdcOptions = new KdcOptions();
modifier.setKdcOptions( kdcOptions );
KerberosTime requestedEndTime = new KerberosTime( now + KerberosTime.DAY / 2 );
modifier.setTill( requestedEndTime );
RequestBody requestBody = modifier.getRequestBody();
KdcRequest message = getKdcRequest( tgt, requestBody );
handler.messageReceived( session, message );
TicketGrantReply reply = ( TicketGrantReply ) session.getMessage();
KerberosTime expectedEndTime = tgt.getEncTicketPart().getEndTime();
boolean isClose = Math.abs( reply.getEndTime().getTime() - expectedEndTime.getTime() ) < 5000;
assertTrue( "Expected renew till time", isClose );
}