java - Vulnerabilities using model beans in view JSP -


i saw hundreds of examples in spring , struts model beans used in view , know if vulnerability , best approach solve it.

a dumb example. have model bean:

public class user {     private string name;     private string pass;     //getters , setters } 

and have views (jsp)

  1. adminview: view allowed admin have form 2 fields (name , password).
  2. userview: view common users have form 1 field (name)

in service layer (which should abstract view) have method:

if(pass.isempty)    createnormaluser(); else     createadminuser(); 

in userview intruder use both fields (modifying data in browser example) due opened in both views (userview , adminview) because same bean (user).

ok dumb example in complex webapp priori can not guarantee behavior model beans avoid because can have complex business logic , hundred of cases modify bean produce unwanted behavior. more, having in mind service layer should independent view layer.

so necessary control in controllers layer (controllers in spring or actions in struts).

what best approach solve it?

  • using form beans contains object of type our bean model getters , setters fields used in form.
  • validate in each controller fields in form allowed come data
  • other?


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -