You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by mi...@apache.org on 2001/07/04 17:49:58 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/modules/actions/sessionvalidator TemplateSessionValidator.java
mikeh 01/07/04 08:49:57
Modified: src/java/org/apache/turbine/modules/actions/sessionvalidator
TemplateSessionValidator.java
Log:
Added some comments, replaced repeated string with a constant
Revision Changes Path
1.8 +11 -11 jakarta-turbine/src/java/org/apache/turbine/modules/actions/sessionvalidator/TemplateSessionValidator.java
Index: TemplateSessionValidator.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/actions/sessionvalidator/TemplateSessionValidator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TemplateSessionValidator.java 2001/06/19 21:51:54 1.7
+++ TemplateSessionValidator.java 2001/07/04 15:49:54 1.8
@@ -72,10 +72,15 @@
* @see TemplateSecureSessionValidator
* @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
- * @version $Id: TemplateSessionValidator.java,v 1.7 2001/06/19 21:51:54 mpoeschl Exp $
+ * @version $Id: TemplateSessionValidator.java,v 1.8 2001/07/04 15:49:54 mikeh Exp $
*/
public class TemplateSessionValidator extends SessionValidator
{
+ private String COUNTER = "_session_access_counter";
+ // the COUNTER can be placed as a hidden field in
+ // forms. This can be used to prevent a user from using the
+ // browsers back button and submitting stale data.
+
/**
* Execute the action.
*
@@ -84,14 +89,13 @@
*/
public void doPerform( RunData data ) throws Exception
{
- /*
- * Pull user from session.
- */
+ // pull user from session, update access times, counters
data.populate();
// The user may have not logged in, so create a "guest" user.
if ( data.getUser() == null )
{
+ // place user in the session
data.setUser(TurbineSecurity.getAnonymousUser());
data.save();
}
@@ -113,15 +117,11 @@
TurbineConstants.SCREEN_HOMEPAGE));
}
}
- // the session_access_counter can be placed as a hidden field in
- // forms. This can be used to prevent a user from using the
- // browsers back button and submitting stale data.
- else if ( data.getParameters().containsKey("_session_access_counter") )
+ else if ( data.getParameters().containsKey(COUNTER) )
{
// See comments in screens.error.InvalidState.
- if ( data.getParameters().getInt("_session_access_counter") <
- (((Integer)data.getUser().getTemp("_session_access_counter"))
- .intValue()-1) )
+ if ( data.getParameters().getInt(COUNTER) <
+ (((Integer)data.getUser().getTemp(COUNTER)).intValue() - 1) )
{
if (data.getTemplateInfo().getScreenTemplate() != null)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: cvs commit:
jakarta-turbine/src/java/org/apache/turbine/modules/actions/sessionvalidato
r TemplateSessionValidator.java
Posted by Jon Stevens <jo...@latchkey.com>.
on 7/4/01 8:49 AM, "mikeh@apache.org" <mi...@apache.org> wrote:
> + private String COUNTER = "_session_access_counter";
It needs to be private static final in order to really do what you intended
(ie: a Constant).
-jon
--
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org