Author: jaz
Date: Sun Oct 7 20:48:24 2007 New Revision: 582705 URL: http://svn.apache.org/viewvc?rev=582705&view=rev Log: implemented code to support pre-account email verification (verify email before account is created) Added: ofbiz/trunk/applications/party/templates/email/VerifyEmailAddressNotification.ftl (with props) Modified: ofbiz/trunk/applications/ecommerce/data/DemoProduct.xml ofbiz/trunk/applications/party/config/PartyUiLabels.properties ofbiz/trunk/applications/party/data/PartyTypeData.xml ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/ContactMechServices.xml ofbiz/trunk/applications/party/servicedef/secas.xml ofbiz/trunk/applications/party/servicedef/services.xml ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java ofbiz/trunk/applications/party/widget/partymgr/PartyEmailNotification.xml ofbiz/trunk/framework/security/config/security.properties ofbiz/trunk/specialpurpose/cmssite/webapp/cmssite/WEB-INF/controller.xml Modified: ofbiz/trunk/applications/ecommerce/data/DemoProduct.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/data/DemoProduct.xml?rev=582705&r1=582704&r2=582705&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/data/DemoProduct.xml (original) +++ ofbiz/trunk/applications/ecommerce/data/DemoProduct.xml Sun Oct 7 20:48:24 2007 @@ -92,6 +92,7 @@ <ProductStoreEmailSetting productStoreId="9000" emailType="PARTY_REGIS_CONFIRM" bodyScreenLocation="component://party/widget/partymgr/PartyEmailNotification.xml#CreatePartyNotification" subject="New Account Created" bccAddress="[hidden email]" fromAddress="[hidden email]"/> <ProductStoreEmailSetting productStoreId="9000" emailType="UPD_PRSNL_INF_CNFRM" bodyScreenLocation="component://party/widget/partymgr/PartyEmailNotification.xml#ChangePersonalInfoNotification" subject="Personal Information Updated" bccAddress="[hidden email]" fromAddress="[hidden email]"/> + <ProductStoreEmailSetting productStoreId="9000" emailType="PRDS_EMAIL_VERIFY" bodyScreenLocation="component://party/widget/partymgr/PartyEmailNotification.xml#VerifyEmailAddressNotification" subject="Email Address Verification" bccAddress="[hidden email]" fromAddress="[hidden email]"/> <ProductStoreFacility productStoreId="9000" facilityId="WebStoreWarehouse" fromDate="2001-05-13 12:00:00.0"/> <ProductStoreRole partyId="admin" roleTypeId="SALES_REP" productStoreId="9000" fromDate="2001-05-13 12:00:00.0"/> Modified: ofbiz/trunk/applications/party/config/PartyUiLabels.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/config/PartyUiLabels.properties?rev=582705&r1=582704&r2=582705&view=diff ============================================================================== --- ofbiz/trunk/applications/party/config/PartyUiLabels.properties (original) +++ ofbiz/trunk/applications/party/config/PartyUiLabels.properties Sun Oct 7 20:48:24 2007 @@ -265,8 +265,10 @@ PartyEmailAddresses=Email Addresses PartyEmailAddressMissing=Email Address is missing PartyEmailAddressNotFormattedCorrectly=Email Address is not formatted correctly, must be like [hidden email] +PartyEmailAddressNotExist=The Email Address cannot be verified. This Email Address does not exists. PartyEmailAddressSuccessfullyCreated=Email Address successfully created. PartyEmailAddressSuccessfullyUpdated=Email Address successfully updated. +PartyEmailAddressVerificationExpired=The Email Address Verification has been expired. PartyEnabled=ENABLED PartyEnteredDate=Entered Date PartyEnterPasswordTwice=You must enter your password twice Modified: ofbiz/trunk/applications/party/data/PartyTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/data/PartyTypeData.xml?rev=582705&r1=582704&r2=582705&view=diff ============================================================================== --- ofbiz/trunk/applications/party/data/PartyTypeData.xml (original) +++ ofbiz/trunk/applications/party/data/PartyTypeData.xml Sun Oct 7 20:48:24 2007 @@ -139,6 +139,7 @@ <EnumerationType description="Party Email Notification" enumTypeId="PARTY_EMAIL" hasTable="N" parentTypeId=""/> <Enumeration description="Party Registration Confirmation Mail" enumCode="REGIS_CONFIRM" enumId="PARTY_REGIS_CONFIRM" sequenceId="01" enumTypeId="PARTY_EMAIL"/> <Enumeration description="Update Personal Info Confirmation" enumCode="UPDAT_CONFIRM" enumId="UPD_PRSNL_INF_CNFRM" sequenceId="02" enumTypeId="PARTY_EMAIL"/> + <Enumeration description="Party Email Address Verification" enumCode="EMAIL_VERIFY" enumId="PRDS_EMAIL_VERIFY" sequenceId="03" enumTypeId="PARTY_EMAIL"/> <!-- top level role types --> <RoleType description="Administrator" hasTable="N" parentTypeId="" roleTypeId="ADMIN"/> Modified: ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/ContactMechServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/ContactMechServices.xml?rev=582705&r1=582704&r2=582705&view=diff ============================================================================== --- ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/ContactMechServices.xml (original) +++ ofbiz/trunk/applications/party/script/org/ofbiz/party/contact/ContactMechServices.xml Sun Oct 7 20:48:24 2007 @@ -289,4 +289,44 @@ <entity-one entity-name="ContactMechAttribute" value-name="lookedUpValue"/> <remove-value value-name="lookedUpValue"/> </simple-method> + <simple-method method-name="sendVerifyEmailAddressNotification" short-description="Send an email to the person for Verification of his Email Address" login-required="false"> + <entity-condition entity-name="ProductStoreEmailSetting" list-name="productStoreEmailSettings"> + <condition-list> + <condition-expr field-name="emailType" operator="equals" value="PRDS_EMAIL_VERIFY"/> + </condition-list> + </entity-condition> + <set field="lookupHash.emailAddress" from-field="parameters.emailAddress"/> + <find-by-primary-key value-name="emailAddressVerification" entity-name="EmailAddressVerification" map-name="lookupHash"/> + <set field="bodyParameters.verifyHash" from-field="emailAddressVerification.verifyHash"/> + <first-from-list entry-name="storeEmail" list-name="productStoreEmailSettings"/> + <if-not-empty field-name="bodyScreenLocation" map-name="storeEmail"> + <set field="emailParams.sendTo" from-field="parameters.emailAddress"/> + <set field="emailParams.subject" from-field="storeEmail.subject"/> + <set field="emailParams.sendFrom" from-field="storeEmail.fromAddress"/> + <set field="emailParams.sendCc" from-field="storeEmail.ccAddress"/> + <set field="emailParams.sendBcc" from-field="storeEmail.bccAddress"/> + <set field="emailParams.contentType" from-field="storeEmail.contentType"/> + <set field="emailParams.bodyParameters" from-field="bodyParameters"/> + <set field="emailParams.bodyScreenUri" from-field="storeEmail.bodyScreenLocation"/> + <map-to-map to-map-name="emailParams.bodyParameters" map-name="bodyParameters"/> + <call-service service-name="sendMailFromScreen" in-map-name="emailParams"/> + </if-not-empty> + </simple-method> + <simple-method method-name="verifyEmailAddress" short-description="Verify an Email Address through verifyHash and expireDate" login-required="false"> + <entity-and entity-name="EmailAddressVerification" list-name="emailAddressVerifications"> + <field-map field-name="verifyHash" env-name="parameters.verifyHash"/> + </entity-and> + + <first-from-list list-name="emailAddressVerifications" entry-name="emailAddressVerification"/> + <if-not-empty field-name="emailAddressVerification"> + <now-timestamp-to-env env-name="nowTimestamp"/> + <if-compare-field field-name="emailAddressVerification.expireDate" operator="less" to-field-name="nowTimestamp"> + <add-error><fail-property resource="PartyUiLabels" property="PartyEmailAddressVerificationExpired"/></add-error> + </if-compare-field> + <else> + <add-error><fail-property resource="PartyUiLabels" property="PartyEmailAddressNotExist"/></add-error> + </else> + </if-not-empty> + <check-errors/> + </simple-method> </simple-methods> Modified: ofbiz/trunk/applications/party/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/servicedef/secas.xml?rev=582705&r1=582704&r2=582705&view=diff ============================================================================== --- ofbiz/trunk/applications/party/servicedef/secas.xml (original) +++ ofbiz/trunk/applications/party/servicedef/secas.xml Sun Oct 7 20:48:24 2007 @@ -108,4 +108,8 @@ <eca service="updatePassword" event="commit"> <action service="sendUpdatePersonalInfoEmailNotification" mode="async" persist="true"/> </eca> + + <eca service="createEmailAddressVerification" event="commit"> + <action service="sendVerifyEmailAddressNotification" mode="async"/> + </eca> </service-eca> Modified: ofbiz/trunk/applications/party/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/servicedef/services.xml?rev=582705&r1=582704&r2=582705&view=diff ============================================================================== --- ofbiz/trunk/applications/party/servicedef/services.xml (original) +++ ofbiz/trunk/applications/party/servicedef/services.xml Sun Oct 7 20:48:24 2007 @@ -773,4 +773,20 @@ location="org/ofbiz/party/user/UserEvents.xml" invoke="sendCreatePartyEmailNotification" auth="false"> <attribute name="USER_EMAIL" type="String" mode="IN" optional="false"/> </service> + + <!-- Email address verification services--> + <service name="createEmailAddressVerification" engine="java" default-entity-name="EmailAddressVerification" + location="org.ofbiz.party.contact.ContactMechServices" invoke="createEmailAddressVerification"> + <attribute name="emailAddress" type="String" mode="IN" optional="false"/> + <attribute name="verifyHash" type="String" mode="OUT" optional="false"/> + <attribute name="expireDate" type="String" mode="IN" optional="true"/> + </service> + <service name="sendVerifyEmailAddressNotification" engine="simple" + location="org/ofbiz/party/contact/ContactMechServices.xml" invoke="sendVerifyEmailAddressNotification"> + <attribute name="emailAddress" type="String" mode="IN" optional="false"/> + </service> + <service name="verifyEmailAddress" engine="simple" + location="org/ofbiz/party/contact/ContactMechServices.xml" invoke="verifyEmailAddress"> + <attribute name="verifyHash" type="String" mode="IN" optional="false"/> + </service> </services> Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java?rev=582705&r1=582704&r2=582705&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechServices.java Sun Oct 7 20:48:24 2007 @@ -19,7 +19,10 @@ package org.ofbiz.party.contact; +import java.security.SecureRandom; import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -27,6 +30,7 @@ import java.util.Map; import java.util.Locale; +import org.ofbiz.base.crypto.HashCrypt; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; @@ -1031,4 +1035,55 @@ } return ServiceUtil.returnSuccess(); } + + /** + * Creates an EmailAddressVerification + */ + + public static Map createEmailAddressVerification(DispatchContext dctx, Map context) { + GenericDelegator delegator = (GenericDelegator) dctx.getDelegator(); + String emailAddress = (String) context.get("emailAddress"); + String verifyHash = null; + + String expireTime = UtilProperties.getPropertyValue("security", "email_verification.expire.hours"); + Integer expTime = Integer.valueOf(expireTime); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.HOUR, expTime.intValue()); + Date date = calendar.getTime(); + Timestamp expireDate = UtilDateTime.toTimestamp(date); + + SecureRandom secureRandom = new SecureRandom(); + + synchronized(ContactMechServices.class) { + while(true){ + Long random = secureRandom.nextLong(); + verifyHash = HashCrypt.getDigestHash(Long.toString(random), "MD5"); + List emailAddVerifications = null; + try { + emailAddVerifications = delegator.findByAnd("EmailAddressVerification", UtilMisc.toMap("verifyHash", verifyHash)); + } catch (GenericEntityException e) { + Debug.logError(e.getMessage(), module); + return ServiceUtil.returnError(e.getMessage()); + } + if(UtilValidate.isEmpty(emailAddVerifications)) { + GenericValue emailAddressVerification = delegator.makeValue("EmailAddressVerification", null); + emailAddressVerification.set("emailAddress", emailAddress); + emailAddressVerification.set("verifyHash", verifyHash); + emailAddressVerification.set("expireDate", expireDate); + try { + delegator.create(emailAddressVerification); + } catch (GenericEntityException e) { + Debug.logError(e.getMessage(),module); + return ServiceUtil.returnError(e.getMessage()); + } + break; + } + } + } + + Map result = ServiceUtil.returnSuccess(); + result.put("verifyHash", verifyHash); + return result; + } + } Added: ofbiz/trunk/applications/party/templates/email/VerifyEmailAddressNotification.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/templates/email/VerifyEmailAddressNotification.ftl?rev=582705&view=auto ============================================================================== --- ofbiz/trunk/applications/party/templates/email/VerifyEmailAddressNotification.ftl (added) +++ ofbiz/trunk/applications/party/templates/email/VerifyEmailAddressNotification.ftl Sun Oct 7 20:48:24 2007 @@ -0,0 +1,32 @@ +<#-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> + <title>${title}</title> + <link rel="stylesheet" href="${baseUrl}/images/maincss.css" type="text/css"/> + </head> + <body> + <h1>${title}</h1> + <p class="tabletext">Thank you for registering. Please click the link below to complete your registration.</p> + <br><br> + <a href="${baseUrl}/cmssite/cms/verifyEmailAddress?verifyHash=${parameters.verifyHash}">www.cmssite.com/cms/registration.html</a> + </body> +</html> \ No newline at end of file Propchange: ofbiz/trunk/applications/party/templates/email/VerifyEmailAddressNotification.ftl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/applications/party/templates/email/VerifyEmailAddressNotification.ftl ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/applications/party/templates/email/VerifyEmailAddressNotification.ftl ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/trunk/applications/party/widget/partymgr/PartyEmailNotification.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/widget/partymgr/PartyEmailNotification.xml?rev=582705&r1=582704&r2=582705&view=diff ============================================================================== --- ofbiz/trunk/applications/party/widget/partymgr/PartyEmailNotification.xml (original) +++ ofbiz/trunk/applications/party/widget/partymgr/PartyEmailNotification.xml Sun Oct 7 20:48:24 2007 @@ -40,4 +40,14 @@ </widgets> </section> </screen> + <screen name="VerifyEmailAddressNotification"> + <section> + <actions> + <set field="title" value="Email Address Verification"/> + </actions> + <widgets> + <platform-specific><html><html-template location="component://party/templates/email/VerifyEmailAddressNotification.ftl"/></html></platform-specific> + </widgets> + </section> + </screen> </screens> Modified: ofbiz/trunk/framework/security/config/security.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/security/config/security.properties?rev=582705&r1=582704&r2=582705&view=diff ============================================================================== --- ofbiz/trunk/framework/security/config/security.properties (original) +++ ofbiz/trunk/framework/security/config/security.properties Sun Oct 7 20:48:24 2007 @@ -64,4 +64,7 @@ security.login.cert.allow=true # -- pattern for the userlogin id in CN section of certificate -security.login.cert.pattern=^(\\w*\\s?\\w*)\\W*.*$ \ No newline at end of file +security.login.cert.pattern=^(\\w*\\s?\\w*)\\W*.*$ + +# -- Hours after which EmailAdressVerification should expire +email_verification.expire.hours=48 \ No newline at end of file Modified: ofbiz/trunk/specialpurpose/cmssite/webapp/cmssite/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/cmssite/webapp/cmssite/WEB-INF/controller.xml?rev=582705&r1=582704&r2=582705&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/cmssite/webapp/cmssite/WEB-INF/controller.xml (original) +++ ofbiz/trunk/specialpurpose/cmssite/webapp/cmssite/WEB-INF/controller.xml Sun Oct 7 20:48:24 2007 @@ -106,6 +106,12 @@ <response name="success" type="none"/> <response name="error" type="view" value="error"/> </request-map> + <request-map uri="verifyEmailAddress"> + <security https="false" auth="false"/> + <event type="service" invoke="verifyEmailAddress"/> + <response name="success" type="none"/> + <response name="error" type="view" value="error"/> + </request-map> <!-- End of Request Mappings --> <!-- View Mappings --> |
Free forum by Nabble | Edit this page |