Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 5156 invoked from network); 23 Mar 2009 13:13:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Mar 2009 13:13:18 -0000 Received: (qmail 99165 invoked by uid 500); 23 Mar 2009 13:13:15 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 99114 invoked by uid 500); 23 Mar 2009 13:13:15 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 99104 invoked by uid 99); 23 Mar 2009 13:13:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Mar 2009 13:13:15 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of nilsga@gmail.com designates 209.85.220.163 as permitted sender) Received: from [209.85.220.163] (HELO mail-fx0-f163.google.com) (209.85.220.163) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Mar 2009 13:13:07 +0000 Received: by fxm7 with SMTP id 7so2092941fxm.11 for ; Mon, 23 Mar 2009 06:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=S3I/4E9VbV1Jc978UBo+IxKoL0h3tv1+fYR1UgoBiPc=; b=nUPnin89mm5QmIHQNN/FaKORPapqxImJoqf6vl1Fvuwon9wxuNR8iwhANxE8tPTX4o gQ4hvSvjJPBr1BSc7oVs8T52p4CRQGhAeHHpCthKtN/AHInc42TwJYC1uviDp5fYHHYM ZFjpvl6E8UC6R970pu5i0SPpG32FynlFsuoKc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=B2go9lbCD6/o9KV2y/T7c/gxXP4GiVODOsatj/ji00uRM3f9/uBI0QnmHjs/vs02hr HGS7aZRbyYVv0u0E9ev+S1StXXTjmeArMz8D2PI/cw0VS9IYEUWg52m3og9bFM8OKLuS 2kskG0Tc2nRRF9t64ZqP4OG1/W+Cdj8GUwWbw= MIME-Version: 1.0 Received: by 10.223.108.140 with SMTP id f12mr6009180fap.69.1237813967265; Mon, 23 Mar 2009 06:12:47 -0700 (PDT) In-Reply-To: References: Date: Mon, 23 Mar 2009 14:12:47 +0100 Message-ID: <7270d7cd0903230612p3956748w6c2e31f90aabf1e4@mail.gmail.com> Subject: Re: avoiding unwanted value stack manipulation From: Nils-Helge Garli Hegvik To: Struts Users Mailing List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org The documentation for the ParametersInterceptor [1] mentions the ParameterNameAware interface [2]. Maybe that could be a solution? Nils-H [1] - http://struts.apache.org/2.1.6/docs/parameters-interceptor.html [2] - http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/= xwork2/interceptor/ParameterNameAware.html On Mon, Mar 23, 2009 at 1:53 PM, Jos=E9 Santos wro= te: > hi, > > what's the recommended design for avoiding fields of DTOs in the value st= ack > being updated through (HTML) DOM manipulation? > > consider a typical edit page containing a form with some fields. this pag= e > is a visual representation of a DTO we are about to update. the DTO is se= t > in the action - it was fetched from the database during prepare() - and > therefore is accessible from the value stack (the JSP generating the edit > page populated the form fields with corresponding DTO fields using OGNL). > > by manipulating the DOM of the edit page (e.g. using Firebug) one can add= a > new input field to the form. this input field may correspond to a DTO > read-only instance variable we would like the action *not* to update. upo= n > form submission, the DTO is updated with all the form fields (existing on= es > + the one added to the DOM) and persisted in the database. > > there are several possible solutions to this issue: > > solution 1: validate the DTO before persisting it in the database. the DT= O > would be persisted only if no "read-only" fields were updated. this could= be > achieved e.g. through a comparison between the updated DTO and a clone of > the original DTO (fetched during prepare()). > > solution 2: another way to solve this would be to apply authorisation rul= es > in the model and therefore guarantee that certain DTO setters are > "read-only". > > solution 3: use a DTO proxy object instead of the DTO itself. the DTO pro= xy > object would contain the DTO read-write fields only. the DTO would then b= e > updated with the corresponding DTO proxy fields before being persisted in > the database. > > solution 4: not to use the "model-driven" approach and have setters in th= e > action corresponding to DTO read-write fields. the DTO would then be upda= ted > with the corresponding action fields before being persisted in the databa= se. > > i am not considering a solution where setters of "read-only" fields are > removed from the DTO class as this would invalidate the update of those > fields by anyone (which includes users with higher privileges). > > i would like to hear about your design solutions to this issue. > > thanks in advance, > santos. > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org