}
private static void buildReply( ChangePasswordContext changepwContext ) throws KerberosException, UnknownHostException
{
Authenticator authenticator = changepwContext.getAuthenticator();
Ticket ticket = changepwContext.getTicket();
CipherTextHandler cipherTextHandler = changepwContext.getCipherTextHandler();
// begin building reply
// create priv message
// user-data component is short result code
EncKrbPrivPart privPart = new EncKrbPrivPart();
// first two bytes are the result code, rest is the string 'Password Changed' followed by a null char
byte[] resultCode =
{ ( byte ) 0x00, ( byte ) 0x00, (byte)0x50, (byte)0x61, (byte)0x73, (byte)0x73, (byte)0x77, (byte)0x6F, (byte)0x72, (byte)0x64, (byte)0x20, (byte)0x63, (byte)0x68, (byte)0x61, (byte)0x6E, (byte)0x67, (byte)0x65, (byte)0x64, (byte)0x00 };
privPart.setUserData( resultCode );
privPart.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
// get the subsession key from the Authenticator
EncryptionKey subSessionKey = authenticator.getSubKey();
EncryptedData encPrivPart;
try
{
encPrivPart = cipherTextHandler.seal( subSessionKey, privPart, KeyUsage.KRB_PRIV_ENC_PART_CHOSEN_KEY );
}
catch ( KerberosException ke )
{
throw new ChangePasswordException( ChangePasswdErrorType.KRB5_KPASSWD_SOFTERROR, ke );
}
KrbPriv privateMessage = new KrbPriv();
privateMessage.setEncPart( encPrivPart );
// Begin AP_REP generation
EncApRepPart repPart = new EncApRepPart();
repPart.setCTime( authenticator.getCtime() );
repPart.setCusec( authenticator.getCusec() );
if ( authenticator.getSeqNumber() != null )
{
repPart.setSeqNumber( authenticator.getSeqNumber() );
}
repPart.setSubkey( subSessionKey );
EncryptedData encRepPart;