Update of
/var/cvs/contributions/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets
In directory
james.mmbase.org:/tmp/cvs-serv32069/portlets-login/src/java/com/finalist/cmsc/portlets
Modified Files:
Tag: b1_4
LoginPortlet.java
Log Message:
CMSC-617 Personal Pages module
Backport to 1.4
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets
See also: http://www.mmbase.org/jira/browse/CMSC-617
Index: LoginPortlet.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets/LoginPortlet.java,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -b -r1.5 -r1.5.2.1
--- LoginPortlet.java 30 Jan 2008 14:09:38 -0000 1.5
+++ LoginPortlet.java 25 Feb 2008 16:25:52 -0000 1.5.2.1
@@ -1,12 +1,12 @@
/*
-This software is OSI Certified Open Source Software.
-OSI Certified is a certification mark of the Open Source Initiative.
+ This software is OSI Certified Open Source Software.
+ OSI Certified is a certification mark of the Open Source Initiative.
-The license (Mozilla version 1.0) can be read at the MMBase site.
-See http://www.MMBase.org/license
+ The license (Mozilla version 1.0) can be read at the MMBase site.
+ See http://www.MMBase.org/license
-*/
+ */
package com.finalist.cmsc.portlets;
import java.io.IOException;
@@ -14,7 +14,8 @@
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
-import javax.portlet.PortletMode;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -22,29 +23,53 @@
import com.finalist.cmsc.services.community.Community;
/**
- * Login / Logout portlet
+ * Login portlet
*
- * @author Menno Menninga / Remco Bos
- * @version $Revision: 1.5 $
+ * @author Remco Bos
*/
public class LoginPortlet extends CmscPortlet {
+ private static final String ACEGI_SECURITY_FORM_USERNAME_KEY =
"j_username";
+
+ private static final String ACEGI_SECURITY_FORM_PASSWORD_KEY =
"j_password";
+
private static final Log log = LogFactory.getLog(LoginPortlet.class);
- public void processView(ActionRequest request, ActionResponse response)
- throws PortletException, IOException {
+ public void processView(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
String action = request.getParameter("action");
if ("login".equals(action)) {
- if (!Community.loginUser(request, response)) {
- response.setPortletMode(PortletMode.VIEW);
+ String userName =
request.getParameter(ACEGI_SECURITY_FORM_USERNAME_KEY);
+ if (userName == null) {
+ userName = "";
}
- } else if ("logout".equals(action)) {
- if (!Community.logoutUser(request, response)) {
- response.setPortletMode(PortletMode.VIEW);
+ String password =
request.getParameter(ACEGI_SECURITY_FORM_PASSWORD_KEY);
+ if (password == null) {
+ password = "";
}
+ Community.login(userName, password);
+ if (Community.isAuthenticated()) {
+ log.info(String.format("Login successful for
user %s", userName));
+ } else {
+ log.info(String.format("Login failed for user
%s", userName));
+ }
+
+ } else if ("logout".equals(action)) {
+ Community.logout();
+
+ // Unknown
} else {
- response.setPortletMode(PortletMode.VIEW);
log.error(String.format("Unknown action '%s'", action));
}
}
+
+ @Override
+ protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
+ String template = null;
+ if (Community.isAuthenticated()) {
+ template = "login/logout.jsp";
+ } else {
+ template = "login/login.jsp";
+ }
+ doInclude("view", template, request, response);
+ }
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs