Author: prabath
Date: Thu Jan 10 02:56:11 2008
New Revision: 12108
Log:
OpenID integration
Modified:
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
Modified:
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
==============================================================================
---
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
(original)
+++
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/UserRegistrationFormSubmitAction.java
Thu Jan 10 02:56:11 2008
@@ -25,6 +25,7 @@
import org.wso2.solutions.identity.admin.ClaimsAdmin;
import org.wso2.solutions.identity.admin.ParameterAdmin;
import org.wso2.solutions.identity.admin.ReportAdmin;
+import org.wso2.solutions.identity.openid.OpenIDProvider;
import org.wso2.solutions.identity.persistence.dataobject.ActionDO;
import org.wso2.solutions.identity.persistence.dataobject.ClaimDO;
import org.wso2.usermanager.UserManagerException;
@@ -40,16 +41,16 @@
import com.opensymphony.xwork2.validator.annotations.Validation;
@Validation
-public class UserRegistrationFormSubmitAction
- extends ManagedAction {
+public class UserRegistrationFormSubmitAction extends ManagedAction {
private static final long serialVersionUID = -4791453858953047850L;
private String username;
private String password;
- private static Log log =
LogFactory.getLog(UserRegistrationFormSubmitAction.class);
-
+ private static Log log = LogFactory
+ .getLog(UserRegistrationFormSubmitAction.class);
+
public String execute() throws Exception {
UserStore store = UserStore.getInstance();
@@ -57,7 +58,7 @@
ClaimDO[] claimDOs = ClaimsAdmin.getAllMappedEnabledClaims();
HttpServletRequest request = (HttpServletRequest) ActionContext
.getContext().get(StrutsStatics.HTTP_REQUEST);
-
+
String emailAddress = null;
HashMap<String, String> props = new HashMap<String, String>();
for (int i = 0; i < claimDOs.length; i++) {
@@ -65,17 +66,17 @@
if (!uri.equals(IdentityConstants.CLAIM_PPID)) {
props.put(uri, request.getParameter(uri));
}
-
- if(uri.equals(IdentityConstants.CLAIM_EMAIL_ADDRESS)){
+
+ if (uri.equals(IdentityConstants.CLAIM_EMAIL_ADDRESS)) {
emailAddress = request.getParameter(uri);
}
}
-
- // We create an OpenID for all registering users, later give this
choice to the user
+
+ // We create an OpenID for all registering users, later give this
choice
+ // to the user
// whether to register for an OpenID at the time of normal
registration.
// Create an OpenID for the user
- // TODO : remove the hard-coded port number
- String openid = request.getServerName() + ":" +12080+
"/user/"+this.username;
+ String openid = OpenIDProvider.generateOpenID(this.username);
props.put(IdentityConstants.CLAIM_OPENID, openid);
ParameterAdmin paramAdmin = new ParameterAdmin();
@@ -84,14 +85,17 @@
if (emailVerification && emailAddress != null) {
try {
EmailVerifier verifier = new EmailVerifier();
- verifier.requestUserVerification(username, emailAddress,
password, props);
- String msg = getText("email_verification", new String[]
{username});
- ReportAdmin.record(username, ActionDO.ACTION_USER_REGISTER,
msg);
+ verifier.requestUserVerification(username, emailAddress,
+ password, props);
+ String msg = getText("email_verification",
+ new String[] { username });
+ ReportAdmin
+ .record(username, ActionDO.ACTION_USER_REGISTER, msg);
this.addInfoMessage(getText("please_check_mail",
new String[] { emailAddress }));
} catch (UserManagerException e) {
- String msg = getText("error_unexpected",
- new String[] { e.getMessage() });
+ String msg = getText("error_unexpected", new String[] { e
+ .getMessage() });
this.addErrorMessage(msg);
log.error(msg, e);
return ERROR;
@@ -99,33 +103,34 @@
} else {
try {
UserStoreAdmin umAdmin = store.getRealm().getUserStoreAdmin();
- if(umAdmin.isExistingUser(username)){
- this.addErrorMessage(getText("sign_in_user_exist",
- new String[]{username}));
- loadMessages();
- return ERROR;
- }else{
+ if (umAdmin.isExistingUser(username)) {
+ this.addErrorMessage(getText("sign_in_user_exist",
+ new String[] { username }));
+ loadMessages();
+ return ERROR;
+ } else {
umAdmin.addUser(this.username, this.password);
}
-
+
} catch (UserManagerException e) {
- String msg = getText("error_unexpected",
- new String[] { e.getMessage() });
+ String msg = getText("error_unexpected", new String[] { e
+ .getMessage() });
this.addErrorMessage(msg);
log.error(msg, e);
return ERROR;
}
-
+
store.getRealm().getUserStoreAdmin().setUserProperties(
this.username, props);
- String msg = getText("successful_for", new String[]{username});
+ String msg = getText("successful_for", new String[] { username });
ReportAdmin.record(username, ActionDO.ACTION_USER_REGISTER, msg);
this.addInfoMessage(getText("user_successfully_added",
new String[] { username }));
+ this.addInfoMessage("Your OpenID is " + openid);
}
-
+
return SUCCESS;
}
_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev