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();
channel.openConnection( config.getHostName(), config.getPasswdPort(), config.getTimeout(), config.isUseUdp() );
AbstractPasswordMessage reply = sendAndReceiveChngPwdMsg( req, channel );
if ( reply instanceof ChangePasswordError )
{
ChangePasswordError err = ( ChangePasswordError ) reply;
ChangePasswordResult result = new ChangePasswordResult( err.getKrbError().getEData() );
return result;
}
ChangePasswordReply chngPwdReply = ( ChangePasswordReply ) reply;
KrbPriv replyPriv = chngPwdReply.getPrivateMessage();
// the same subKey present in ApReq is used for encrypting the KrbPriv present in reply
byte[] data = cipherTextHandler.decrypt( subKey, replyPriv.getEncPart(), KeyUsage.KRB_PRIV_ENC_PART_CHOSEN_KEY );
part = KerberosDecoder.decodeEncKrbPrivPart( data );
ChangePasswordResult result = new ChangePasswordResult( part.getUserData() );
return result;
}
catch( ChangePasswordException e )
{