[Opensource] Updated: Added transaction token support for controllers
Raul DAVIDOVICH
R.DAVIDOVICH at caconcology.com
Fri Oct 18 03:31:03 PDT 2002
Hi all,
I reworked a bit the transaction token support.. I wasn't very happy
by modifying the PersistentSession interface, so instead of that, I added a
getHttpServletRequest() method in ControllerRequest who simplifies things a
bit..
here are the code snippets, the .class files and the .java sources
Controller.java
...
/**
* Generate a new transaction token, to be used for enforcing a single
* request for a particular transaction.
*
* @param request The request we are processing
*/
protected String generateToken(ControllerRequest request) {
return (super.generateToken(request.getHttpServletRequest()));
}
/**
* Return <code>true</code> if there is a transaction token stored in
* the user's current session, and the value submitted as a request
* parameter with this action matches it. Returns <code>false</code>
* under any of the following circumstances:
* <ul>
* <li>No session associated with this request</li>
* <li>No transaction token saved in the session</li>
* <li>No transaction token included as a request parameter</li>
* <li>The included transaction token value does not match the
* transaction token in the user's session</li>
* </ul>
*
* @param request The servlet request we are processing
*/
protected boolean isTokenValid(ControllerRequest request) {
return(super.isTokenValid(request.getHttpServletRequest()));
}
/**
* Reset the saved transaction token in the user's session. This
* indicates that transactional token checking will not be needed
* on the next request that is submitted.
*
* @param request The servlet request we are processing
*/
protected void resetToken(ControllerRequest request) {
super.resetToken(request.getHttpServletRequest());
}
protected void saveToken(ControllerRequest request) {
super.saveToken(request.getHttpServletRequest());
}
...
ControllerRequest.java
...
import javax.servlet.http.HttpServletRequest;
...
/**
* Returns the HttpServletRequest
*
* @return javax.servlet.http.HttpServletRequest
*/
public HttpServletRequest getHttpServletRequest() {
if (mySession != null)
return mySession.getRequest();
else
return null;
}
...
(See attached file: ControllerRequest.java)(See attached file:
Controller.java)(See attached file: ControllerRequest.class)(See attached
file: Controller.class)
Best regards
---------------------------------------------------
Raul Davidovich
Responsable Informatique
Cvitkovic & Associés Consultants
(33) 1 45 15 40 68
(33) 1 45 15 40 41 Fax
-------------------------------------------------------
http://www.caconcology.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: =?iso-8859-1?Q?ControllerRequest.java?=
Type: application/octet-stream
Size: 20670 bytes
Desc: not available
Url : http://mailman.jcorporate.com/pipermail/opensource/attachments/20021018/b8bb53a7/iso-8859-1QControllerRequest-0004.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: =?iso-8859-1?Q?Controller.java?=
Type: application/octet-stream
Size: 103464 bytes
Desc: not available
Url : http://mailman.jcorporate.com/pipermail/opensource/attachments/20021018/b8bb53a7/iso-8859-1QController-0004.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: =?iso-8859-1?Q?ControllerRequest.class?=
Type: application/octet-stream
Size: 11305 bytes
Desc: not available
Url : http://mailman.jcorporate.com/pipermail/opensource/attachments/20021018/b8bb53a7/iso-8859-1QControllerRequest-0005.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: =?iso-8859-1?Q?Controller.class?=
Type: application/octet-stream
Size: 44085 bytes
Desc: not available
Url : http://mailman.jcorporate.com/pipermail/opensource/attachments/20021018/b8bb53a7/iso-8859-1QController-0005.obj
More information about the Opensource
mailing list