[mashup-dev] svn commit r14479 - in trunk/mashup/java/modules:
core/conf core/src/org/wso2/mashup
core/src/org/wso2/mashup/webapp/identity www
svn at wso2.org
svn at wso2.org
Mon Mar 3 21:35:41 PST 2008
Author: tyrell
Date: Mon Mar 3 21:35:31 2008
New Revision: 14479
Log:
Fixing MASHUP-707
Modified:
trunk/mashup/java/modules/core/conf/server.xml
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/RegistrationBean.java
trunk/mashup/java/modules/www/register_self.jsp
Modified: trunk/mashup/java/modules/core/conf/server.xml
==============================================================================
--- trunk/mashup/java/modules/core/conf/server.xml (original)
+++ trunk/mashup/java/modules/core/conf/server.xml Mon Mar 3 21:35:31 2008
@@ -180,6 +180,11 @@
-->
<RememberMePeriod>14</RememberMePeriod>
</SessionManagement>
+
+ <!-- Used to enable or disable the Captcha functionality -->
+ <Captcha>
+ <EnableCaptcha>true</EnableCaptcha>
+ </Captcha>
<!--User to setup the primary (admin) user account when browser based local setup is not possible-->
<PrimaryUserConfig>
Modified: trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java (original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java Mon Mar 3 21:35:31 2008
@@ -45,6 +45,9 @@
public static String SESSION_MANAGEMENT = "SessionManagement";
public static String REMEMBER_ME_PERIOD = "RememberMePeriod";
+
+ public static String CAPTCHA_CONFIG = "Captcha";
+ public static String CAPTCHA_CONFIG_STATUS = "EnableCaptcha";
public static String QUARTZ_FUNCTION_SCHEDULER = "FunctionScheduler";
public static String QUARTZ_FUNCTION_SCHEDULER_JOB_IDS = "FunctionSchedulerJobIds";
Modified: trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/RegistrationBean.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/RegistrationBean.java (original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/identity/RegistrationBean.java Mon Mar 3 21:35:31 2008
@@ -30,8 +30,7 @@
import org.wso2.registry.users.UserStoreAdmin;
import org.wso2.registry.users.UserStoreException;
import org.wso2.registry.users.verifier.EmailVerifier;
-import org.wso2.usermanager.UserManagerException;
-
+import org.wso2.utils.ServerConfiguration;
import org.wso2.wsas.persistence.PersistenceManager;
import javax.servlet.ServletContext;
@@ -156,7 +155,7 @@
*/
public void createAdmin(HttpServletRequest request) throws MashupFault,
RegistryException {
-
+
// Recheck that the request to create the primary user is valid.
if (!MashupUtils.isInitialSetupComplete() && MashupUtils.isFromLocalHost(request)) {
ServletContext context = request.getSession().getServletContext();
@@ -164,8 +163,8 @@
RegistryConstants.REGISTRY);
UserRealm realm = (UserRealm) context.getAttribute(RegistryConstants.REGISTRY_REALM);
SecureRegistry registry = RegistryUtils.createSecureRegistry(
- MashupConstants.SYSTEM_USER, MashupConstants.SYSTEM_USER_PASSWORD, jdbcRegistry,
- realm);
+ MashupConstants.SYSTEM_USER, MashupConstants.SYSTEM_USER_PASSWORD, jdbcRegistry,
+ realm);
try {
// Get an instance of the user store admin and create the user.
UserStoreAdmin userStoreAdmin = realm.getUserStoreAdmin();
@@ -173,7 +172,7 @@
String adminName = "".equals(fullName.trim()) ? userName : fullName;
String adminEmail = "".equals(emailId.trim()) ? "none" : emailId;
-
+
// Create the admin user profile.
RegistryUtils.createUser(registry, realm, userName,
adminName, adminEmail, "System Administrator");
@@ -321,28 +320,38 @@
if (!adminCreation) {
//First and formost checking captcha and returning immediately if invalid
- String expectedCaptchaValue = (String) request.getSession().getAttribute("captcha");
- if (!captcha.equals(expectedCaptchaValue)) {
- //Clearing existing error records
- errors.clear();
- errors.put("captcha",
- "The text you typed in doesn't match with the text in image. Please try again.");
- return false;
+ ServerConfiguration serverConfig =
+ ServerConfiguration.getInstance();
+ String captchaStatus =
+ serverConfig
+ .getFirstProperty(
+ MashupConstants.CAPTCHA_CONFIG + "." +
+ MashupConstants
+ .CAPTCHA_CONFIG_STATUS);
+ if (captchaStatus.equalsIgnoreCase("true")) {
+ String expectedCaptchaValue = (String) request.getSession().getAttribute("captcha");
+ if (!captcha.equals(expectedCaptchaValue)) {
+ //Clearing existing error records
+ errors.clear();
+ errors.put("captcha",
+ "The text you typed in doesn't match with the text in image. Please try again.");
+ return false;
+ }
}
if (fullName.equals("")) {
errors.put("fullName", "Full name cannot be empty.");
valid = false;
}
-
+
if (emailId.equals("")) {
errors.put("emailId", "E-mail ID cannot be empty.");
valid = false;
}
}
-
+
valid = isPasswordValid(password, confirmedPassword, errors);
-
+
// Expensive operation, so do only once all other data has been validated.
if (valid) {
if (ManageUsers.isExistingUser(request, userName)) {
Modified: trunk/mashup/java/modules/www/register_self.jsp
==============================================================================
--- trunk/mashup/java/modules/www/register_self.jsp (original)
+++ trunk/mashup/java/modules/www/register_self.jsp Mon Mar 3 21:35:31 2008
@@ -15,11 +15,20 @@
--%>
<%@ page errorPage="error.jsp" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndContent" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndContentImpl" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndEntry" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndEntryImpl" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndFeed" %>
+<%@ page import="com.sun.syndication.feed.synd.SyndFeedImpl" %>
+<%@ page import="com.sun.syndication.io.SyndFeedOutput" %>
+<%@ page import="org.apache.axis2.context.ConfigurationContext" %>
<%@ page import="org.wso2.mashup.MashupConstants" %>
<%@ page import="org.wso2.mashup.MashupFault" %>
<%@ page import="org.wso2.mashup.utils.MashupUtils" %>
<%@ page import="org.wso2.mashup.utils.QueryResult" %>
<%@ page import="org.wso2.mashup.utils.QueryResults" %>
+<%@ page import="org.wso2.mashup.webapp.MashupUiFault" %>
<%@ page import="org.wso2.mashup.webapp.identity.InfoCardHandler" %>
<%@ page import="org.wso2.mashup.webapp.identity.RegistrationBean" %>
<%@ page import="org.wso2.mashup.webapp.userprofile.ManageUsers" %>
@@ -28,14 +37,29 @@
<%@ page import="org.wso2.mashup.webapp.userprofile.UserQuery" %>
<%@ page import="org.wso2.mashup.webapp.utils.QueryParamUtils" %>
<%@ page import="org.wso2.mashup.webapp.utils.RegistryUtils" %>
-<%@ page import="org.wso2.registry.*" %>
+<%@ page import="org.wso2.registry.Comment" %>
+<%@ page import="org.wso2.registry.Registry" %>
+<%@ page import="org.wso2.registry.RegistryConstants" %>
+<%@ page import="org.wso2.registry.RegistryException" %>
+<%@ page import="org.wso2.registry.Resource" %>
+<%@ page import="org.wso2.registry.Tag" %>
<%@ page import="org.wso2.registry.jdbc.JDBCRegistry" %>
<%@ page import="org.wso2.registry.secure.SecureRegistry" %>
+<%@ page import="org.wso2.registry.users.UserRealm" %>
+<%@ page import="org.wso2.registry.users.UserStoreAdmin" %>
+<%@ page import="org.wso2.registry.users.UserStoreException" %>
+<%@ page import="org.wso2.utils.ServerConfiguration" %>
+<%@ page import="org.wso2.wsas.ServerManager" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.FileReader" %>
<%@ page import="java.net.URL" %>
<%@ page import="java.net.URLDecoder" %>
-<%@ page import="java.util.*" %>
+<%@ page import="java.util.ArrayList" %>
+<%@ page import="java.util.Date" %>
+<%@ page import="java.util.Iterator" %>
+<%@ page import="java.util.List" %>
+<%@ page import="java.util.Map" %>
+<%@ page import="java.util.ResourceBundle" %>
<%
@@ -171,19 +195,36 @@
.getErrorMessage("confirmedPassword")%></font>
</td>
</tr>
+ <%
+ ServerConfiguration serverConfig =
+ ServerConfiguration.getInstance();
+ String captchaStatus =
+ serverConfig
+ .getFirstProperty(
+ MashupConstants.CAPTCHA_CONFIG + "." +
+ MashupConstants
+ .CAPTCHA_CONFIG_STATUS);
+ if (captchaStatus.equalsIgnoreCase("true")) {
+ %>
<tr>
<td>
<div align="center"><img src="captcha.jsp"/></div>
</td>
<td>
<br/>
- <label>Type the text you see in the image here<font color="#FF0000">*</font></label>
+ <label>Type the text you see in the image here<font
+ color="#FF0000">*</font></label>
<br/>
<input type="text" name="captcha"
value="<%=registrationHandler.getCaptcha()%>"/>
- <br><font color="#FF0000"><%=registrationHandler.getErrorMessage("captcha")%></font>
+ <br><font color="#FF0000"><%=registrationHandler
+ .getErrorMessage("captcha")%>
+ </font>
</td>
</tr>
+ <%
+ }
+ %>
<tr>
<td> </td>
<td><input type="submit" value="Register"/> <input type="button" value="Cancel" onclick="document.location = '<%= bounceback %>';"></td>
More information about the Mashup-dev
mailing list