瀏覽代碼

Add obtainUsername method as per http://forum.springframework.org/viewtopic.php?t=4757.

Ben Alex 20 年之前
父節點
當前提交
fdf5c63033

+ 15 - 1
core/src/main/java/org/acegisecurity/ui/webapp/AuthenticationProcessingFilter.java

@@ -66,7 +66,7 @@ public class AuthenticationProcessingFilter extends AbstractProcessingFilter {
 
     public Authentication attemptAuthentication(HttpServletRequest request)
         throws AuthenticationException {
-        String username = request.getParameter(ACEGI_SECURITY_FORM_USERNAME_KEY);
+        String username = obtainUsername(request);
         String password = obtainPassword(request);
 
         if (username == null) {
@@ -127,4 +127,18 @@ public class AuthenticationProcessingFilter extends AbstractProcessingFilter {
     protected String obtainPassword(HttpServletRequest request) {
         return request.getParameter(ACEGI_SECURITY_FORM_PASSWORD_KEY);
     }
+
+    /**
+     * Enables subclasses to override the composition of the username, such as
+     * by including additional values and a separator.
+     *
+     * @param request so that request attributes can be retrieved
+     *
+     * @return the username that will be presented in the
+     *         <code>Authentication</code> request token to the
+     *         <code>AuthenticationManager</code>
+     */
+    protected String obtainUsername(HttpServletRequest request) {
+        return request.getParameter(ACEGI_SECURITY_FORM_USERNAME_KEY);
+    }
 }

+ 1 - 0
doc/xdocs/changes.xml

@@ -33,6 +33,7 @@
       <action dev="benalex" type="update">Update commons-codec dependency to 1.3</action>
       <action dev="raykrueger" type="update">AbstractProcessingFilter no longer has setters for failures, it uses the exceptionMappings property</action>
       <action dev="benalex" type="update">Update to match Spring 1.2 RC 1 official JAR dependencies</action>
+      <action dev="raykrueger" type="update">AuthenticationProcessingFilter now provides an obtainUsername method</action>
     </release>
     <release version="0.8.1" date="2005-03-22">
       <action dev="luke_t" type="add">X509 (certificate-based) authentication support</action>