Scott,

After dwelling on this for a few more days, I have finally decided on how to
handle this for the moment and have a question to throw out on this one.

Instead of extending the AuthenticationViaFormAction class, I simply created
a custom SWF action that pulled the credentials object and lowercased and
trimmed the username.  I inserted this between the bindAndValidate and
submit SWF states.  I was hoping to simply provide my own customized
UsernamePasswordCredentials class with a setUsername method that
automatically trimmed and lowercased the username passed into it, however
with the methods marked as final, there is no way I could override the
methods.

Would it be possible to change UsernamePasswordCredentials to an interface
and have a default implementation (UsernamePasswordCredentialsImpl) so
deployers can customize how these form fields are handled?  I suggest this
versus the PropertyEditor route as the Spring forums mention how
PropertyEditors are not thread safe and the difficulty of doing something
this simple.  No offense but extending the AuthenticationViaFormAction class
seems very invasive as I would have to keep up with any changes made to it
in future releases whereas if UsernamePasswordCredentials were an interface,
I would feel safer as interfaces wouldn¹t change as much.  It also seems
awkward to handle processing of a form submission outside of the form
object; the logic should be encapsulated.

Please don¹t get me wrong; I really do appreciate your help and direction.
=C
Andrew


On 9/9/08 2:37 PM, "Scott Battaglia" <[EMAIL PROTECTED]> wrote:

> You can use the PropertyEditor to convert Strings to more Strings (see the
> String Trimmer example in the Spring source).
> 
> You can extend the AuthenticationViaForm class, similar to this example below
> (but you'll be calling the method to register the property editors on the
> DataBinder):
> 
> package edu.rutgers.enterprise.cas.web.flow;
> 
> import org.jasig.cas.web.flow.AuthenticationViaFormAction;
> import org.springframework.validation.DataBinder;
> import org.springframework.web.bind.WebDataBinder;
> import org.springframework.webflow.execution.RequestContext;
> 
> 
> public class RestrictedAuthenticationViaFormAction extends
>     AuthenticationViaFormAction {
> 
>     protected void initBinder(RequestContext arg0, DataBinder binder) {
>         final WebDataBinder webBinder = (WebDataBinder) binder;
>         binder.setAllowedFields(new String[] {"username", "password",
> "authenticationType"});
>         webBinder.setFieldMarkerPrefix(null);
>     }
> }
> 
> JavaDoc: 
> http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/va
> lidation/DataBinder.html#registerCustomEditor(java.lang.Class,%20java.lang.Str
> ing,%20java.beans.PropertyEditor)
> 
> There is also another way to do it via the Spring configuration but I'm not
> too familiar with that.
> 
> -Scott Battaglia
> PGP Public Key Id: 0x383733AA
> LinkedIn: http://www.linkedin.com/in/scottbattaglia
> 
> 
> On Tue, Sep 9, 2008 at 2:53 PM, Andrew Ralph Feller, afelle1 <[EMAIL 
> PROTECTED]>
> wrote:
>> Scott,
>> 
>> Could you elaborate further?  The Spring documentation about using
>> PropertyEditors (
>> http://static.springframework.org/spring/docs/2.5.x/reference/validation.html
>> #beans-beans-conversion-customeditor-registration ) is confusing as it uses
>> the context of converting Strings to Objects.  The Spring WebFlow
>> documentation for the FormAction class mentions a PropertyEditorRegistrar can
>> be associated with the FormAction (
>> http://static.springframework.org/spring-webflow/docs/1.0.x/api/org/springfra
>> mework/webflow/action/FormAction.html#setPropertyEditorRegistrar(org.springfr
>> amework.beans.PropertyEditorRegistrar
>> <http://static.springframework.org/spring-webflow/docs/1.0.x/api/org/springfr
>> amework/webflow/action/FormAction.html#setPropertyEditorRegistrar%28org.sprin
>> gframework.beans.PropertyEditorRegistrar>  ).
>> 
>> This definitely seems overly complicated for something that should be simple.
>> =vC
>> 
>> Thanks,
>> 
>> Andrew
>> 
>> On 9/9/08 10:01 AM, "Scott Battaglia" <[EMAIL PROTECTED]
>> <http://[EMAIL PROTECTED]> > wrote:
>> 
>>> Andrew,
>>> 
>>> You should be able to register a custom PropertyEditor that you apply to the
>>> particular Credentials property (i.e. "username").  The PropertyEditor can
>>> lowercase the provided text.
>>> 
>>> -Scott
>>> 
>>> -Scott Battaglia
>>> PGP Public Key Id: 0x383733AA
>>> LinkedIn: http://www.linkedin.com/in/scottbattaglia
>>> 
>>> 
>>> On Tue, Sep 9, 2008 at 10:46 AM, Andrew Ralph Feller, afelle1
>>> <[EMAIL PROTECTED] <http://[EMAIL PROTECTED]> > wrote:
>>>> QUESTION: What is the recommended method of manipulating login form fields
>>>> such as username in CAS 3.X: CAS' CredentialsBinder or Spring's DataBinder
>>>> or PropertyEditor?
>>>> 
>>>> Thanks,
>>>> Andrew

-- 
Andrew R. Feller, Analyst
Information Technology Services
200 Fred Frey Building
Louisiana State University
Baton Rouge, LA 70803
(225) 578-3737 (Office)
(225) 578-6400 (Fax)

_______________________________________________
Yale CAS mailing list
[email protected]
http://tp.its.yale.edu/mailman/listinfo/cas

Reply via email to