|
Author: adrianc
Date: Sun Apr 4 17:12:53 2010 New Revision: 930719 URL: http://svn.apache.org/viewvc?rev=930719&view=rev Log: Moved the framework/api classes to framework/base. Removed the framework/api component. Added: ofbiz/branches/executioncontext20091231/framework/base/config/api.properties (with props) ofbiz/branches/executioncontext20091231/framework/base/config/freemarkerTransforms.properties (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AccessController.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AdminPermission.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManager.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManagerException.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermission.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermissions.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/NullAuthorizationManager.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/OfbizSecurityTransform.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsIntersection.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsSet.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsUnion.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/AbstractExecutionContext.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ArtifactPath.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ExecutionArtifact.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ExecutionContext.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ExecutionContextFactory.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/GenericExecutionArtifact.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/GenericParametersArtifact.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ParametersArtifact.java (with props) ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ThreadContext.java (with props) Removed: ofbiz/branches/executioncontext20091231/framework/api/ Modified: ofbiz/branches/executioncontext20091231/BranchReadMe.txt ofbiz/branches/executioncontext20091231/applications/accounting/build.xml ofbiz/branches/executioncontext20091231/applications/content/build.xml ofbiz/branches/executioncontext20091231/applications/manufacturing/build.xml ofbiz/branches/executioncontext20091231/applications/marketing/build.xml ofbiz/branches/executioncontext20091231/applications/order/build.xml ofbiz/branches/executioncontext20091231/applications/party/build.xml ofbiz/branches/executioncontext20091231/applications/product/build.xml ofbiz/branches/executioncontext20091231/applications/workeffort/build.xml ofbiz/branches/executioncontext20091231/framework/bi/build.xml ofbiz/branches/executioncontext20091231/framework/build.xml ofbiz/branches/executioncontext20091231/framework/common/build.xml ofbiz/branches/executioncontext20091231/framework/component-load.xml ofbiz/branches/executioncontext20091231/framework/context/build.xml ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessDeniedController.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessGrantedController.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AuditedArtifactFinder.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/ContextUtil.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/PathNode.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/PermissionTreeBuilder.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/PermissionsGatherer.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/TreeBuilder.java ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/TreeWalker.java ofbiz/branches/executioncontext20091231/framework/entity/build.xml ofbiz/branches/executioncontext20091231/framework/entity/src/org/ofbiz/entity/ExecutionContext.java ofbiz/branches/executioncontext20091231/framework/entity/src/org/ofbiz/entity/GenericDelegator.java ofbiz/branches/executioncontext20091231/framework/entity/src/org/ofbiz/entity/GenericEntity.java ofbiz/branches/executioncontext20091231/framework/entity/src/org/ofbiz/entity/ThreadContext.java ofbiz/branches/executioncontext20091231/framework/entity/src/org/ofbiz/entity/model/ModelEntity.java ofbiz/branches/executioncontext20091231/framework/entityext/build.xml ofbiz/branches/executioncontext20091231/framework/minilang/build.xml ofbiz/branches/executioncontext20091231/framework/security/build.xml ofbiz/branches/executioncontext20091231/framework/service/build.xml ofbiz/branches/executioncontext20091231/framework/service/src/org/ofbiz/service/ModelService.java ofbiz/branches/executioncontext20091231/framework/service/src/org/ofbiz/service/ServiceDispatcher.java ofbiz/branches/executioncontext20091231/framework/webapp/build.xml ofbiz/branches/executioncontext20091231/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java ofbiz/branches/executioncontext20091231/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java ofbiz/branches/executioncontext20091231/framework/webtools/build.xml ofbiz/branches/executioncontext20091231/framework/widget/build.xml ofbiz/branches/executioncontext20091231/framework/widget/src/org/ofbiz/widget/form/ModelForm.java ofbiz/branches/executioncontext20091231/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java ofbiz/branches/executioncontext20091231/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java ofbiz/branches/executioncontext20091231/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java ofbiz/branches/executioncontext20091231/specialpurpose/ebay/build.xml ofbiz/branches/executioncontext20091231/specialpurpose/googlebase/build.xml ofbiz/branches/executioncontext20091231/specialpurpose/googlecheckout/build.xml ofbiz/branches/executioncontext20091231/specialpurpose/hhfacility/build.xml ofbiz/branches/executioncontext20091231/specialpurpose/oagis/build.xml ofbiz/branches/executioncontext20091231/specialpurpose/pos/build.xml ofbiz/branches/executioncontext20091231/specialpurpose/webpos/build.xml Modified: ofbiz/branches/executioncontext20091231/BranchReadMe.txt URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/BranchReadMe.txt?rev=930719&r1=930718&r2=930719&view=diff ============================================================================== --- ofbiz/branches/executioncontext20091231/BranchReadMe.txt (original) +++ ofbiz/branches/executioncontext20091231/BranchReadMe.txt Sun Apr 4 17:12:53 2010 @@ -90,7 +90,7 @@ the interface and add their methods. It' This is where you can find the interfaces: -org.ofbiz.api.context.ExecutionContext +org.ofbiz.base.context.ExecutionContext org.ofbiz.entity.ExecutionContext org.ofbiz.service.ExecutionContext Modified: ofbiz/branches/executioncontext20091231/applications/accounting/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/applications/accounting/build.xml?rev=930719&r1=930718&r2=930719&view=diff ============================================================================== --- ofbiz/branches/executioncontext20091231/applications/accounting/build.xml (original) +++ ofbiz/branches/executioncontext20091231/applications/accounting/build.xml Sun Apr 4 17:12:53 2010 @@ -30,7 +30,6 @@ under the License. <property name="ofbiz.home.dir" value="../.."/> <path id="local.class.path"> - <fileset dir="../../framework/api/build/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib/commons" includes="*.jar"/> <fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/> Modified: ofbiz/branches/executioncontext20091231/applications/content/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/applications/content/build.xml?rev=930719&r1=930718&r2=930719&view=diff ============================================================================== --- ofbiz/branches/executioncontext20091231/applications/content/build.xml (original) +++ ofbiz/branches/executioncontext20091231/applications/content/build.xml Sun Apr 4 17:12:53 2010 @@ -32,7 +32,6 @@ under the License. <path id="local.class.path"> <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="${lib.dir}/uno" includes="*.jar"/> - <fileset dir="../../framework/api/build/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib/commons" includes="*.jar"/> <fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/> Modified: ofbiz/branches/executioncontext20091231/applications/manufacturing/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/applications/manufacturing/build.xml?rev=930719&r1=930718&r2=930719&view=diff ============================================================================== --- ofbiz/branches/executioncontext20091231/applications/manufacturing/build.xml (original) +++ ofbiz/branches/executioncontext20091231/applications/manufacturing/build.xml Sun Apr 4 17:12:53 2010 @@ -31,7 +31,6 @@ under the License. <path id="local.class.path"> <!-- <fileset dir="${lib.dir}" includes="*.jar"/> --> - <fileset dir="../../framework/api/build/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/> <fileset dir="../../framework/base/build/lib" includes="*.jar"/> Modified: ofbiz/branches/executioncontext20091231/applications/marketing/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/applications/marketing/build.xml?rev=930719&r1=930718&r2=930719&view=diff ============================================================================== --- ofbiz/branches/executioncontext20091231/applications/marketing/build.xml (original) +++ ofbiz/branches/executioncontext20091231/applications/marketing/build.xml Sun Apr 4 17:12:53 2010 @@ -30,7 +30,6 @@ under the License. <property name="ofbiz.home.dir" value="../.."/> <path id="local.class.path"> - <fileset dir="../../framework/api/build/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/> <fileset dir="../../framework/base/build/lib" includes="*.jar"/> Modified: ofbiz/branches/executioncontext20091231/applications/order/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/applications/order/build.xml?rev=930719&r1=930718&r2=930719&view=diff ============================================================================== --- ofbiz/branches/executioncontext20091231/applications/order/build.xml (original) +++ ofbiz/branches/executioncontext20091231/applications/order/build.xml Sun Apr 4 17:12:53 2010 @@ -31,7 +31,6 @@ under the License. <path id="local.class.path"> <!--<fileset dir="${lib.dir}" includes="*.jar"/>--> - <fileset dir="../../framework/api/build/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib/commons" includes="*.jar"/> <fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/> Modified: ofbiz/branches/executioncontext20091231/applications/party/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/applications/party/build.xml?rev=930719&r1=930718&r2=930719&view=diff ============================================================================== --- ofbiz/branches/executioncontext20091231/applications/party/build.xml (original) +++ ofbiz/branches/executioncontext20091231/applications/party/build.xml Sun Apr 4 17:12:53 2010 @@ -31,7 +31,6 @@ under the License. <path id="local.class.path"> <!--<fileset dir="${lib.dir}" includes="*.jar"/>--> - <fileset dir="../../framework/api/build/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/> <fileset dir="../../framework/base/build/lib" includes="*.jar"/> Modified: ofbiz/branches/executioncontext20091231/applications/product/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/applications/product/build.xml?rev=930719&r1=930718&r2=930719&view=diff ============================================================================== --- ofbiz/branches/executioncontext20091231/applications/product/build.xml (original) +++ ofbiz/branches/executioncontext20091231/applications/product/build.xml Sun Apr 4 17:12:53 2010 @@ -31,7 +31,6 @@ under the License. <path id="local.class.path"> <!--<fileset dir="${lib.dir}" includes="*.jar"/>--> - <fileset dir="../../framework/api/build/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib/commons" includes="*.jar"/> <fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/> Modified: ofbiz/branches/executioncontext20091231/applications/workeffort/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/applications/workeffort/build.xml?rev=930719&r1=930718&r2=930719&view=diff ============================================================================== --- ofbiz/branches/executioncontext20091231/applications/workeffort/build.xml (original) +++ ofbiz/branches/executioncontext20091231/applications/workeffort/build.xml Sun Apr 4 17:12:53 2010 @@ -31,7 +31,6 @@ under the License. <path id="local.class.path"> <!--<fileset dir="${lib.dir}" includes="*.jar"/>--> - <fileset dir="../../framework/api/build/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib" includes="*.jar"/> <fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/> <fileset dir="../../framework/base/lib/scripting" includes="*.jar"/> Added: ofbiz/branches/executioncontext20091231/framework/base/config/api.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/config/api.properties?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/config/api.properties (added) +++ ofbiz/branches/executioncontext20091231/framework/base/config/api.properties Sun Apr 4 17:12:53 2010 @@ -0,0 +1,44 @@ +############################################################################### +# 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. +############################################################################### + +#### +# Apache OFBiz Framework API Settings +#### + +# Class name of the ExecutionContext implementation. +executionContext.class=org.ofbiz.context.ExecutionContextImpl + +# Class name of the AuthorizationManager implementation. +authorizationManager.class=org.ofbiz.context.AuthorizationManagerImpl + +# Enable security auditing. +securityAudit.enabled=false + +#-- The following properties are for development only, they will be removed +#-- when the security-aware artifact implementation is complete. + +# Set to true to enable ExecutionContext info messages. +executionContext.verbose=false + +# Set to true to enable AuthorizationManager info messages. +authorizationManager.verbose=false + +# Set to true to disable the AuthorizationManager. +authorizationManager.disabled=false + Propchange: ofbiz/branches/executioncontext20091231/framework/base/config/api.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/config/api.properties ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/config/api.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/config/freemarkerTransforms.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/config/freemarkerTransforms.properties?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/config/freemarkerTransforms.properties (added) +++ ofbiz/branches/executioncontext20091231/framework/base/config/freemarkerTransforms.properties Sun Apr 4 17:12:53 2010 @@ -0,0 +1,24 @@ +############################################################################### +# 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. +############################################################################### +### FreeMarker transforms ### +############################# + +# entries are in the form: key=transform name, property=transform class name + +ofbizSecurity=org.ofbiz.base.authorization.OfbizSecurityTransform Propchange: ofbiz/branches/executioncontext20091231/framework/base/config/freemarkerTransforms.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/config/freemarkerTransforms.properties ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/config/freemarkerTransforms.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AccessController.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AccessController.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AccessController.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AccessController.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,82 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + +import java.security.AccessControlException; +import java.security.Permission; +import java.util.List; +import java.util.ListIterator; + +import org.ofbiz.base.context.ArtifactPath; + +/** AccessController interface. This interface is intended to + * separate the permissions-checking logic from the artifacts + * that use it. + */ +public interface AccessController { + + /** Returns silently if the user has been granted <code>permission</code> + * access for the current artifact, throws <code>AccessControlException</code> + * otherwise.<p>Security-aware artifacts call this + * method with the desired permission. If access is granted the + * method returns, otherwise it throws an unchecked exception. + * Higher level code can catch the exception and handle it accordingly.</p> + * + * @param permission The permission to check + * @throws AccessControlException + */ + void checkPermission(Permission permission) throws AccessControlException; + + /** Returns silently if the user has been granted <code>permission</code> + * access for the specified artifact, throws <code>AccessControlException</code> + * otherwise.<p>Client code can call this method when an artifact other + * than the current one needs to be checked. If access is granted the + * method returns, otherwise it throws an unchecked exception. + * Higher level code can catch the exception and handle it accordingly.</p> + * + * @param permission The permission to check + * @throws AccessControlException + */ + void checkPermission(Permission permission, ArtifactPath artifactPath) throws AccessControlException; + + /** Applies permission filters to a <code>List</code>. The + * returned <code>List</code> is security-aware, so methods + * that return an <code>Object</code> will return only the + * objects the user has permission to access. + * + * @param list The <code>List</code> to apply filters to + * @return A security-aware <code>List</code> if filters + * were specified for the current artifact, or the original + * <code>List</code> otherwise + */ + <E> List<E> applyFilters(List<E> list); + + /** Applies permission filters to a <code>ListIterator</code>. The + * returned <code>ListIterator</code> is security-aware, so methods + * that return an <code>Object</code> will return only the + * objects the user has permission to access. + * + * @param list The <code>ListIterator</code> to apply filters to + * @return A security-aware <code>ListIterator</code> if filters + * were specified for the current artifact, or the original + * <code>ListIterator</code> otherwise + */ + <E> ListIterator<E> applyFilters(ListIterator<E> list); + +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AccessController.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AccessController.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AccessController.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AdminPermission.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AdminPermission.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AdminPermission.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AdminPermission.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,68 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + +import java.security.Permission; + +/** + * Admin permission class. Extends BasicPermission. + */ +@SuppressWarnings("serial") +public class AdminPermission extends BasicPermission { + + public AdminPermission() { + super("admin=true"); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + try { + AdminPermission that = (AdminPermission) obj; + return this.permissionString.equals(that.permissionString); + } catch (ClassCastException e) {} + return false; + } + + @Override + public String getActions() { + return null; + } + + @Override + public int hashCode() { + return this.permissionString.hashCode(); + } + + /** Returns <code>true</code> - the admin permission has + * no restrictions. + * + */ + @Override + public boolean implies(Permission permission) { + return true; + } + + @Override + public String toString() { + return this.permissionString; + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AdminPermission.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AdminPermission.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AdminPermission.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManager.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManager.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManager.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManager.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + +import java.security.Permission; + +/** + * An object used for managing users, user groups, and permissions. + */ +public interface AuthorizationManager { + + void assignGroupPermission(String userGroupId, String artifactId, Permission permission) throws AuthorizationManagerException; + + void assignGroupToGroup(String childGroupId, String parentGroupId) throws AuthorizationManagerException; + + void assignUserPermission(String userLoginId, String artifactId, Permission permission) throws AuthorizationManagerException; + + void assignUserToGroup(String userLoginId, String userGroupId) throws AuthorizationManagerException; + + void createUser(String userLoginId, String password) throws AuthorizationManagerException; + + String createUserGroup(String description) throws AuthorizationManagerException; + + void deleteGroupFromGroup(String childGroupId, String parentGroupId) throws AuthorizationManagerException; + + void deleteGroupPermission(String userGroupId, String artifactId, Permission permission) throws AuthorizationManagerException; + + void deleteUser(String userLoginId) throws AuthorizationManagerException; + + void deleteUserFromGroup(String userLoginId, String userGroupId) throws AuthorizationManagerException; + + void deleteUserGroup(String userGroupId) throws AuthorizationManagerException; + + void deleteUserPermission(String userLoginId, String artifactId, Permission permission) throws AuthorizationManagerException; + + AccessController getAccessController() throws AuthorizationManagerException; + + void updateUser(String userLoginId, String password) throws AuthorizationManagerException; + + void updateUserGroup(String userGroupId, String description) throws AuthorizationManagerException; +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManager.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManager.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManager.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManagerException.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManagerException.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManagerException.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManagerException.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + + +/** + * AuthorizationManagerException class. + */ +@SuppressWarnings("serial") +public class AuthorizationManagerException extends Exception { + public AuthorizationManagerException() { + super(); + } + + public AuthorizationManagerException(String message) { + super(message); + } + + public AuthorizationManagerException(String message, Throwable cause) { + super(message, cause); + } + + public AuthorizationManagerException(Throwable cause) { + super(cause); + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManagerException.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManagerException.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/AuthorizationManagerException.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermission.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermission.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermission.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermission.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,85 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + +import java.security.Permission; + +/** + * Generic permission class. Similar to java.security.BasicPermission. + */ +@SuppressWarnings("serial") +public class BasicPermission extends Permission { + + protected final String permissionString; + + public BasicPermission(String permissionString) { + super(permissionString); + this.permissionString = permissionString; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + try { + BasicPermission that = (BasicPermission) obj; + return this.permissionString.equals(that.permissionString); + } catch (ClassCastException e) {} + return false; + } + + @Override + public String getActions() { + return null; + } + + @Override + public int hashCode() { + return this.permissionString.hashCode(); + } + + @Override + public boolean implies(Permission permission) { + try { + PermissionsUnion permissionsUnion = (PermissionsUnion) permission; + for (Permission perm : permissionsUnion.getPermissionsSet()) { + if (this.implies(perm)) { + return true; + } + } + return false; + } catch (Exception e) {} + try { + PermissionsIntersection permissionsIntersection = (PermissionsIntersection) permission; + for (Permission perm : permissionsIntersection.getPermissionsSet()) { + if (!this.implies(perm)) { + return false; + } + } + return true; + } catch (Exception e) {} + return this.equals(permission); + } + + @Override + public String toString() { + return this.permissionString; + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermission.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermission.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermission.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermissions.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermissions.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermissions.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermissions.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + +import java.security.Permission; +import java.util.Map; + +import javolution.util.FastMap; + +/** + * A collection of basic permissions. + */ +public class BasicPermissions { + + public static final Permission Access = new BasicPermission("access=true"); + public static final Permission Admin = new AdminPermission(); + public static final Permission Create = new BasicPermission("create=true"); + public static final Permission Delete = new BasicPermission("delete=true"); + public static final Permission Update = new BasicPermission("update=true"); + public static final Permission View = new BasicPermission("view=true"); + public static final Map<String, Permission> ConversionMap = createConversionMap(); + + protected static Map<String, Permission> createConversionMap() { + Map<String, Permission> conversionMap = FastMap.newInstance(); + conversionMap.put("ACCESS", Access); + conversionMap.put("ADMIN", Admin); + conversionMap.put("CREATE", Create); + conversionMap.put("DELETE", Delete); + conversionMap.put("UPDATE", Update); + conversionMap.put("VIEW", View); + return conversionMap; + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermissions.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermissions.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/BasicPermissions.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/NullAuthorizationManager.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/NullAuthorizationManager.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/NullAuthorizationManager.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/NullAuthorizationManager.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,80 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + +import java.security.AccessControlException; +import java.security.Permission; + +public class NullAuthorizationManager implements AuthorizationManager { + + public static final String module = NullAuthorizationManager.class.getName(); + + protected final AccessController accessController; + + public NullAuthorizationManager(AccessController accessController) { + this.accessController = accessController; + } + + public void assignGroupPermission(String userGroupId, String artifactId, Permission permission) { + } + + public void assignGroupToGroup(String childGroupId, String parentGroupId) { + } + + public void assignUserPermission(String userLoginId, String artifactId, Permission permission) { + } + + public void assignUserToGroup(String userLoginId, String userGroupId) { + } + + public void createUser(String userLoginId, String password) { + } + + public String createUserGroup(String description) { + return null; + } + + public void deleteGroupFromGroup(String childGroupId, String parentGroupId) { + } + + public void deleteGroupPermission(String userGroupId, String artifactId, Permission permission) { + } + + public void deleteUser(String userLoginId) { + } + + public void deleteUserFromGroup(String userLoginId, String userGroupId) { + } + + public void deleteUserGroup(String userGroupId) { + } + + public void deleteUserPermission(String userLoginId, String artifactId, Permission permission) { + } + + public void updateUser(String userLoginId, String password) { + } + + public void updateUserGroup(String userGroupId, String description) { + } + + public AccessController getAccessController() throws AccessControlException { + return this.accessController; + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/NullAuthorizationManager.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/NullAuthorizationManager.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/NullAuthorizationManager.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/OfbizSecurityTransform.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/OfbizSecurityTransform.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/OfbizSecurityTransform.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/OfbizSecurityTransform.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,92 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + +import java.io.IOException; +import java.security.AccessControlException; +import java.security.Permission; +import java.util.Map; + +import org.ofbiz.base.context.ThreadContext; +import org.ofbiz.base.util.Debug; + +import freemarker.core.Environment; +import freemarker.ext.beans.StringModel; +import freemarker.template.SimpleScalar; +import freemarker.template.TemplateDirectiveBody; +import freemarker.template.TemplateDirectiveModel; +import freemarker.template.TemplateException; +import freemarker.template.TemplateModel; + +/** + * OfbizSecurityTransform - Security-aware Freemarker transform. + */ +public class OfbizSecurityTransform implements TemplateDirectiveModel { + + public final static String module = OfbizSecurityTransform.class.getName(); + + @SuppressWarnings("unchecked") + public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { + if (body == null) { + return; + } + String artifactId = toString(params.get("artifactId")); + if (artifactId == null) { + Debug.logError("artifactId parameter not found, unable to execute transform", module); + return; + } + String permStr = toString(params.get("permission")); + if (permStr == null) { + Debug.logError("permission parameter not found, unable to execute transform", module); + return; + } + Permission permission = BasicPermissions.ConversionMap.get(permStr.toUpperCase()); + if (permission == null) { + Debug.logError("Unknown permission \"" + permStr + "\", unable to execute transform", module); + return; + } + ThreadContext.pushExecutionArtifact(module, artifactId); + try { + ThreadContext.getAccessController().checkPermission(permission); + body.render(env.getOut()); + } catch (AccessControlException e) { + } finally { + ThreadContext.popExecutionArtifact(); + } + } + + protected static String toString(Object freeMarkerObject) { + String result = null; + if (freeMarkerObject != null) { + try { + StringModel modelObj = (StringModel) freeMarkerObject; + result = modelObj.getAsString(); + } catch (ClassCastException e) { + try { + SimpleScalar scalarObj = (SimpleScalar) freeMarkerObject; + result = scalarObj.getAsString(); + } catch (Exception e2) {} + } + if (result != null) { + result = result.replace("/", ""); + } + } + return result; + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/OfbizSecurityTransform.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/OfbizSecurityTransform.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/OfbizSecurityTransform.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsIntersection.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsIntersection.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsIntersection.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsIntersection.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,73 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + +import java.security.Permission; +import java.util.Arrays; +import java.util.List; + +/** + * A <code>Set</code> of permissions that represents an intersection. + */ +@SuppressWarnings("serial") +public class PermissionsIntersection extends PermissionsSet { + + public PermissionsIntersection(String listName) { + super(listName); + } + + public PermissionsIntersection(String listName, List<Permission> permissionsList) { + super(listName, permissionsList); + } + + public PermissionsIntersection(String listName, Permission... permissions) { + super(listName, Arrays.asList(permissions)); + } + + /** Returns <code>true</code> if all of the contained permissions + * return <code>true</code>. + */ + @Override + public boolean implies(Permission permission) { + try { + PermissionsUnion permissionsUnion = (PermissionsUnion) permission; + for (Permission perm : permissionsUnion.getPermissionsSet()) { + if (this.implies(perm)) { + return true; + } + } + return false; + } catch (Exception e) {} + try { + PermissionsIntersection permissionsIntersection = (PermissionsIntersection) permission; + for (Permission perm : permissionsIntersection.getPermissionsSet()) { + if (!this.implies(perm)) { + return false; + } + } + return true; + } catch (Exception e) {} + for (Permission perm : this.permissionsSet) { + if (!perm.implies(permission)) { + return false; + } + } + return true; + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsIntersection.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsIntersection.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsIntersection.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsSet.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsSet.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsSet.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsSet.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + +import java.security.Permission; +import java.util.List; +import java.util.Set; + +import javolution.util.FastSet; + +/** + * A <code>Set</code> of permissions. + */ +@SuppressWarnings("serial") +public abstract class PermissionsSet extends BasicPermission { + + protected final Set<Permission> permissionsSet = FastSet.newInstance(); + + public PermissionsSet(String setName) { + super(setName); + } + + public PermissionsSet(String setName, List<Permission> permissionsList) { + super(setName); + this.permissionsSet.addAll(permissionsList); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + try { + PermissionsSet that = (PermissionsSet) obj; + return this.permissionsSet.equals(that.permissionsSet); + } catch (ClassCastException e) {} + return false; + } + + @Override + public String getActions() { + return null; + } + + @Override + public int hashCode() { + return permissionsSet.hashCode(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + for (Permission perm : this.permissionsSet) { + sb.append(perm); + sb.append(" "); + } + return sb.toString().trim(); + } + + public Set<Permission> getPermissionsSet() { + return this.permissionsSet; + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsSet.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsSet.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsSet.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsUnion.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsUnion.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsUnion.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsUnion.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,73 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.authorization; + +import java.security.Permission; +import java.util.Arrays; +import java.util.List; + +/** + * A <code>Set</code> of permissions that represent a union. + */ +@SuppressWarnings("serial") +public class PermissionsUnion extends PermissionsSet { + + public PermissionsUnion(String listName) { + super(listName); + } + + public PermissionsUnion(String listName, List<Permission> permissionsList) { + super(listName, permissionsList); + } + + public PermissionsUnion(String listName, Permission... permissions) { + super(listName, Arrays.asList(permissions)); + } + + /** Returns <code>true</code> if any of the contained permissions + * returns <code>true</code>. + */ + @Override + public boolean implies(Permission permission) { + try { + PermissionsUnion permissionsUnion = (PermissionsUnion) permission; + for (Permission perm : permissionsUnion.getPermissionsSet()) { + if (this.implies(perm)) { + return true; + } + } + return false; + } catch (ClassCastException e) {} + try { + PermissionsIntersection permissionsIntersection = (PermissionsIntersection) permission; + for (Permission perm : permissionsIntersection.getPermissionsSet()) { + if (!this.implies(perm)) { + return false; + } + } + return true; + } catch (ClassCastException e) {} + for (Permission perm : this.permissionsSet) { + if (perm.implies(permission)) { + return true; + } + } + return false; + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsUnion.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsUnion.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/authorization/PermissionsUnion.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/AbstractExecutionContext.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/AbstractExecutionContext.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/AbstractExecutionContext.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/AbstractExecutionContext.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,201 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.context; + +import java.util.Currency; +import java.util.Locale; +import java.util.Map; +import java.util.TimeZone; + +import javolution.util.FastList; +import javolution.util.FastMap; + +import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilProperties; + +/** Implementation of the ExecutionContext interface. */ +public abstract class AbstractExecutionContext implements ExecutionContext { + + public static final String module = AbstractExecutionContext.class.getName(); + + protected final FastList<ExecutionArtifact> artifactStack = FastList.newInstance(); + protected Currency currency = null; + protected Locale locale = Locale.getDefault(); + protected TimeZone timeZone = TimeZone.getDefault(); + protected final Map<String, Object> properties; + // Temporary - will be removed later + protected boolean verbose = false; + + protected AbstractExecutionContext() { + this.properties = FastMap.newInstance(); + this.verbose = "true".equals(UtilProperties.getPropertyValue("api.properties", "executionContext.verbose")); + } + + protected AbstractExecutionContext(Map<String, Object> properties) { + this.properties = properties; + this.verbose = "true".equals(UtilProperties.getPropertyValue("api.properties", "executionContext.verbose")); + } + + @Override + protected void finalize() throws Throwable { + if (this.artifactStack.size() > 0) { + // This check is temporary - it will be removed when implementation is complete + Debug.logError(new Exception("finalize() called with a stack that is not empty"), module); + return; + } + super.finalize(); + } + + public Currency getCurrency() { + if (this.currency == null) { + this.currency = getDefaultCurrency(); + } + return this.currency; + } + + protected Currency getDefaultCurrency() { + String currencyCode = UtilProperties.getPropertyValue("general", "currency.uom.id.default"); + return Currency.getInstance(currencyCode); + } + + public ArtifactPath getExecutionPath() { + return new ArtifactPath(getExecutionPathAsArray()); + } + + public String[] getExecutionPathAsArray() { + FastList<String> elementList = FastList.newInstance(); + elementList.add(ArtifactPath.PATH_ROOT_NODE_NAME); + for (ExecutionArtifact artifact : this.artifactStack) { + String artifactName = artifact.getName(); + if (artifactName.contains(ArtifactPath.PATH_ELEMENT_SEPARATOR)) { + String[] strArray = artifactName.split(ArtifactPath.PATH_ELEMENT_SEPARATOR); + for (int i = 0; i < strArray.length; i++) { + elementList.add(strArray[i]); + } + } else { + elementList.add(artifactName); + } + } + return elementList.toArray(new String[elementList.size()]); + } + + public String getExecutionPathAsString() { + StringBuilder sb = new StringBuilder(ArtifactPath.PATH_ROOT_NODE_NAME); + for (ExecutionArtifact artifact : this.artifactStack) { + sb.append(ArtifactPath.PATH_ELEMENT_SEPARATOR); + sb.append(artifact.getName()); + } + return sb.toString(); + } + + public Locale getLocale() { + return this.locale; + } + + public Map<String, ? extends Object> getParameters() { + for (int i = this.artifactStack.size() - 1; i >= 0; i--) { + try { + ParametersArtifact artifact = (ParametersArtifact) this.artifactStack.get(i); + return artifact.getParameters(); + } catch (Exception e) {} + } + return null; + } + + public Object getProperty(String key) { + return this.properties.get(key); + } + + public TimeZone getTimeZone() { + return this.timeZone; + } + + public void popExecutionArtifact() { + if (this.artifactStack.size() == 0) { + // This check is temporary - it will be removed when implementation is complete + Debug.logError(new Exception("Attempt to pop an empty stack"), module); + return; + } + ExecutionArtifact artifact = this.artifactStack.removeLast(); + if (this.verbose) { + Debug.logInfo("Popping artifact [" + artifact.getClass().getName() + "] location = " + artifact.getLocation() + ", name = " + artifact.getName(), module); + } + } + + public void pushExecutionArtifact(ExecutionArtifact artifact) { + this.artifactStack.addLast(artifact); + if (this.verbose) { + Debug.logInfo("Pushing artifact [" + artifact.getClass().getName() + "] location = " + artifact.getLocation() + ", name = " + artifact.getName(), module); + } + } + + public void reset() { + if (this.verbose) { + Debug.logInfo("Resetting ExecutionContext", module); + } + this.artifactStack.clear(); + this.currency = getDefaultCurrency(); + this.locale = Locale.getDefault(); + this.properties.clear(); + this.timeZone = TimeZone.getDefault(); + } + + public void setCurrency(Currency currency) { + if (currency != null) { + this.currency = currency; + } + } + + public void setLocale(Locale locale) { + if (locale != null) { + this.locale = locale; + } + } + + protected void setLocale(String locale) { + if (locale != null) { + this.locale = new Locale(locale); + } else { + this.locale = Locale.getDefault(); + } + } + + public Object setProperty(String key, Object value) { + return this.properties.put(key, value); + } + + protected void setTimeZone(String timeZone) { + if (timeZone != null) { + this.timeZone = TimeZone.getTimeZone(timeZone); + } else { + this.timeZone = TimeZone.getDefault(); + } + } + + public void setTimeZone(TimeZone timeZone) { + if (timeZone != null) { + this.timeZone = timeZone; + } + } + + @Override + public String toString() { + return this.getExecutionPathAsString(); + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/AbstractExecutionContext.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/AbstractExecutionContext.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/AbstractExecutionContext.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ArtifactPath.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ArtifactPath.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ArtifactPath.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ArtifactPath.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,132 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.context; + +import java.util.Iterator; +import java.util.NoSuchElementException; + +import javolution.text.TextBuilder; +import javolution.util.FastList; + +/** Artifact path class. */ +public class ArtifactPath implements Iterator<String> { + + public static final String PATH_ROOT_NODE_NAME = "ofbiz"; + public static final String PATH_ELEMENT_SEPARATOR = "/"; + public static final ArtifactPath PATH_ROOT = new PathRoot(); + + protected int currentIndex = 0; + protected final String[] pathElementArray; + protected FastList<Integer> stack = FastList.newInstance(); + + public ArtifactPath(String artifactPath) { + this.pathElementArray = artifactPath.split(PATH_ELEMENT_SEPARATOR); + } + + public ArtifactPath(String... pathElementArray) { + this.pathElementArray = pathElementArray; + } + + public String getCurrentPath() { + if (this.pathElementArray.length == 1 || !this.hasNext()) { + return this.pathElementArray[this.currentIndex]; + } + return getPathAsString(this.currentIndex); + } + + public String getCurrentPathElement() { + return this.pathElementArray[this.currentIndex]; + } + + protected String getPathAsString(int index) { + TextBuilder stringBuilder = TextBuilder.newInstance(); + for (int i = index; i < this.pathElementArray.length; i++) { + if (i != index) { + stringBuilder.append(PATH_ELEMENT_SEPARATOR); + } + stringBuilder.append(this.pathElementArray[i]); + } + return stringBuilder.toString(); + } + + @Override + public boolean hasNext() { + return this.currentIndex + 1 < this.pathElementArray.length; + } + + @Override + public String next() { + if (!this.hasNext()) { + throw new NoSuchElementException(); + } + return this.pathElementArray[++this.currentIndex]; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + public void restoreState() { + if (!this.stack.isEmpty()) { + this.currentIndex = this.stack.removeLast(); + } + } + + public void saveState() { + this.stack.addLast(this.currentIndex); + } + + @Override + public String toString() { + return getPathAsString(0); + } + + protected static class PathRoot extends ArtifactPath { + PathRoot() { + super(new String[]{PATH_ROOT_NODE_NAME}); + } + + @Override + public String getCurrentPath() { + return PATH_ROOT_NODE_NAME; + } + + @Override + public String getCurrentPathElement() { + return PATH_ROOT_NODE_NAME; + } + + @Override + public boolean hasNext() { + return false; + } + + @Override + public String next() { + throw new NoSuchElementException(); + } + + @Override + public void restoreState() {} + + @Override + public void saveState() {} + } +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ArtifactPath.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ArtifactPath.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ArtifactPath.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ExecutionArtifact.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ExecutionArtifact.java?rev=930719&view=auto ============================================================================== --- ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ExecutionArtifact.java (added) +++ ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ExecutionArtifact.java Sun Apr 4 17:12:53 2010 @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.base.context; + +/** ExecutionArtifact interface. Artifacts in the program's execution + * path (services, screen widgets, form widgets, entities) should implement + * this interface. + */ +public interface ExecutionArtifact { + + /** + * Returns the location of this artifact. + * + * @return Location of this artifact + */ + String getLocation(); + + /** + * Returns the name of this artifact. + * + * @return Name of this artifact + */ + String getName(); +} Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ExecutionArtifact.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ExecutionArtifact.java ------------------------------------------------------------------------------ svn:keywords = Date Rev Author URL Id Propchange: ofbiz/branches/executioncontext20091231/framework/base/src/org/ofbiz/base/context/ExecutionArtifact.java ------------------------------------------------------------------------------ svn:mime-type = text/plain |
| Free forum by Nabble | Edit this page |
