continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r367386 - in /maven/continuum/trunk/continuum-webapp: pom.xml src/main/java/org/apache/maven/continuum/web/action/LoginAction.java src/main/resources/localization/Continuum.properties src/main/webapp/login.jsp
Date Mon, 09 Jan 2006 20:31:18 GMT
Author: evenisse
Date: Mon Jan  9 12:31:11 2006
New Revision: 367386

URL: http://svn.apache.org/viewcvs?rev=367386&view=rev
Log:
Use plexus-security and remember me (not finished)

Modified:
    maven/continuum/trunk/continuum-webapp/pom.xml
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/LoginAction.java
    maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    maven/continuum/trunk/continuum-webapp/src/main/webapp/login.jsp

Modified: maven/continuum/trunk/continuum-webapp/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/pom.xml?rev=367386&r1=367385&r2=367386&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/pom.xml (original)
+++ maven/continuum/trunk/continuum-webapp/pom.xml Mon Jan  9 12:31:11 2006
@@ -45,6 +45,11 @@
       <artifactId>plexus-security-osuser</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-remember-me</artifactId>
+      <version>1.0-alpha-1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
       <version>2.4</version>

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/LoginAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/LoginAction.java?rev=367386&r1=367385&r2=367386&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/LoginAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/LoginAction.java
Mon Jan  9 12:31:11 2006
@@ -16,7 +16,18 @@
  * limitations under the License.
  */
 
+import org.codehaus.plexus.rememberme.RememberMeServices;
+import org.codehaus.plexus.security.Authentication;
+import org.codehaus.plexus.security.Authenticator;
+import org.codehaus.plexus.security.DefaultAuthentication;
+import org.codehaus.plexus.security.User;
+
 import com.opensymphony.xwork.ActionSupport;
+import com.opensymphony.webwork.ServletActionContext;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.servlet.http.HttpSession;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -25,17 +36,62 @@
 public class LoginAction
     extends ActionSupport
 {
+    private Authenticator authenticator;
+
+    private RememberMeServices rememberMeServices;
+
     private String username = "";
 
     private String password = "";
 
+    private boolean rememberMe = false;
+
     /**
      * Execute the login action
      */
     public String execute()
         throws Exception
     {
-        return SUCCESS;
+        try
+        {
+            Map params = new HashMap();
+
+            params.put( "username", username );
+
+            params.put( "password", password );
+
+            User user = authenticator.authenticate( params );
+
+            if ( rememberMe )
+            {
+                Authentication auth = new DefaultAuthentication();
+
+                auth.setUser( user );
+
+                auth.setAuthenticated( true );
+
+                rememberMeServices.loginSuccess( ServletActionContext.getRequest(),
+                    ServletActionContext.getResponse(), auth );
+            }
+
+            HttpSession session = ServletActionContext.getRequest().getSession( true );
+
+            session.setAttribute( "authentication", user );
+
+            return SUCCESS;
+        }
+        catch ( Exception e )
+        {
+            addActionError( "Login failed. " + e.getMessage() );
+
+            if ( rememberMe )
+            {
+                rememberMeServices.loginFail( ServletActionContext.getRequest(),
+                    ServletActionContext.getResponse() );
+            }
+
+            return INPUT;
+        }
     }
 
     /**
@@ -51,18 +107,28 @@
         return username;
     }
 
-    public String getPassword()
+    public void setUsername( String username )
     {
-        return password;
+        this.username = username;
     }
 
-    public void setUsername( String username )
+    public String getPassword()
     {
-        this.username = username;
+        return password;
     }
 
     public void setPassword( String password )
     {
         this.password = password;
+    }
+
+    public boolean isRememberMe()
+    {
+        return rememberMe;
+    }
+
+    public void setRememberMe( boolean rememberMe )
+    {
+        this.rememberMe = rememberMe;
     }
 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=367386&r1=367385&r2=367386&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Mon Jan  9 12:31:11 2006
@@ -53,6 +53,7 @@
 login.section.title = Authentication
 login.username = Username
 login.password = Password
+login.rememberMe = Remember me
 login.submit = Connect
 
 // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/login.jsp
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-webapp/src/main/webapp/login.jsp?rev=367386&r1=367385&r2=367386&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/login.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/login.jsp Mon Jan  9 12:31:11 2006
@@ -12,6 +12,7 @@
         <ww:form action="login" method="post">
             <ww:textfield label="%{getText('login.username')}" name="username" required="true"/>
             <ww:password label="%{getText('login.password')}" name="password" required="true"/>
+            <ww:checkbox label="%{getText('login.rememberMe')}" name="rememberMe" value="rememberMe"
fieldValue="true"/>
             <c1:submitcancel value="%{getText('login.submit')}" cancel="%{getText('cancel')}"/>
         </ww:form>
         </div>



Mime
View raw message