Author: dimuthul
Date: Wed Dec 5 01:10:26 2007
New Revision: 10526
Log:
Adding email verification.
Added:
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowUserVerificationAction.java
trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/userverification.jsp
Modified:
trunk/solutions/identity/modules/admin-ui/pom.xml
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/ShowUserManagementAction.java
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/UpdateGlobalUserManagementPropertiesAction.java
trunk/solutions/identity/modules/admin-ui/src/main/resources/org/wso2/solutions/identity/package.properties
trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml
trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/usermanagement.jsp
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/IdentityConstants.java
trunk/solutions/identity/modules/distribution/src/assemble/assembly-bin.xml
trunk/solutions/identity/modules/identity-provider/pom.xml
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/IdentityProviderConstants.java
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/Initializer.java
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/resources.properties
trunk/solutions/identity/modules/user-ui/pom.xml
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/UIConstants.java
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/interceptor/SessionInterceptor.java
trunk/solutions/identity/modules/user-ui/src/main/resources/struts.xml
Modified: trunk/solutions/identity/modules/admin-ui/pom.xml
==============================================================================
--- trunk/solutions/identity/modules/admin-ui/pom.xml (original)
+++ trunk/solutions/identity/modules/admin-ui/pom.xml Wed Dec 5 01:10:26 2007
@@ -73,7 +73,7 @@
<groupId>org.wso2.commons.usermanager</groupId>
<artifactId>usermanager-core</artifactId>
<version>${usermanager.version}</version>
- <exclusions>
+ <exclusions>
<exclusion>
<groupId>org.acegisecurity</groupId>
<artifactId>acegi-security</artifactId>
@@ -99,6 +99,15 @@
<version>${usermanager.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.wso2.commons.usermanager</groupId>
+ <artifactId>user-verification</artifactId>
+ <version>${usermanager.version}</version>
+ <exclusions>
+ <excludeTransitive>true</excludeTransitive>
+ </exclusions>
+ </dependency>
+
<!-- AXIOM Dependencies -->
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
Modified:
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/ShowUserManagementAction.java
==============================================================================
---
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/ShowUserManagementAction.java
(original)
+++
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/ShowUserManagementAction.java
Wed Dec 5 01:10:26 2007
@@ -19,24 +19,48 @@
import org.wso2.solutions.identity.IdentityProviderConstants;
import org.wso2.solutions.identity.admin.ParameterAdmin;
-
-public class ShowUserManagementAction extends ManagedAction {
+public class ShowUserManagementAction
+ extends ManagedAction {
private static final long serialVersionUID = -3406313561520890097L;
private boolean allowUserRegistration;
-
+
private boolean enableEmailVerification;
-
+
+ private int port = 0;
+
+ private String host = null;
+
+ private String fromAddress = null;
+
+ private String username = null;
+
+ private String password = null;
+
@Override
public String execute() throws Exception {
ParameterAdmin admin = new ParameterAdmin();
-
+
this.allowUserRegistration = admin
.getParameter(IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION) !=
null;
this.enableEmailVerification = admin
.getParameter(IdentityProviderConstants.PARAM_NAME_ENABLE_EMAIL_VERIFICATION)
!= null;
-
+
+ String value = admin
+
.getParameterValue(IdentityProviderConstants.PARAM_NAME_EMAIL_PORT);
+ if (value != null) {
+ this.port = Integer.parseInt(value);
+ }
+ this.host = admin
+
.getParameterValue(IdentityProviderConstants.PARAM_NAME_EMAIL_HOST);
+ this.fromAddress = admin
+
.getParameterValue(IdentityProviderConstants.PARAM_NAME_EMAIL_FROM_ADDRESS);
+ this.username = admin
+
.getParameterValue(IdentityProviderConstants.PARAM_NAME_EMAIL_USERNAME);
+ this.password = admin
+
.getParameterValue(IdentityProviderConstants.PARAM_NAME_EMAIL_PASSWORD);
+
return SUCCESS;
}
@@ -47,5 +71,53 @@
public boolean isEnableEmailVerification() {
return enableEmailVerification;
}
-
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public String getFromAddress() {
+ return fromAddress;
+ }
+
+ public void setFromAddress(String fromAddress) {
+ this.fromAddress = fromAddress;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public void setAllowUserRegistration(boolean allowUserRegistration) {
+ this.allowUserRegistration = allowUserRegistration;
+ }
+
+ public void setEnableEmailVerification(boolean enableEmailVerification) {
+ this.enableEmailVerification = enableEmailVerification;
+ }
+
}
Modified:
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/UpdateGlobalUserManagementPropertiesAction.java
==============================================================================
---
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/UpdateGlobalUserManagementPropertiesAction.java
(original)
+++
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/UpdateGlobalUserManagementPropertiesAction.java
Wed Dec 5 01:10:26 2007
@@ -17,6 +17,7 @@
package org.wso2.solutions.identity.admin.ui.action;
import org.wso2.solutions.identity.IdentityProviderConstants;
+import org.wso2.solutions.identity.IdentityProviderException;
import org.wso2.solutions.identity.admin.ParameterAdmin;
public class UpdateGlobalUserManagementPropertiesAction extends ManagedAction {
@@ -27,23 +28,79 @@
private boolean enableEmailVerification;
+ private int port = 0;
+
+ private String host = null;
+
+ private String fromAddress = null;
+
+ private String username = null;
+
+ private String password = null;
+
@Override
public String execute() throws Exception {
- ParameterAdmin admin = new ParameterAdmin();
-
- if(allowUserRegistration) {
-
admin.createOrUpdatearameter(IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION,
null);
- } else {
-
admin.removeParam(IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION);
- }
-
- if(enableEmailVerification) {
-
admin.createOrUpdatearameter(IdentityProviderConstants.PARAM_NAME_ENABLE_EMAIL_VERIFICATION,
null);
- } else {
-
admin.removeParam(IdentityProviderConstants.PARAM_NAME_ENABLE_EMAIL_VERIFICATION);
- }
-
+
+ try {
+ ParameterAdmin admin = new ParameterAdmin();
+ if (enableEmailVerification) {
+ if (port == 0 || host == null || fromAddress == null) {
+ // TODO error
+ return ERROR;
+ }
+
+ this.host = host.trim();
+ this.fromAddress = fromAddress.trim();
+ this.username = username.trim();
+ this.password = password.trim();
+
+ admin.createOrUpdatearameter(
+ IdentityProviderConstants.PARAM_NAME_EMAIL_PORT,
+ Integer.toString(port));
+ admin.createOrUpdatearameter(
+ IdentityProviderConstants.PARAM_NAME_EMAIL_HOST, host);
+ admin
+ .createOrUpdatearameter(
+
IdentityProviderConstants.PARAM_NAME_EMAIL_FROM_ADDRESS,
+ fromAddress);
+
+ if (username.length() != 0) {
+ admin
+ .createOrUpdatearameter(
+
IdentityProviderConstants.PARAM_NAME_EMAIL_USERNAME,
+ username);
+ admin
+ .createOrUpdatearameter(
+
IdentityProviderConstants.PARAM_NAME_EMAIL_PASSWORD,
+ password);
+ }
+
+ admin
+ .createOrUpdatearameter(
+
IdentityProviderConstants.PARAM_NAME_ENABLE_EMAIL_VERIFICATION,
+ null);
+
+
+
+ } else {
+ admin
+
.removeParam(IdentityProviderConstants.PARAM_NAME_ENABLE_EMAIL_VERIFICATION);
+ }
+
+ if (allowUserRegistration) {
+ admin
+ .createOrUpdatearameter(
+
IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION,
+ null);
+ } else {
+ admin
+
.removeParam(IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION);
+ }
+ } catch (IdentityProviderException e) {
+ return ERROR;
+ }
+
return SUCCESS;
}
@@ -57,4 +114,66 @@
this.enableEmailVerification = enableEmailVerification;
}
+
+ public int getPort() {
+ return port;
+ }
+
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+
+ public String getHost() {
+ return host;
+ }
+
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+
+ public String getFromAddress() {
+ return fromAddress;
+ }
+
+
+ public void setFromAddress(String fromAddress) {
+ this.fromAddress = fromAddress;
+ }
+
+
+ public String getUsername() {
+ return username;
+ }
+
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+
+ public String getPassword() {
+ return password;
+ }
+
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+
+ public boolean isAllowUserRegistration() {
+ return allowUserRegistration;
+ }
+
+
+ public boolean isEnableEmailVerification() {
+ return enableEmailVerification;
+ }
+
+
+
}
Modified:
trunk/solutions/identity/modules/admin-ui/src/main/resources/org/wso2/solutions/identity/package.properties
==============================================================================
---
trunk/solutions/identity/modules/admin-ui/src/main/resources/org/wso2/solutions/identity/package.properties
(original)
+++
trunk/solutions/identity/modules/admin-ui/src/main/resources/org/wso2/solutions/identity/package.properties
Wed Dec 5 01:10:26 2007
@@ -8,12 +8,15 @@
email_validation=Email address is invalid.
login_successful = {0} successfully logged in!
user_successfully_added = User registration successful : {0}
+please_check_mail = Please check mail at : {0}
no_selector=Seems like you don't have an information card selector installed
card_alredy_registered = Card that issues tokens with ppid : {0} already
registered please use another information card
register-card-already-exists = Information card already registered : You might
be trying to register a card that belongs to someone else!
relying-party-exists = Relying party already exists
no-cert-file = Certificate file not available
cert-invalid = Invalid certificate
+unable_to_verify_string = Your request is invalid or expired! Please try again.
+successful_verification = You are successfully verified. You may login now!!
add_claim_duplicate_claim = Duplicate claim : {0}
add_claim_uri_null = Claim URI missing
Modified:
trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml
==============================================================================
--- trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml
(original)
+++ trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml
Wed Dec 5 01:10:26 2007
@@ -189,8 +189,8 @@
<action name="ShowUserManagement"
class="org.wso2.solutions.identity.admin.ui.action.ShowUserManagementAction">
<result name="success">jsp/usermanagement.jsp</result>
</action>
- <action name="UpdateGlobalUserManagementProperties"
class="org.wso2.solutions.identity.admin.ui.action.UpdateGlobalUserManagementPropertiesAction">
- <result name="success"
type="redirect">ShowUserManagement.action</result>
+ <action name="UpdateGlobalUserManagementProperties"
class="org.wso2.solutions.identity.admin.ui.action.UpdateGlobalUserManagementPropertiesAction">
+ <result name="success">jsp/usermanagement.jsp</result>
</action>
<!-- User management : END -->
Modified:
trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/usermanagement.jsp
==============================================================================
---
trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/usermanagement.jsp
(original)
+++
trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/usermanagement.jsp
Wed Dec 5 01:10:26 2007
@@ -33,19 +33,46 @@
<div class="breadcrumb"><a
class="breadcrumb-link" href="ShowMain.action">Home</a> | User Management</div>
<h1 class="headding-userstores">User
Management</h1>
-
- <s:form action="UpdateGlobalUserManagementProperties"
method="post" enctype="multipart/form-data" theme="simple">
- <table cellpadding="0" cellspacing="0" border="0"
class="form-table">
- <tr>
- <td>Allow User Registration :</td><td>
<s:checkbox name="allowUserRegistration" value="allowUserRegistration"
fieldValue="true"/></td></tr>
- <tr>
- <td>Enable Email Verification
:</td><td><s:checkbox name="enableEmailVerification"
value="enableEmailVerification" fieldValue="true"/></td></tr>
- <tr>
- <td><s:submit cssClass="button" type="button"
label="Update" value="Update"/></td><td></td>
- </tr>
- </table>
-
+
+ <s:form action="UpdateGlobalUserManagementProperties"
method="post" theme="simple">
+ <table cellpadding="0" cellspacing="0" border="0"
class="form-table">
+ <tr>
+ <td>Allow User Registration :</td><td>
<s:checkbox name="allowUserRegistration" value="allowUserRegistration"
fieldValue="true"/></td>
+ </tr>
+ <tr>
+ <td>Enable Email Verification
:</td><td><s:checkbox name="enableEmailVerification"
value="enableEmailVerification" fieldValue="true"/></td>
+ </tr>
+ <tr>
+ <td>
+ <table cellpadding="0" cellspacing="0"
border="0" class="form-table">
+ <tr>
+ <td>Email host</td>
+ <td><s:textfield name="host"
value="%{host}"/></td>
+ </tr>
+ <tr>
+ <td>Email host port</td>
+ <td><s:textfield name="port"
value="%{port}"/></td>
+ </tr>
+ <tr>
+ <td>Host user name</td>
+ <td><s:textfield
name="username" value="%{username}"/></td>
+ </tr>
+ <tr>
+ <td>Host password</td>
+ <td><s:password name="password"
label="password"/></td>
+ </tr>
+ <tr>
+ <td>From address</td>
+ <td><s:textfield
name="fromAddress" value="%{fromAddress}"/></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td><s:submit cssClass="button" type="button"
label="Update" value="Update"/></td><td></td>
+ </tr>
+ </table>
</s:form>
</td>
Modified:
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/IdentityConstants.java
==============================================================================
---
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/IdentityConstants.java
(original)
+++
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/IdentityConstants.java
Wed Dec 5 01:10:26 2007
@@ -78,6 +78,9 @@
public final static String PARAM_USE_SYMM_BINDING = "useSymmBinding";
+ public final static String USER_VERIFICATION_PAGE =
"/UserVerification.action";
+ public final static String USER_VERIFICATION_PARAM = "confString";
+
}
Modified:
trunk/solutions/identity/modules/distribution/src/assemble/assembly-bin.xml
==============================================================================
--- trunk/solutions/identity/modules/distribution/src/assemble/assembly-bin.xml
(original)
+++ trunk/solutions/identity/modules/distribution/src/assemble/assembly-bin.xml
Wed Dec 5 01:10:26 2007
@@ -60,6 +60,7 @@
<include>org.wso2.solutions.identity:wso2is-idp-sample:jar</include>
<!-- Other 3rd party jars-->
<include>org.apache.axis2:mex-impl:jar</include>
+
<include>org.wso2.commons.usermanager:user-verification:jar</include>
<include>org.wso2.commons.usermanager:usermanager-core:jar</include>
<include>org.wso2.commons.usermanager:usermanager-config-annotation:jar</include>
<!-- todo to new version-->
Modified: trunk/solutions/identity/modules/identity-provider/pom.xml
==============================================================================
--- trunk/solutions/identity/modules/identity-provider/pom.xml (original)
+++ trunk/solutions/identity/modules/identity-provider/pom.xml Wed Dec 5
01:10:26 2007
@@ -45,6 +45,15 @@
<dependencies>
+ <dependency>
+ <groupId>org.wso2.commons.usermanager</groupId>
+ <artifactId>user-verification</artifactId>
+ <version>${usermanager.version}</version>
+ <exclusions>
+ <excludeTransitive>true</excludeTransitive>
+ </exclusions>
+ </dependency>
+
<dependency>
<groupId>org.wso2.solutions.identity</groupId>
<artifactId>wso2is-base</artifactId>
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/IdentityProviderConstants.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/IdentityProviderConstants.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/IdentityProviderConstants.java
Wed Dec 5 01:10:26 2007
@@ -90,6 +90,7 @@
public final static String ISSUER_SELF = "Self";
+
/**
* Local names of the identity provider constants
*/
@@ -157,6 +158,18 @@
public final static String PARAM_NAME_ENABLE_EMAIL_VERIFICATION =
"enableEmailVerification";
+ public final static String PARAM_NAME_EMAIL_PORT = "email_host_port";
+
+ public final static String PARAM_NAME_EMAIL_HOST = "email_host";
+
+ public final static String PARAM_NAME_EMAIL_FROM_ADDRESS = "email_from";
+
+ public final static String PARAM_NAME_EMAIL_USERNAME = "email_username";
+
+ public final static String PARAM_NAME_EMAIL_PASSWORD = "email_password";
+
+ public final static String PARAM_NAME_EMAIL_VERIFICATION_EPR = "email_epr";
+
/**
* Sample related constants of the identity provider
*/
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/Initializer.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/Initializer.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/Initializer.java
Wed Dec 5 01:10:26 2007
@@ -15,6 +15,9 @@
*/
package org.wso2.solutions.identity;
+import java.util.ArrayList;
+import java.util.Iterator;
+
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.commons.logging.Log;
@@ -34,21 +37,21 @@
import org.wso2.solutions.identity.persistence.dataobject.RelyingPartyDO;
import org.wso2.solutions.identity.persistence.dataobject.VerifierServiceIdpDO;
import org.wso2.solutions.identity.users.wsas.WSASRealm;
+import org.wso2.usermanager.Realm;
import org.wso2.usermanager.custom.jdbc.JDBCRealm;
import org.wso2.usermanager.custom.jdbc.JDBCRealmConfig;
import org.wso2.usermanager.custom.ldap.LDAPRealm;
import org.wso2.usermanager.custom.ldap.LDAPRealmConfig;
import org.wso2.usermanager.readwrite.DefaultRealm;
import org.wso2.usermanager.readwrite.DefaultRealmConfig;
+import org.wso2.usermanager.verification.email.EmailVerifier;
+import org.wso2.usermanager.verification.email.EmailVerifierConfig;
import org.wso2.utils.ServerConfiguration;
import org.wso2.utils.ServerException;
import org.wso2.wsas.ServerConstants;
import org.wso2.wsas.ServerInitializer;
import org.wso2.wsas.admin.service.UserAdmin;
-import java.util.ArrayList;
-import java.util.Iterator;
-
/**
* WSO2 WSAS <code>ServerInitializer</code> implementation to carry out
* initial configuration setup of the Identity Solution : Identity Provider.
@@ -70,12 +73,12 @@
ConfigurationContextHolder.setConfigurationContext(ctx);
-
try {
IPPersistenceManager db = IPPersistenceManager
.getPersistanceManager();
- // Checking whether the initial startup - at least one dialect
must be there
+ // Checking whether the initial startup - at least one dialect must
+ // be there
DialectDO[] dialectDOs = db.getAllSupportedDialects();
boolean isInitial = false;
if (dialectDOs.length == 0) {
@@ -83,18 +86,18 @@
}
STSConfigAdmin.configuraServices(isInitial);
-
- if(isInitial){
+
+ if (isInitial) {
addDialectsAndClaims();
-
+
setupRelyingPartyUserAccounts();
-
+
addParameters();
-
+
setupAllRealms();
-
+
addActions();
-
+
// Add the globally trusted relying party
RelyingPartyDO rp = new RelyingPartyDO();
rp = new RelyingPartyDO();
@@ -106,30 +109,27 @@
.getFirstProperty("Security.KeyStore.KeyAlias"));
db.create(rp);
-
-
- //// remove the below 4 lines after dumindoo's fix
+ // // remove the below 4 lines after dumindoo's fix
VerifierServiceIdpDO idp = new VerifierServiceIdpDO();
idp.setHostName("localhost");
idp.setGlobal(true);
db.create(idp);
}
-
-
+
+ initializeEmailVerifier();
+
} catch (Exception e) {
throw new AxisFault(e.getMessage(), e);
}
-
log.info(messages.getMessage("initDone"));
}
- private void setupAllRealms()
- throws Exception {
+ private void setupAllRealms() throws Exception {
IPPersistenceManager db = IPPersistenceManager.getPersistanceManager();
- // Add JDBC realm
+ // Add JDBC realm
RealmDO jdbcRealm = new RealmDO();
jdbcRealm.setClassName(JDBCRealm.class.getName());
jdbcRealm.setConfigClassName(JDBCRealmConfig.class.getName());
@@ -146,19 +146,16 @@
wsasRealm.setConfigClassName(null);
db.create(wsasRealm);
-
RealmConfigurationDO wsasRealmConfig = new RealmConfigurationDO();
wsasRealmConfig.setName("wsasRealmForAccessControlSample");
wsasRealmConfig.setRealm(wsasRealm);
db.create(wsasRealmConfig);
-
+
RealmDO defaultRalm = new RealmDO();
defaultRalm.setClassName(DefaultRealm.class.getName());
- defaultRalm.setConfigClassName(DefaultRealmConfig.class
- .getName());
+ defaultRalm.setConfigClassName(DefaultRealmConfig.class.getName());
db.create(defaultRalm);
-
-
+
// Add default realm configuration
RealmConfigurationDO realmConfig = new RealmConfigurationDO();
realmConfig.setName("defaultRealm");
@@ -197,14 +194,15 @@
+ "/conf/"
+ IdentityProviderConstants.Default.SQL_STATEMENTS_FILE_PATH);
db.create(prop);
-
+
this.setupSampleRealmConfig(db, jdbcRealm);
-
- //Enable user registration
+
+ // Enable user registration
ParameterAdmin paramAdmin = new ParameterAdmin();
paramAdmin.createOrUpdatearameter(
IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION,
null);
+
}
/**
@@ -216,7 +214,7 @@
*/
private void setupSampleRealmConfig(IPPersistenceManager db,
RealmDO jdbcRealm) throws Exception {
-
+
// Add sample realm configuration
RealmConfigurationDO realmConfig = new RealmConfigurationDO();
realmConfig.setName("sampleRealm");
@@ -280,9 +278,9 @@
db.create(prop);
}
-
-
- private void addDialectsAndClaims() throws IdentityProviderException,
AxisFault{
+
+ private void addDialectsAndClaims() throws IdentityProviderException,
+ AxisFault {
IPPersistenceManager db = IPPersistenceManager.getPersistanceManager();
if (log.isDebugEnabled()) {
log.debug(messages.getMessage("addingInitialClaimsInfo"));
@@ -317,33 +315,27 @@
}
ClaimDO claim = claimDOs[i];
- if (claim.getUri().equals(
- IdentityConstants.CLAIM_EMAIL_ADDRESS)) {
+ if (claim.getUri().equals(IdentityConstants.CLAIM_EMAIL_ADDRESS)) {
claim.setAttrId(IdentityConstants.CLAIM_EMAIL_ADDRESS);
- } else if (claim.getUri().equals(
- IdentityConstants.CLAIM_GIVEN_NAME)) {
+ } else if (claim.getUri()
+ .equals(IdentityConstants.CLAIM_GIVEN_NAME)) {
claim.setAttrId(IdentityConstants.CLAIM_GIVEN_NAME);
- } else if (claim.getUri().equals(
- IdentityConstants.CLAIM_SURNAME)) {
+ } else if (claim.getUri().equals(IdentityConstants.CLAIM_SURNAME))
{
claim.setAttrId(IdentityConstants.CLAIM_SURNAME);
}
- if (claim.getUri().equals(
- IdentityConstants.CLAIM_EMAIL_ADDRESS)
- || claim.getUri().equals(
- IdentityConstants.CLAIM_GIVEN_NAME)
- || claim.getUri().equals(
- IdentityConstants.CLAIM_SURNAME)
- || claim.getUri().equals(
- IdentityConstants.CLAIM_PPID)) {
+ if (claim.getUri().equals(IdentityConstants.CLAIM_EMAIL_ADDRESS)
+ || claim.getUri()
+ .equals(IdentityConstants.CLAIM_GIVEN_NAME)
+ || claim.getUri().equals(IdentityConstants.CLAIM_SURNAME)
+ || claim.getUri().equals(IdentityConstants.CLAIM_PPID)) {
claim.setSupported(true);
claimsAdmin.updateClaim(claim);
}
- }
-
+ }
+
}
-
-
+
/**
* Called only when the Identity Solution is coming up for the first time
*/
@@ -364,27 +356,81 @@
}
- /**
+ private void initializeEmailVerifier() throws Exception{
+ ParameterAdmin admin = new ParameterAdmin();
+ boolean enableEmailVerification = admin
+
.getParameter(IdentityProviderConstants.PARAM_NAME_ENABLE_EMAIL_VERIFICATION)
!= null;
+
+ if(!enableEmailVerification){
+ return;
+ }
+ String value = admin
+
.getParameterValue(IdentityProviderConstants.PARAM_NAME_EMAIL_PORT);
+ int port = 0;
+
+ if (value != null) {
+ port = Integer.parseInt(value);
+ }
+
+ String host = admin
+
.getParameterValue(IdentityProviderConstants.PARAM_NAME_EMAIL_HOST);
+ String fromAddress = admin
+
.getParameterValue(IdentityProviderConstants.PARAM_NAME_EMAIL_FROM_ADDRESS);
+ String username = admin
+
.getParameterValue(IdentityProviderConstants.PARAM_NAME_EMAIL_USERNAME);
+ String password = admin
+
.getParameterValue(IdentityProviderConstants.PARAM_NAME_EMAIL_PASSWORD);
+
+ UserStore store = UserStore.getInstance();
+ Realm realm = store.getRealm();
+
+ EmailVerifierConfig config = new EmailVerifierConfig();
+ config.setFromAddress(fromAddress);
+ config.setHost(host);
+ if (username.length() != 0) {
+ config.setPassword(password);
+ config.setUsername(username);
+ }
+ ServerConfiguration serverConfig = ServerConfiguration
+ .getInstance();
+
+ String hostName = serverConfig.getFirstProperty("HostName");
+ String hostPort = serverConfig.getFirstProperty("Ports.HTTPS");
+
+ String verificationAddress = "https://" + hostName + ":"
+ + hostPort
+ + IdentityConstants.USER_VERIFICATION_PAGE;
+
+ config.setRegistrationServiceEPR(verificationAddress);
+ config.setPort(port);
+ if (realm.getClass().getName().equals(
+ DefaultRealm.class.getName())) {
+ EmailVerifier.init(realm, config);
+ } else {
+ throw new IdentityProviderException("emailNotActivated");
+ }
+
+ }
+
+ /**
* Called only when the Identity Solution is coming up for the first time
*/
private void addParameters() throws Exception {
ParameterAdmin admin = new ParameterAdmin();
-
admin.createOrUpdatearameter(IdentityConstants.PARAM_SUPPORTED_TOKEN_TYPES,
+ admin.createOrUpdatearameter(
+ IdentityConstants.PARAM_SUPPORTED_TOKEN_TYPES,
IdentityConstants.SAML10_URL + ","
+ IdentityConstants.SAML11_URL);
admin.createOrUpdatearameter(IdentityConstants.PARAM_CARD_NAME,
IdentityConstants.PARAM_VALUE_CARD_NAME);
admin.createOrUpdatearameter(IdentityConstants.PARAM_VALID_PERIOD,
IdentityConstants.PARAM_VALUE_VALID_PERIOD);
-
+
}
-
- private void addActions() throws Exception{
-
-
-
+
+ private void addActions() throws Exception {
IPPersistenceManager db = IPPersistenceManager.getPersistanceManager();
- for(int i=0;i<ActionDO.actions.length; i++){
+ for (int i = 0; i < ActionDO.actions.length; i++) {
ActionDO act = new ActionDO();
act.setActionId(ActionDO.actions[i]);
db.create(act);
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/resources.properties
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/resources.properties
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/resources.properties
Wed Dec 5 01:10:26 2007
@@ -49,7 +49,7 @@
deletedRp = Deleted trusted relying party : {0}
relyingPartyExists = Relying party {0} already exists
errorInKeystoreAccess = Error accessing keystore
-
+emailNotActivated = Email Verification not activted now, but all parameters
are saved. It will be activated when DefaultRealm is selected.
#db errors
createDuplicateEntity = Duplcate entity exist
errorCreatingEntity = Error creating entity in the database
Modified: trunk/solutions/identity/modules/user-ui/pom.xml
==============================================================================
--- trunk/solutions/identity/modules/user-ui/pom.xml (original)
+++ trunk/solutions/identity/modules/user-ui/pom.xml Wed Dec 5 01:10:26 2007
@@ -39,8 +39,15 @@
</build>
<dependencies>
-
- <dependency>
+ <dependency>
+ <groupId>org.wso2.commons.usermanager</groupId>
+ <artifactId>user-verification</artifactId>
+ <version>${usermanager.version}</version>
+ <exclusions>
+ <excludeTransitive>true</excludeTransitive>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.wso2.solutions.identity</groupId>
<artifactId>wso2is-identity-provider</artifactId>
<version>${pom.version}</version>
Modified:
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/UIConstants.java
==============================================================================
---
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/UIConstants.java
(original)
+++
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/UIConstants.java
Wed Dec 5 01:10:26 2007
@@ -42,9 +42,9 @@
public final static String LOGIN_JSP = "/jsp/login.jsp";
public final static String JSP_ERROR_PAGE = "/jsp/error.jsp";
-
+
public final static String CARD_ISSUER_CONFIG_PATH =
"WEB-INF/infocard-issuer-config.xml";
public final static String MAIN_PAGE_MESSAGES = "mainMessages";
-
+
}
Added:
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowUserVerificationAction.java
==============================================================================
--- (empty file)
+++
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/ShowUserVerificationAction.java
Wed Dec 5 01:10:26 2007
@@ -0,0 +1,38 @@
+package org.wso2.solutions.identity.user.ui.action;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts2.StrutsStatics;
+import org.wso2.usermanager.verification.email.EmailVerifier;
+
+import com.opensymphony.xwork2.ActionContext;
+
+public class ShowUserVerificationAction
+ extends ManagedAction {
+
+ public String execute() throws Exception {
+ String result = ERROR;
+
+ HttpServletRequest request = (HttpServletRequest) ActionContext
+ .getContext().get(StrutsStatics.HTTP_REQUEST);
+ String[] values = request
+ .getParameterValues(EmailVerifier.CONF_STRING);
+
+ String stuff = request
+ .getParameter(EmailVerifier.CONF_STRING);
+
+ if (values != null && values.length > 0) {
+ EmailVerifier verifier = new EmailVerifier();
+ boolean value = verifier.confirmUser(values[0]);
+ if (value == false) {
+ this.addErrorMessage(getText("unable_to_verify_string"));
+ } else {
+ this.addInfoMessage(getText("successful_verification"));
+ result = SUCCESS;
+ }
+ }
+ loadMessages();
+ return result;
+ }
+
+}
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
Wed Dec 5 01:10:26 2007
@@ -18,12 +18,15 @@
import org.apache.struts2.StrutsStatics;
import org.wso2.solutions.identity.IdentityConstants;
+import org.wso2.solutions.identity.IdentityProviderConstants;
import org.wso2.solutions.identity.UserStore;
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.persistence.dataobject.ActionDO;
import org.wso2.solutions.identity.persistence.dataobject.ClaimDO;
import org.wso2.usermanager.UserManagerException;
+import org.wso2.usermanager.verification.email.EmailVerifier;
import javax.servlet.http.HttpServletRequest;
@@ -34,7 +37,8 @@
import com.opensymphony.xwork2.validator.annotations.Validation;
@Validation
-public class UserRegistrationFormSubmitAction extends ManagedAction {
+public class UserRegistrationFormSubmitAction
+ extends ManagedAction {
private static final long serialVersionUID = -4791453858953047850L;
@@ -44,34 +48,54 @@
public String execute() throws Exception {
UserStore store = UserStore.getInstance();
- try {
- store.getRealm().getUserStoreAdmin().addUser(this.username,
this.password);
- } catch (UserManagerException e) {
- //Right now we cannot check whether a given user exists
- //therefore at this point we have to set the error msg
- //based on the exception
- this.addErrorMessage(getText("sign_in_user_exist", new String[]
{this.username}));
- return ERROR;
- }
-
ClaimsAdmin ClaimsAdmin = new ClaimsAdmin();
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++) {
String uri = claimDOs[i].getUri();
- if(!uri.equals(IdentityConstants.CLAIM_PPID)) {
+ if (!uri.equals(IdentityConstants.CLAIM_PPID)) {
props.put(uri, request.getParameter(uri));
}
+
+ if(uri.equals(IdentityConstants.CLAIM_EMAIL_ADDRESS)){
+ emailAddress = request.getParameter(uri);
+ }
+ }
+
+ ParameterAdmin paramAdmin = new ParameterAdmin();
+ boolean emailVerification = paramAdmin
+
.getParameter(IdentityProviderConstants.PARAM_NAME_ENABLE_EMAIL_VERIFICATION)
!= null;
+ if (emailVerification && emailAddress != null) {
+ EmailVerifier verifier = new EmailVerifier();
+ verifier.requestUserVerification(username, emailAddress, password,
props);
+ ReportAdmin.record(username, ActionDO.ACTION_USER_REGISTER, "Email
Verification Sent");
+ this.addInfoMessage(getText("please_check_mail",
+ new String[] { emailAddress }));
+ } else {
+ try {
+ store.getRealm().getUserStoreAdmin().addUser(this.username,
+ this.password);
+
+ } catch (UserManagerException e) {
+ // Right now we cannot check whether a given user exists
+ // therefore at this point we have to set the error msg
+ // based on the exception
+ this.addErrorMessage(getText("sign_in_user_exist",
+ new String[] { this.username }));
+ return ERROR;
+ }
+ store.getRealm().getUserStoreAdmin().setUserProperties(
+ this.username, props);
+ ReportAdmin.record(username, ActionDO.ACTION_USER_REGISTER, "");
+
+ this.addInfoMessage(getText("user_successfully_added",
+ new String[] { username }));
+
}
-
- store.getRealm().getUserStoreAdmin().setUserProperties(this.username,
props);
- ReportAdmin.record(username, ActionDO.ACTION_USER_REGISTER, "");
-
- this.addInfoMessage(getText("user_successfully_added",
- new String[] { username }));
return SUCCESS;
}
@@ -84,6 +108,7 @@
public void setUsername(String username) {
this.username = username;
}
+
@RequiredStringValidator(message = "", key = "password")
public String getPassword() {
return password;
Modified:
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/interceptor/SessionInterceptor.java
==============================================================================
---
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/interceptor/SessionInterceptor.java
(original)
+++
trunk/solutions/identity/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/interceptor/SessionInterceptor.java
Wed Dec 5 01:10:26 2007
@@ -17,6 +17,7 @@
package org.wso2.solutions.identity.user.ui.interceptor;
import org.apache.struts2.StrutsStatics;
+import org.wso2.solutions.identity.IdentityConstants;
import org.wso2.solutions.identity.user.ui.UIConstants;
import javax.servlet.http.HttpServletRequest;
@@ -35,7 +36,9 @@
HttpServletRequest request = (HttpServletRequest) context
.get(StrutsStatics.HTTP_REQUEST);
StringBuffer requestURL = request.getRequestURL();
- if (requestURL.indexOf(UIConstants.LOGIN_ACTION) < 0
+ if(requestURL.indexOf(IdentityConstants.USER_VERIFICATION_PAGE) > 0){
+ return invocation.invoke();
+ }else if (requestURL.indexOf(UIConstants.LOGIN_ACTION) < 0
&& requestURL.toString().indexOf(
UIConstants.INFOCARD_SUBMIT_ACTION) < 0
&& requestURL.toString().indexOf(
Modified: trunk/solutions/identity/modules/user-ui/src/main/resources/struts.xml
==============================================================================
--- trunk/solutions/identity/modules/user-ui/src/main/resources/struts.xml
(original)
+++ trunk/solutions/identity/modules/user-ui/src/main/resources/struts.xml
Wed Dec 5 01:10:26 2007
@@ -93,6 +93,11 @@
<result name="success" type="redirect">ShowMain.action</result>
<result name="error" type="redirect">ShowMain.action</result>
</action>
+
+ <action name="UserVerification"
class="org.wso2.solutions.identity.user.ui.action.ShowUserVerificationAction">
+ <result name="success">jsp/userverification.jsp</result>
+ <result name="error">jsp/userverification.jsp</result>
+ </action>
<action name="RemoveRegisteredInfoCard"
class="org.wso2.solutions.identity.user.ui.action.RemoveRegisteredInfoCardAction">
Added:
trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/userverification.jsp
==============================================================================
--- (empty file)
+++
trunk/solutions/identity/modules/user-ui/src/main/webapp/jsp/userverification.jsp
Wed Dec 5 01:10:26 2007
@@ -0,0 +1,47 @@
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+"http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<title>WSO2 Identity Solution</title>
+<link type="text/css" rel="stylesheet" href="css/styles.css" />
+</head>
+<body>
+<!-- Include the header -->
+<s:include value="header.jsp" />
+
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%;">
+ <tr>
+ <td class="right-back">
+ </td>
+ <td class="content" valign="top">
+ <table cellpadding="0" cellspacing="0" border="0"
style="width:100%;">
+ <tr>
+ <td><h1>WSO2 Identity Provider</h1></td>
+ <td align="right" valign="top"><img
src="images/wso2-identity-content-rounded.jpg" align="top" /></td>
+ </tr>
+ </table>
+
+ <br>
+
+ <s:iterator value="errorMessages">
+ <div class="error-message"><s:property /></div>
+ </s:iterator>
+
+ <s:iterator value="infoMessages">
+ <div class="info-message"><s:property /></div>
+ </s:iterator>
+
+ <p></p>
+ <h3><s:a href="ShowLogin.action">Login</s:a> </h3>
+ <p></p>
+ </td>
+ </tr>
+</table>
+
+<!-- Include footer -->
+<s:include value="footer.jsp" />
+
+</body>
+
+</html>
\ No newline at end of file
_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev