Author: channa
Date: Thu Mar 6 23:31:51 2008
New Revision: 14570
Log:
Removed code maintaining redundant e-mail ID in user manager. MASHUP-709.
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ResetPasswordBean.java
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ResetPasswordBean.java
==============================================================================
---
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ResetPasswordBean.java
(original)
+++
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/ResetPasswordBean.java
Thu Mar 6 23:31:51 2008
@@ -20,14 +20,15 @@
import org.apache.commons.logging.LogFactory;
import org.wso2.mashup.MashupConstants;
import org.wso2.mashup.MashupFault;
+import org.wso2.mashup.webapp.utils.RegistryUtils;
import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.RegistryException;
+import org.wso2.registry.secure.SecureRegistry;
import org.wso2.registry.users.UserRealm;
import org.wso2.registry.users.UserStoreAdmin;
import org.wso2.registry.users.UserStoreException;
-import org.wso2.registry.users.UserStoreReader;
import org.wso2.registry.users.verifier.EmailVerifierConfig;
-
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
@@ -39,7 +40,6 @@
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import java.util.Hashtable;
-import java.util.Map;
import java.util.Properties;
/**
@@ -83,8 +83,9 @@
/**
* Validates the information in mandatory fields.
- *
+ * @param request Servnet request instance.
* @return true if validation is successful.
+ * @throws MashupFault if retrieval of profile info fails.
*/
public boolean isInputValid(HttpServletRequest request) throws MashupFault
{
boolean valid = true;
@@ -100,18 +101,17 @@
// User/email combination verification. Do this check only if data has
been entered.
if (valid) {
- ServletContext context = request.getSession().getServletContext();
- UserRealm realm = (UserRealm)
context.getAttribute(RegistryConstants.REGISTRY_REALM);
+ SecureRegistry registry = (SecureRegistry)
request.getSession().getAttribute(
+ MashupConstants.USER_REGISTRY);
try {
- UserStoreReader userStoreReader = realm.getUserStoreReader();
- Map userProps = userStoreReader.getUserProperties(userName);
- String eMail = (String)
userProps.get(MashupConstants.EMAIL_ID);
+ User userProfile = RegistryUtils.getUserProfile(userName,
registry);
+ String eMail = userProfile.getEmailAddress();
if ("".equals(eMail) || !emailId.equals(eMail)) {
errors.put("emailId", "The user and e-mail ID combination
specified are " +
"incorrect.");
valid = false;
}
- } catch (UserStoreException ume) {
+ } catch (RegistryException ume) {
log.error("Error retrieving user information", ume);
throw new MashupFault(ume);
}
@@ -137,24 +137,17 @@
* @throws MashupFault on errors.
*/
public boolean resetPassword(HttpServletRequest request) throws
MashupFault {
- boolean success = false;
+ boolean success;
ServletContext context = request.getSession().getServletContext();
UserRealm realm = (UserRealm)
context.getAttribute(RegistryConstants.REGISTRY_REALM);
try {
UserStoreAdmin userStoreAdmin = realm.getUserStoreAdmin();
- Map userProps = userStoreAdmin.getUserProperties(userName);
- String eMail = (String) userProps.get(MashupConstants.EMAIL_ID);
-
- // Recheck the user/e-mail ID match, the proceed with change.
- if (emailId.equals(eMail)) {
- // Currently setting the password to the user name.
- String uuid = UUIDGenerator.getUUID();
- String newPassword = uuid.substring(uuid.length() - 8);
- userStoreAdmin.updateUser(userName, newPassword);
- sendEmail(newPassword);
- success = true;
- }
+ String uuid = UUIDGenerator.getUUID();
+ String newPassword = uuid.substring(uuid.length() - 8);
+ userStoreAdmin.updateUser(userName, newPassword);
+ sendEmail(newPassword);
+ success = true;
} catch (UserStoreException e) {
log.error("Error resetting password in user manager", e);
throw new MashupFault("Could not reset password", e);
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
==============================================================================
---
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
(original)
+++
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
Thu Mar 6 23:31:51 2008
@@ -24,7 +24,6 @@
import org.wso2.mashup.webapp.userprofile.User;
import org.wso2.registry.ActionConstants;
import org.wso2.registry.Collection;
-import org.wso2.registry.CollectionImpl;
import org.wso2.registry.LogEntry;
import org.wso2.registry.Registry;
import org.wso2.registry.RegistryConstants;
@@ -524,7 +523,6 @@
Map properties = userStoreAdmin.getUserProperties(userName);
properties.put(MashupConstants.PROFILE_PATH, profilePath);
properties.put(MashupConstants.FULL_NAME, fullName);
- properties.put(MashupConstants.EMAIL_ID, eMailId);
properties.put(MashupConstants.ORIGIN_MASHUP, String.valueOf(true));
userStoreAdmin.setUserProperties(userName, properties);
@@ -594,7 +592,6 @@
String profilePath = null;
Map properties = userStoreAdmin.getUserProperties(userName);
properties.put(MashupConstants.FULL_NAME, fullName);
- properties.put(MashupConstants.EMAIL_ID, eMailId);
userStoreAdmin.setUserProperties(userName, properties);
if (properties.containsKey(MashupConstants.PROFILE_PATH)) {
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev