On Sun, Jan 16, 2011 at 9:16 PM, Kathiravelu Pradeeban <[email protected]>wrote:
> > > On Sun, Jan 16, 2011 at 9:06 PM, Thilina Buddhika <[email protected]>wrote: > >> I think it is better to allow domain name pattern to be configurable >> through a reg-ex that goes into stratos.xml, similar to what we do for >> password validations in user manager. >> > > +1. We have a stratos.xml without being used much. We should use that for > these. We check for the regex to validate in both BE and FE. Not sure > whether we should use the stratos.xml for the FE. Won't that be a > performance hit? > You can read it during the start-up from your service component impl. and store it as a static variable. Thanks, Thilina > > Regards, > Pradeeban. > >> >> Thanks, >> Thilina >> >> >> On Sun, Jan 16, 2011 at 7:58 PM, Afkham Azeez <[email protected]> wrote: >> >>> Also, I think making the tenant domain have a dot is not necessary. In >>> Mars, and private cloud deployments, tenants will be departments or other >>> organizational entities. Hence, marketing, engineering, hr, operations etc. >>> should be legal domain names. Also, if there is repeated validation logic, >>> all that must be brought into a single place. >>> >>> Azeez >>> >>> >>> On Sun, Jan 16, 2011 at 7:36 PM, Kathiravelu Pradeeban < >>> [email protected]> wrote: >>> >>>> Fixed the issues discussed above. We should pay a great attention to the >>>> front end files (js, jsp, ..) too, like we do with the java classes, >>>> regarding the code styles and best practices. I noticed many similar issues >>>> in the tenant-mgt module and will fix them sooner. >>>> >>>> Thank you. >>>> Regards, >>>> Pradeeban. >>>> >>>> >>>> On Sun, Jan 16, 2011 at 6:28 PM, Kathiravelu Pradeeban < >>>> [email protected]> wrote: >>>> >>>>> >>>>> >>>>> On Sun, Jan 16, 2011 at 6:20 PM, Afkham Azeez <[email protected]> wrote: >>>>> >>>>>> I think all this can be replaced with a simple regex match which will >>>>>> filter out illegal domain names >>>>>> >>>>>> +1. That's how it is done in tenant.mgt BE. Wonder why it was written >>>>> this way in the FE (register.ui and mgt.ui). Will do the needed fixes, as >>>>> I >>>>> am already in the process of refactoring the above modules of tenant-mgt. >>>>> >>>>> Regards, >>>>> Pradeeban. >>>>> >>>>> >>>>>> On Sun, Jan 16, 2011 at 6:08 PM, Afkham Azeez <[email protected]> wrote: >>>>>> >>>>>>> >>>>>>> >>>>>>> On Sun, Jan 16, 2011 at 4:16 PM, <[email protected]> wrote: >>>>>>> >>>>>>>> Author: pradeeban >>>>>>>> Date: Sun Jan 16 02:46:02 2011 >>>>>>>> New Revision: 85379 >>>>>>>> URL: http://wso2.org/svn/browse/wso2?view=rev&revision=85379 >>>>>>>> >>>>>>>> Log: >>>>>>>> Check the validity of the domain when adding a new tenant by the >>>>>>>> super-admin. >>>>>>>> >>>>>>>> >>>>>>>> Modified: >>>>>>>> >>>>>>>> trunk/stratos/components/tenant-mgt/org.wso2.stratos.tenant.mgt.ui/src/main/resources/web/tenant-mgt/js/tenant_config.js >>>>>>>> >>>>>>>> Modified: >>>>>>>> trunk/stratos/components/tenant-mgt/org.wso2.stratos.tenant.mgt.ui/src/main/resources/web/tenant-mgt/js/tenant_config.js >>>>>>>> URL: >>>>>>>> http://wso2.org/svn/browse/wso2/trunk/stratos/components/tenant-mgt/org.wso2.stratos.tenant.mgt.ui/src/main/resources/web/tenant-mgt/js/tenant_config.js?rev=85379&r1=85378&r2=85379&view=diff >>>>>>>> >>>>>>>> ============================================================================== >>>>>>>> --- >>>>>>>> trunk/stratos/components/tenant-mgt/org.wso2.stratos.tenant.mgt.ui/src/main/resources/web/tenant-mgt/js/tenant_config.js >>>>>>>> (original) >>>>>>>> +++ >>>>>>>> trunk/stratos/components/tenant-mgt/org.wso2.stratos.tenant.mgt.ui/src/main/resources/web/tenant-mgt/js/tenant_config.js >>>>>>>> Sun Jan 16 02:46:02 2011 >>>>>>>> @@ -1,15 +1,33 @@ >>>>>>>> function addTenant(isUpdating) { >>>>>>>> var reason = ""; >>>>>>>> var addTenantForm = document.getElementById('addTenantForm'); >>>>>>>> - var adminPassword = ""; >>>>>>>> - var adminPasswordRepeat = ""; >>>>>>>> + var adminPassword = document.getElementById('admin-password'); >>>>>>>> + var adminPasswordRepeat = >>>>>>>> document.getElementById('admin-password-repeat'); >>>>>>>> + var email = document.getElementById('admin-email'); >>>>>>>> var firstname = document.getElementById('admin-firstname'); >>>>>>>> var lastname = document.getElementById('admin-lastname'); >>>>>>>> - adminPassword = document.getElementById('admin-password'); >>>>>>>> - adminPasswordRepeat = >>>>>>>> document.getElementById('admin-password-repeat'); >>>>>>>> - var email = document.getElementById('admin-email'); >>>>>>>> >>>>>>>> - if (!isUpdating) { >>>>>>>> + if (isUpdating) { >>>>>>>> + // only the given values will be updated, so no need to >>>>>>>> fill all the values. >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateEmpty(firstname, "First Name"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateIllegal(firstname, "First Name"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateEmpty(lastname, "Last Name"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateIllegal(lastname, "Last Name"); >>>>>>>> + } >>>>>>>> + if (adminPassword.value != null && adminPassword.value != >>>>>>>> "") { >>>>>>>> + if (adminPassword.value != adminPasswordRepeat.value) { >>>>>>>> + reason += jsi18n["password.mismatched"]; >>>>>>>> + } >>>>>>>> + } >>>>>>>> + } >>>>>>>> + else { >>>>>>>> var domain = document.getElementById('domain'); >>>>>>>> var adminName = document.getElementById('admin'); >>>>>>>> if (reason == "") { >>>>>>>> @@ -19,50 +37,52 @@ >>>>>>>> reason += validateDomain(domain); >>>>>>>> } >>>>>>>> if (reason == "") { >>>>>>>> - reason += validateEmpty(adminName, "AdminName"); >>>>>>>> + reason += checkDomain(domain); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateEmpty(firstname, "First Name"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateIllegal(firstname, "First Name"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateEmpty(lastname, "Last Name"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateIllegal(lastname, "Last Name"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateEmpty(adminName, "Admin Name"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateIllegal(adminName, "Admin Name"); >>>>>>>> } >>>>>>>> if (reason == "") { >>>>>>>> reason += validateUsername(adminName); >>>>>>>> } >>>>>>>> - } >>>>>>>> - >>>>>>>> - if (reason == "") { >>>>>>>> - reason += validateEmpty(firstname, "First Name"); >>>>>>>> - } >>>>>>>> - if (reason == "") { >>>>>>>> - reason += validateIllegal(firstname, "First Name"); >>>>>>>> - } >>>>>>>> - if (reason == "") { >>>>>>>> - reason += validateEmpty(lastname, "Last Name"); >>>>>>>> - } >>>>>>>> - if (reason == "") { >>>>>>>> - reason += validateIllegal(lastname, "Last Name"); >>>>>>>> - } >>>>>>>> - if (reason == "") { >>>>>>>> - reason += validateIllegal(adminName, "AdminName"); >>>>>>>> - } >>>>>>>> - if (reason == "") { >>>>>>>> - reason += validateEmpty(adminPassword, "AdminPassword"); >>>>>>>> - } >>>>>>>> - if (reason == "") { >>>>>>>> - reason += validatePassword(adminPassword); >>>>>>>> - } >>>>>>>> - if (reason == "") { >>>>>>>> - reason += validateEmpty(adminPasswordRepeat, >>>>>>>> "AdminPasswordRepeat"); >>>>>>>> - } >>>>>>>> - if (reason == "") { >>>>>>>> - reason += validateEmpty(email, "Mail"); >>>>>>>> - } >>>>>>>> - if (reason == "") { >>>>>>>> - reason += validateEmail(email); >>>>>>>> - } >>>>>>>> - >>>>>>>> - if (reason == "") { >>>>>>>> - if (adminPassword.value != adminPasswordRepeat.value) { >>>>>>>> - reason += jsi18n["password.mismatched"]; >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateEmpty(adminPassword, >>>>>>>> "AdminPassword"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validatePassword(adminPassword); >>>>>>>> } >>>>>>>> - if (adminPassword.value.length < 6) { >>>>>>>> - reason += jsi18n["password.length"]; >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateEmpty(adminPasswordRepeat, >>>>>>>> "AdminPasswordRepeat"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateEmpty(email, "Email"); >>>>>>>> + } >>>>>>>> + if (reason == "") { >>>>>>>> + reason += validateEmail(email); >>>>>>>> + } >>>>>>>> + >>>>>>>> + if (reason == "") { >>>>>>>> + if (adminPassword.value != adminPasswordRepeat.value) { >>>>>>>> + reason += jsi18n["password.mismatched"]; >>>>>>>> + } >>>>>>>> + if (adminPassword.value.length < 6) { >>>>>>>> + reason += jsi18n["password.length"]; >>>>>>>> + } >>>>>>>> } >>>>>>>> } >>>>>>>> if (reason != "") { >>>>>>>> @@ -75,10 +95,12 @@ >>>>>>>> function showsuccessregistermessage() { >>>>>>>> >>>>>>> >>>>>>> you should have proper camel casing in Javascript too. >>>>>>> >>>>>>> >>>>>>>> var message = "You have registered the Organization >>>>>>>> Successfully"; >>>>>>>> CARBON.showInfoDialog(message); >>>>>>>> + return; >>>>>>>> } >>>>>>>> function showsuccessupdatemessage() { >>>>>>>> var message = "Your changes saved Successfully!"; >>>>>>>> CARBON.showInfoDialog(message); >>>>>>>> + return; >>>>>>>> } >>>>>>>> function activationChanged(cbox, domain) { >>>>>>>> if (!cbox.checked) { >>>>>>>> @@ -129,4 +151,52 @@ >>>>>>>> } >>>>>>>> >>>>>>>> return error; >>>>>>>> +} >>>>>>>> + >>>>>>>> +function checkDomain(nname) { >>>>>>>> + >>>>>>>> + var error = ""; >>>>>>>> + var mai = nname.value; >>>>>>>> + >>>>>>>> + var val = true; >>>>>>>> + var dot = mai.lastIndexOf("."); >>>>>>>> + var dname = mai.substring(0, dot); >>>>>>>> + var ext = mai.substring(dot, mai.length); >>>>>>>> + >>>>>>>> + if (ext.indexOf("-trial") >= 0 || ext.indexOf("-unverified") >= >>>>>>>> 0) { >>>>>>>> + // we are not allowing to create a domain with -trial or >>>>>>>> -unverified is in the extension >>>>>>>> + return "The domain name you entered is not valid. Please >>>>>>>> enter a valid domain name."; >>>>>>>> + } >>>>>>>> + >>>>>>>> + if (ext.indexOf("/") >= 0 || ext.indexOf("\\") >= 0) { >>>>>>>> + return "The '/' and '\\' is not allowed in a domain name"; >>>>>>>> + } >>>>>>>> + >>>>>>>> + if (dot > 0 && dot < 57) { >>>>>>>> >>>>>>> >>>>>>> What is this 57? >>>>>>> >>>>>>> >>>>>>>> + if (!val) { >>>>>>>> + error = "Your domain extension " + ext + " is not >>>>>>>> correct"; >>>>>>>> + return error; >>>>>>>> + } >>>>>>>> + else { >>>>>>>> + for (var j = 0; j < dname.length; j++) { >>>>>>>> + var dh = dname.charAt(j); >>>>>>>> + var hh = dh.charCodeAt(0); >>>>>>>> + if ((hh > 47 && hh < 59) || (hh > 64 && hh < 91) || >>>>>>>> (hh > 96 && hh < 123) || >>>>>>>> + hh == 45 || hh == 46) { >>>>>>>> + if ((j == 0 || j == dname.length - 1) && hh == >>>>>>>> 45) { >>>>>>>> >>>>>>> >>>>>>> What are all these magic numbers? >>>>>>> >>>>>>> >>>>>>>> + error = "Domain name should not begin and >>>>>>>> end with '-'"; >>>>>>>> + return error; >>>>>>>> + } >>>>>>>> + } else { >>>>>>>> + error = "Your domain name should not have >>>>>>>> special characters"; >>>>>>>> + return error; >>>>>>>> + } >>>>>>>> + } >>>>>>>> + } >>>>>>>> + } >>>>>>>> + else { >>>>>>>> + error = "Your Domain name is too short/long or you should >>>>>>>> have an extension to your domain."; >>>>>>>> + return error; >>>>>>>> + } >>>>>>>> + return error; >>>>>>>> } >>>>>>>> \ No newline at end of file >>>>>>>> _______________________________________________ >>>>>>>> Carbon-commits mailing list >>>>>>>> [email protected] >>>>>>>> https://wso2.org/cgi-bin/mailman/listinfo/carbon-commits >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> *Afkham Azeez* >>>>>>> Senior Software Architect & Senior Manager; WSO2, Inc.; >>>>>>> http://wso2.com, >>>>>>> * >>>>>>> * >>>>>>> *Member; Apache Software Foundation; >>>>>>> **http://www.apache.org/*<http://www.apache.org/> >>>>>>> * >>>>>>> email: **[email protected]* <[email protected]>* cell: +94 77 3320919 >>>>>>> blog: **http://blog.afkham.org* <http://blog.afkham.org>* >>>>>>> twitter: >>>>>>> **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> >>>>>>> * >>>>>>> linked-in: **http://lk.linkedin.com/in/afkhamazeez* >>>>>>> * >>>>>>> * >>>>>>> *Lean . Enterprise . Middleware* >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> *Afkham Azeez* >>>>>> Senior Software Architect & Senior Manager; WSO2, Inc.; >>>>>> http://wso2.com, >>>>>> * >>>>>> * >>>>>> *Member; Apache Software Foundation; >>>>>> **http://www.apache.org/*<http://www.apache.org/> >>>>>> * >>>>>> email: **[email protected]* <[email protected]>* cell: +94 77 3320919 >>>>>> blog: **http://blog.afkham.org* <http://blog.afkham.org>* >>>>>> twitter: >>>>>> **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> >>>>>> * >>>>>> linked-in: **http://lk.linkedin.com/in/afkhamazeez* >>>>>> * >>>>>> * >>>>>> *Lean . Enterprise . Middleware* >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Kathiravelu Pradeeban. >>>>> Software Engineer. >>>>> WSO2 Inc. >>>>> >>>>> Blog: [Llovizna] http://kkpradeeban.blogspot.com/ >>>>> >>>>> >>>> >>>> >>>> -- >>>> Kathiravelu Pradeeban. >>>> Software Engineer. >>>> WSO2 Inc. >>>> >>>> Blog: [Llovizna] http://kkpradeeban.blogspot.com/ >>>> >>>> >>> >>> >>> -- >>> *Afkham Azeez* >>> Senior Software Architect & Senior Manager; WSO2, Inc.; http://wso2.com >>> , >>> * >>> * >>> *Member; Apache Software Foundation; >>> **http://www.apache.org/*<http://www.apache.org/> >>> * >>> email: **[email protected]* <[email protected]>* cell: +94 77 3320919 >>> blog: **http://blog.afkham.org* <http://blog.afkham.org>* >>> twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> >>> * >>> linked-in: **http://lk.linkedin.com/in/afkhamazeez* >>> * >>> * >>> *Lean . Enterprise . Middleware* >>> >>> >>> _______________________________________________ >>> Carbon-commits mailing list >>> [email protected] >>> https://wso2.org/cgi-bin/mailman/listinfo/carbon-commits >>> >>> >> >> >> -- >> Thilina Buddhika >> Senior Software Engineer >> >> WSO2 Inc. ; http://wso2.com >> lean . enterprise . middleware >> >> phone : +94 77 44 88 727 >> blog : http://blog.thilinamb.com >> > > > > -- > Kathiravelu Pradeeban. > Software Engineer. > WSO2 Inc. > > Blog: [Llovizna] http://kkpradeeban.blogspot.com/ > > -- Thilina Buddhika Senior Software Engineer WSO2 Inc. ; http://wso2.com lean . enterprise . middleware phone : +94 77 44 88 727 blog : http://blog.thilinamb.com
_______________________________________________ Carbon-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev
