svn commit: r498789 - in /ofbiz/trunk/framework/common: config/CommonUiLabels.properties script/org/ofbiz/common/permission/ script/org/ofbiz/common/permission/CommonPermissionServices.xml servicedef/services.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r498789 - in /ofbiz/trunk/framework/common: config/CommonUiLabels.properties script/org/ofbiz/common/permission/ script/org/ofbiz/common/permission/CommonPermissionServices.xml servicedef/services.xml

jaz-3
Author: jaz
Date: Mon Jan 22 12:37:39 2007
New Revision: 498789

URL: http://svn.apache.org/viewvc?view=rev&rev=498789
Log:
implemented base set permission service - from Anil Patel & Co.

Added:
    ofbiz/trunk/framework/common/script/org/ofbiz/common/permission/
    ofbiz/trunk/framework/common/script/org/ofbiz/common/permission/CommonPermissionServices.xml   (with props)
Modified:
    ofbiz/trunk/framework/common/config/CommonUiLabels.properties
    ofbiz/trunk/framework/common/servicedef/services.xml

Modified: ofbiz/trunk/framework/common/config/CommonUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/CommonUiLabels.properties?view=diff&rev=498789&r1=498788&r2=498789
==============================================================================
--- ofbiz/trunk/framework/common/config/CommonUiLabels.properties (original)
+++ ofbiz/trunk/framework/common/config/CommonUiLabels.properties Mon Jan 22 12:37:39 2007
@@ -282,6 +282,8 @@
 CommonPerform=Perform
 CommonPermissionErrorMessage=Security Error\: to run ${resourceDescription} you must have the EXAMPLE_${mainAction} or EXAMPLE_ADMIN permission
 CommonPermissionError=Permission Error
+CommonPermissionMainActionAttributeMissing=Permission main-action attribute missing
+CommonGenericPermissionError=Security Error\: To run ${resourceDescription} you must have the ${}_${mainAction} or ${}_ADMIN permission
 CommonPerson=Person
 CommonPostedBy=Posted By
 CommonPostedDate=Posted Date

Added: ofbiz/trunk/framework/common/script/org/ofbiz/common/permission/CommonPermissionServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/permission/CommonPermissionServices.xml?view=auto&rev=498789
==============================================================================
--- ofbiz/trunk/framework/common/script/org/ofbiz/common/permission/CommonPermissionServices.xml (added)
+++ ofbiz/trunk/framework/common/script/org/ofbiz/common/permission/CommonPermissionServices.xml Mon Jan 22 12:37:39 2007
@@ -0,0 +1,48 @@
+<!--
+  ~ Copyright 2001-2007 The Apache Software Foundation
+  ~
+  ~ Licensed 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.
+  -->
+
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
+
+    <simple-method method-name="genericBasePermissionCheck" short-description="Basic Permission check">
+        <!-- This method should be put in common place so it can be called from anyware in ofbiz -->
+        <set field="mainAction" from-field="parameters.mainAction"/>
+        <if-empty field-name="mainAction">
+            <add-error><fail-property resource="CommonUiLabels" property="CommonPermissionMainActionAttributeMissing"/></add-error>
+        </if-empty>
+        <log level="verbose" message="Checking for ${primaryPermission}_${mainAction}"/>
+        <log level="verbose" message="Checking for ${altPermission}_${mainAction}"/>
+        <check-errors/>
+        <if>
+            <condition>
+                <or>
+                    <if-has-permission permission="${primaryPermission}" action="_${parameters.mainAction}"/>
+                    <if-has-permission permission="${altPermission}" action="_${parameters.mainAction}"/>
+                </or>
+            </condition>
+            <then>
+                <set field="hasPermission" type="Boolean" value="true"/>
+                <field-to-result field-name="hasPermission"/>
+            </then>
+            <else>
+                <property-to-field resource="CommonUiLabels" property="CommonGenericPermissionError" field-name="failMessage"/>
+                <set field="hasPermission" type="Boolean" value="false"/>
+                <field-to-result field-name="hasPermission"/>
+                <field-to-result field-name="failMessage"/>
+            </else>
+        </if>
+    </simple-method>
+</simple-methods>

Propchange: ofbiz/trunk/framework/common/script/org/ofbiz/common/permission/CommonPermissionServices.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/common/script/org/ofbiz/common/permission/CommonPermissionServices.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/framework/common/script/org/ofbiz/common/permission/CommonPermissionServices.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/framework/common/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services.xml?view=diff&rev=498789&r1=498788&r2=498789
==============================================================================
--- ofbiz/trunk/framework/common/servicedef/services.xml (original)
+++ ofbiz/trunk/framework/common/servicedef/services.xml Mon Jan 22 12:37:39 2007
@@ -388,4 +388,10 @@
         <attribute name="disabledDateTime" type="java.sql.Timestamp" mode="IN" optional="true"/>
         <attribute name="successiveFailedLogins" type="Long" mode="IN" optional="true"/>
     </service>
+
+    <!-- common permission services -->
+    <service name="genericBasePermissionCheck" engine="simple"
+             location="org/ofbiz/common/permission/CommonPermissionServices.xml" invoke="genericBasePermissionCheck">
+        <implements service="permissionInterface"/>
+    </service>
 </services>