Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 4568 invoked from network); 16 Jul 2009 18:47:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Jul 2009 18:47:45 -0000 Received: (qmail 94077 invoked by uid 500); 16 Jul 2009 18:48:48 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 94003 invoked by uid 500); 16 Jul 2009 18:48:48 -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 93993 invoked by uid 99); 16 Jul 2009 18:48:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jul 2009 18:48:48 +0000 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [155.91.38.113] (HELO taz.merck.com) (155.91.38.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jul 2009 18:48:36 +0000 X-IronPort-AV: E=Sophos;i="4.42,412,1243828800"; d="scan'208";a="230483352" Received: from unknown (HELO ipmh2.merck.com) ([54.62.195.240]) by taz.merck.com with ESMTP; 16 Jul 2009 14:48:10 -0400 X-IronPort-AV: E=Sophos;i="4.42,412,1243828800"; d="scan'208";a="164286344" Received: from usctcl1-usctcl2-intranet-snat.merck.com (HELO usctgw1104.merck.com) ([54.62.195.245]) by ipmh2.merck.com with ESMTP; 16 Jul 2009 14:48:08 -0400 Received: from USCTMX1140.merck.com ([54.50.72.134]) by usctgw1104.merck.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 16 Jul 2009 14:48:08 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: RE: Login with Struts2 Date: Thu, 16 Jul 2009 14:48:08 -0400 Message-ID: <2CDB225E3067C043A2FF13D8844F5D1802D7FB43@USCTMX1140.merck.com> In-Reply-To: <24522078.post@talk.nabble.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Login with Struts2 Thread-Index: AcoGRIsraXVEHC+aRz+ZvRhduLiH/gAAOd8w References: <24522078.post@talk.nabble.com> From: "Kawczynski, David" To: "Struts Users Mailing List" X-OriginalArrivalTime: 16 Jul 2009 18:48:08.0870 (UTC) FILETIME=[F6542460:01CA0645] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Take a look at Spring Security (formerly ACEGI). =20 http://static.springsource.org/spring-security/site/ > -----Original Message----- > From: mathias-ewald [mailto:nitehoaxxer@gmx.net]=20 > Sent: Thursday, July 16, 2009 2:37 PM > To: user@struts.apache.org > Subject: Login with Struts2 >=20 >=20 > Hi, >=20 > I am trying to implement a login mechanism. I will now=20 > explain what I did > and what error I get but in case there is a more=20 > sophisticated way to do > that - please tell me! >=20 > I created a BaseAction which is the parent of all my Actions.=20 > The BaseAction > is supposed to be responsible for displaying a login page if=20 > there is no > User object in session scope. Then the login form should put=20 > the username > and password into the BaseAction. The BaseAction then tries=20 > to find a match > in the database and places the User object into session scope: >=20 > --------------------- > public abstract class BaseAction { >=20 > private String username; > =09 > private String password; > =09 > protected Log log; > =09 > private Boolean loginStatus; > =09 > =09 > public String execute() { > if(log =3D=3D null) { > log =3D LogFactory.getLog(getClass()); > } > =09 > if(isProtected()) { > Map session =3D=20 > ActionContext.getContext().getSession(); > Object o =3D session.get("user"); > if(o instanceof User) { > loginStatus =3D true; > } else { > return "login"; > } > } > =09 > =09 > return executeAction(); > } >=20 > =09 > public abstract String executeAction(); >=20 > public abstract Boolean isProtected(); > =09 >=20 > public Boolean getLoginStatus() { > return loginStatus; > } >=20 > public void setLoginStatus(Boolean loginStatus) { > this.loginStatus =3D loginStatus; > } >=20 > public String getUsername() { > return username; > } >=20 > public void setUsername(String username) { > this.username =3D username; > } >=20 > public String getPassword() { > return password; > } >=20 > public void setPassword(String password) { > this.password =3D password; > } > } > --------------------- >=20 > An Action that wants to be password protected must implement=20 > #isProtected() > to return "true". This is my JSP file that is shown if=20 > #isProtected() =3D=3D > true and there's no User in session scope: >=20 > --------------------- > ... > > name=3D"userData.username"> > name=3D"userData.password"> > > > ... > --------------------- >=20 > This is the error I get >=20 > --------------------- > 20:35:42,179 WARN OgnlValueStack:49 - Error setting value > ognl.OgnlException: target is null for setProperty(null, "password", > [Ljava.lang.String;@1f22dad5) > at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651) > at ognl.ASTProperty.setValueBody(ASTProperty.java:101) > at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) > at ognl.SimpleNode.setValue(SimpleNode.java:246) > at ognl.ASTChain.setValueBody(ASTChain.java:172) > at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) > at ognl.SimpleNode.setValue(SimpleNode.java:246) > at ognl.Ognl.setValue(Ognl.java:476) > ... > --------------------- >=20 >=20 > Why is that happening? >=20 > cu > mathias > --=20 > View this message in context:=20 > http://www.nabble.com/Login-with-Struts2-tp24522078p24522078.html > Sent from the Struts - User mailing list archive at Nabble.com. >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org >=20 >=20 Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu - direct contact information for affiliates is available at http://www.merck.com/contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org