EncryptionKey subKey = RandomKeyFactory.getRandomKey( tgt.getEncKdcRepPart().getKey().getKeyType() );
authenticator.setSubKey( subKey );
EncryptedData authData = cipherTextHandler.encrypt( tgt.getSessionKey(), getEncoded( authenticator ), KeyUsage.AP_REQ_AUTHNT_SESS_KEY );
apReq.setAuthenticator( authData );
KrbPriv privateMessage = new KrbPriv();
EncKrbPrivPart part = new EncKrbPrivPart();
part.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
part.setSeqNumber( authenticator.getSeqNumber() );
part.setTimestamp( authenticator.getCtime() );
short changePwdPVNO = ChangePasswordRequest.PVNO;
if( config.isUseLegacyChngPwdProtocol() )
{
part.setUserData( Strings.getBytesUtf8( newPassword ) );
changePwdPVNO = ChangePasswordRequest.OLD_PVNO;
}
else
{
ChangePasswdData chngPwdData = new ChangePasswdData();
chngPwdData.setNewPasswd( Strings.getBytesUtf8( newPassword ) );
//chngPwdData.setTargName( new PrincipalName( clientPrincipal, PrincipalNameType.KRB_NT_PRINCIPAL ) );
//chngPwdData.setTargRealm( clientTgtReq.getRealm() );
byte[] data = getEncoded( chngPwdData );
part.setUserData( data );
}
EncryptedData encKrbPrivPartData = cipherTextHandler.encrypt( subKey, getEncoded( part ), KeyUsage.KRB_PRIV_ENC_PART_CHOSEN_KEY );
privateMessage.setEncPart( encKrbPrivPartData );
ChangePasswordRequest req = new ChangePasswordRequest( changePwdPVNO, apReq, privateMessage );
channel = new KerberosChannel();