Author: jonesde
Date: Mon Mar 15 08:58:46 2010 New Revision: 923117 URL: http://svn.apache.org/viewvc?rev=923117&view=rev Log: Commented out the TenantUserLogin entity and related code for now; the authentication within a tenant makes more sense and avoids redundancy; also added a disabled flag on the Tenant entity and code in the GenericDelegator to test it Modified: ofbiz/branches/multitenant20100310/framework/entity/data/TenantDemoData.xml ofbiz/branches/multitenant20100310/framework/entity/entitydef/entitymodel.xml ofbiz/branches/multitenant20100310/framework/entity/src/org/ofbiz/entity/GenericDelegator.java ofbiz/branches/multitenant20100310/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Modified: ofbiz/branches/multitenant20100310/framework/entity/data/TenantDemoData.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/entity/data/TenantDemoData.xml?rev=923117&r1=923116&r2=923117&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/entity/data/TenantDemoData.xml (original) +++ ofbiz/branches/multitenant20100310/framework/entity/data/TenantDemoData.xml Mon Mar 15 08:58:46 2010 @@ -27,12 +27,12 @@ under the License. <TenantDataSource tenantId="DEMO1" entityGroupName="org.ofbiz.olap" jdbcUri="jdbc:derby:ofbizolap_DEMO1;create=true" jdbcUsername="ofbiz" jdbcPassword="ofbiz"/> <!-- the org.ofbiz.tenant URI should be the same for ALL tenants, so don't create a TenantDataSource record for it, it will be ignored anyway --> - <TenantUserLogin tenantId="DEMO1" userLoginId="admin" fromDate="2001-05-13 00:00:00.000" thruDate="" isManager="Y"/> + <!-- See comments on entity def: <TenantUserLogin tenantId="DEMO1" userLoginId="admin" fromDate="2001-05-13 00:00:00.000" thruDate="" isManager="Y"/> --> <Tenant tenantId="DEMO2" tenantName="Demo Tenant Two"/> <TenantDataSource tenantId="DEMO2" entityGroupName="org.ofbiz" jdbcUri="jdbc:derby:ofbiz_DEMO2;create=true" jdbcUsername="ofbiz" jdbcPassword="ofbiz"/> <TenantDataSource tenantId="DEMO2" entityGroupName="org.ofbiz.olap" jdbcUri="jdbc:derby:ofbizolap_DEMO2;create=true" jdbcUsername="ofbiz" jdbcPassword="ofbiz"/> - <TenantUserLogin tenantId="DEMO2" userLoginId="admin" fromDate="2001-05-13 00:00:00.000" thruDate="" isManager="N"/> + <!-- See comments on entity def: <TenantUserLogin tenantId="DEMO2" userLoginId="admin" fromDate="2001-05-13 00:00:00.000" thruDate="" isManager="N"/> --> </entity-engine-xml> Modified: ofbiz/branches/multitenant20100310/framework/entity/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/entity/entitydef/entitymodel.xml?rev=923117&r1=923116&r2=923117&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/entity/entitydef/entitymodel.xml (original) +++ ofbiz/branches/multitenant20100310/framework/entity/entitydef/entitymodel.xml Mon Mar 15 08:58:46 2010 @@ -35,7 +35,7 @@ under the License. <!-- - org.ofbiz.entity.audit --> <!-- - org.ofbiz.entity.crypto --> <!-- - org.ofbiz.entity.sequence --> - <!-- org.ofbiz.entity.tenant --> + <!-- - org.ofbiz.entity.tenant --> <!-- ========================================================= --> <entity entity-name="EntityAuditLog" package-name="org.ofbiz.entity.audit" title="Entity Audit Log"> @@ -68,6 +68,7 @@ under the License. <entity entity-name="Tenant" package-name="org.ofbiz.entity.tenant"> <field name="tenantId" type="id-ne"/> <field name="tenantName" type="name"/> + <field name="disabled" type="indicator"><description>Disabled if 'Y', defaults to 'N' (not disabled).</description></field> <prim-key field="tenantId"/> </entity> <entity entity-name="TenantDataSource" package-name="org.ofbiz.entity.tenant"> @@ -86,18 +87,20 @@ under the License. <key-map field-name="tenantId"/> </relation> </entity> + <!-- may be no reason for this entity, user is authenticated inside the tenant and this would only be useful to + get a list of tenants per user <entity entity-name="TenantUserLogin" package-name="org.ofbiz.entity.tenant"> <field name="tenantId" type="id-ne"/> <field name="userLoginId" type="name"/> <field name="fromDate" type="date-time"/> <field name="thruDate" type="date-time"/> - <field name="isManager" type="indicator"/> <prim-key field="tenantId"/> <prim-key field="userLoginId"/> <prim-key field="fromDate"/> <relation type="one" fk-name="TNTUSRLGN_TNT" rel-entity-name="Tenant"> <key-map field-name="tenantId"/> </relation> - <!-- NOTE: there is no FK to the UserLogin entity, which is in a higher-level component, and would normally be in a separate database --> + <!- - NOTE: there is no FK to the UserLogin entity, which is in a higher-level component, and would normally be in a separate database - -> </entity> + --> </entitymodel> Modified: ofbiz/branches/multitenant20100310/framework/entity/src/org/ofbiz/entity/GenericDelegator.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=923117&r1=923116&r2=923117&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original) +++ ofbiz/branches/multitenant20100310/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Mon Mar 15 08:58:46 2010 @@ -231,6 +231,8 @@ public class GenericDelegator implements GenericValue tenant = baseDelegator.findOne("Tenant", true, "tenantId", this.delegatorTenantId); if (tenant == null) { throw new GenericEntityException("No Tenant record found for delegator [" + this.delegatorFullName + "] with tenantId [" + this.delegatorTenantId + "]"); + } else if ("Y".equals(tenant.getString("disabled"))) { + throw new GenericEntityException("No Tenant record found for delegator [" + this.delegatorFullName + "] with tenantId [" + this.delegatorTenantId + "]"); } } Modified: ofbiz/branches/multitenant20100310/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?rev=923117&r1=923116&r2=923117&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original) +++ ofbiz/branches/multitenant20100310/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Mon Mar 15 08:58:46 2010 @@ -337,6 +337,8 @@ public class LoginWorker { } if (delegatorNameHashIndex == -1 || (currentDelegatorTenantId != null && !tenantId.equals(currentDelegatorTenantId))) { + /* don't require this, allow a user to authenticate inside the tenant as long as the userLoginId and + * password match what is in that tenant's database; instead just set things up below try { List<GenericValue> tenantUserLoginList = delegator.findList("TenantUserLogin", EntityCondition.makeCondition(EntityOperator.AND, "tenantId", tenantId, "userLoginId", username), null, null, null, false); if (tenantUserLoginList != null && tenantUserLoginList.size() > 0) { @@ -363,6 +365,19 @@ public class LoginWorker { request.setAttribute("_ERROR_MESSAGE_", errMsg); return "error"; } + */ + + ServletContext servletContext = session.getServletContext(); + + // make that tenant active, setup a new delegator and a new dispatcher + String delegatorName = delegator.getDelegatorName() + "#" + tenantId; + + // after this line the delegator is replaced with the new per-tenant delegator + delegator = DelegatorFactory.getDelegator(delegatorName); + dispatcher = ContextFilter.makeWebappDispatcher(servletContext, delegator); + + // NOTE: these will be local for now and set in the request and session later, after we've verified that the user + setupNewDelegatorEtc = true; } } |
Free forum by Nabble | Edit this page |