private static void buildReply( AuthenticationContext authContext ) throws KerberosException, InvalidTicketException
{
KdcReq request = authContext.getRequest();
Ticket ticket = authContext.getTicket();
AsRep reply = new AsRep();
reply.setCName( request.getKdcReqBody().getCName() );
reply.setCRealm( request.getKdcReqBody().getRealm() );
reply.setTicket( ticket );
EncKdcRepPart encKdcRepPart = new EncKdcRepPart();
encKdcRepPart.setKey( ticket.getEncTicketPart().getKey() );
// TODO - fetch lastReq for this client; requires store
// FIXME temporary fix, IMO we should create some new ATs to store this info in DIT
LastReq lastReq = new LastReq();
lastReq.addEntry( new LastReqEntry( LastReqType.TIME_OF_INITIAL_REQ, new KerberosTime() ) );
encKdcRepPart.setLastReq( lastReq );
// TODO - resp.key-expiration := client.expiration; requires store
encKdcRepPart.setNonce( request.getKdcReqBody().getNonce() );
encKdcRepPart.setFlags( ticket.getEncTicketPart().getFlags() );
encKdcRepPart.setAuthTime( ticket.getEncTicketPart().getAuthTime() );
encKdcRepPart.setStartTime( ticket.getEncTicketPart().getStartTime() );
encKdcRepPart.setEndTime( ticket.getEncTicketPart().getEndTime() );
if ( ticket.getEncTicketPart().getFlags().isRenewable() )
{
encKdcRepPart.setRenewTill( ticket.getEncTicketPart().getRenewTill() );
}
encKdcRepPart.setSName( ticket.getSName() );
encKdcRepPart.setSRealm( ticket.getRealm() );
encKdcRepPart.setClientAddresses( ticket.getEncTicketPart().getClientAddresses() );
EncAsRepPart encAsRepPart = new EncAsRepPart();
encAsRepPart.setEncKdcRepPart( encKdcRepPart );
if ( LOG.isDebugEnabled() )
{
monitorContext( authContext );
monitorReply( reply, encKdcRepPart );
}
EncryptionKey clientKey = authContext.getClientKey();
EncryptedData encryptedData = cipherTextHandler.seal( clientKey, encAsRepPart, KeyUsage.AS_REP_ENC_PART_WITH_CKEY );
reply.setEncPart( encryptedData );
reply.setEncKdcRepPart( encKdcRepPart );
authContext.setReply( reply );
}