Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleAbstractFormController formBackingObject()
protected Object formBackingObject(HttpServletRequest request) throws Exception {
    return createCommand();
}

So we could override that method's implementation to add delegation to our RequestToCredentials instance.

What to do

Let's not, however. Let's use the Form abstraction provided by AbstractFormController for the portion of the input to LoginController that actually is a form. Credentials are not necessarily a form, they are any object. Spring serves us best by staying out of our way and letting us implement this piece of the Login controller directly.

Our form revisited

Suppose we use the Object argument to processFormSubmission to handle the handful of request parameters that we need to process regardless of the Credentials type.

Code Block
titleLoginController

    protected ModelAndView processFormSubmission(final HttpServletRequest request, final HttpServletResponse response, final Object object,
        final BindException errors) throws Exception {
        final Credentials credentials = (Credentials)object;
        
        this.credentialsBinder.bind(request, credentials);

        final String ticketGrantingTicketId = this.centralAuthenticationService.createTicketGrantingTicket(credentials);
        final String service = request.getParameter(WebConstants.SERVICE);
        final boolean warn = StringUtils.hasText(request.getParameter(WebConstants.WARN));

Copyright notice

Cited code snippets from The Spring Framework are used here for the purpose of explaining CAS 3's usage of this framework. The Spring Framework is subject to license agreement.