EncryptionKey subSessionKey = authenticator.getSubKey();
// decrypt the request's private message with the subsession key
EncryptedData encReqPrivPart = request.getPrivateMessage().getEncryptedPart();
EncKrbPrivPart privatePart;
try
{
privatePart = ( EncKrbPrivPart ) cipherTextHandler.unseal( EncKrbPrivPart.class, subSessionKey,
encReqPrivPart, KeyUsage.KRB_PRIV_ENC_PART_CHOSEN_KEY );
}
catch ( KerberosException ke )
{
throw new ChangePasswordException( ErrorType.KRB5_KPASSWD_SOFTERROR, ke );
}
ChangePasswordData passwordData = null;
if ( request.getVersionNumber() == ( short ) 1 )
{
// Use protocol version 0x0001, the legacy Kerberos change password protocol
ChangePasswordDataModifier modifier = new ChangePasswordDataModifier();
modifier.setNewPassword( privatePart.getUserData() );
passwordData = modifier.getChangePasswdData();
}
else
{
// Use protocol version 0xFF80, the backwards-compatible MS protocol
ChangePasswordDataDecoder passwordDecoder = new ChangePasswordDataDecoder();
passwordData = passwordDecoder.decodeChangePasswordData( privatePart.getUserData() );
}
try
{
changepwContext.setPassword( new String( passwordData.getPassword(), "UTF-8" ) );