* @return The {@link ChangePasswordError}.
* @throws IOException
*/
public ChangePasswordError decode( ByteBuffer buf ) throws IOException
{
ChangePasswordErrorModifier modifier = new ChangePasswordErrorModifier();
short messageLength = buf.getShort();
modifier.setProtocolVersionNumber( buf.getShort() );
// AP_REQ length will be 0 for error messages
buf.getShort(); // authHeader length
int errorLength = messageLength - HEADER_LENGTH;
byte[] errorBytes = new byte[errorLength];
buf.get( errorBytes );
ByteBuffer errorBuffer = ByteBuffer.wrap( errorBytes );
ErrorMessageDecoder errorDecoder = new ErrorMessageDecoder();
ErrorMessage errorMessage = errorDecoder.decode( errorBuffer );
modifier.setErrorMessage( errorMessage );
return modifier.getChangePasswordError();
}