← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14464: renamed SharingService => AccessControlService, will be used for all manner of access control, wip

 

------------------------------------------------------------
revno: 14464
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-03-27 05:38:53 +0100
message:
  renamed SharingService => AccessControlService, will be used for all manner of access control, wip
removed:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sharing/SharingService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sharing/DefaultSharingService.java
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/sharing/AccessControlService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sharing/DefaultAccessControlService.java
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/dimension/DefaultDimensionService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sharing/AccessControlService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sharing/AccessControlService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sharing/AccessControlService.java	2014-03-27 04:38:53 +0000
@@ -0,0 +1,150 @@
+package org.hisp.dhis.sharing;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.user.User;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public interface AccessControlService
+{
+    public static final List<String> SHARING_OVERRIDE_AUTHORITIES = Arrays.asList( "ALL", "F_METADATA_IMPORT" );
+
+    boolean isSupported( String type );
+
+    boolean isSupported( Class<?> klass );
+
+    /**
+     * Can user write to this object (create)
+     * <p/>
+     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
+     * 2. Is the user for the object null?
+     * 3. Is the user of the object equal to current user?
+     * 4. Is the object public write?
+     * 5. Does any of the userGroupAccesses contain public write and the current user is in that group
+     *
+     * @param user   User to check against
+     * @param object Object to check
+     * @return Result of test
+     */
+    boolean canWrite( User user, IdentifiableObject object );
+
+    /**
+     * Can user read this object
+     * <p/>
+     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
+     * 2. Is the user for the object null?
+     * 3. Is the user of the object equal to current user?
+     * 4. Is the object public read?
+     * 5. Does any of the userGroupAccesses contain public read and the current user is in that group
+     *
+     * @param user   User to check against
+     * @param object Object to check
+     * @return Result of test
+     */
+    boolean canRead( User user, IdentifiableObject object );
+
+    /**
+     * Can user update this object
+     * <p/>
+     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
+     * 2. Can user write to this object?
+     *
+     * @param user   User to check against
+     * @param object Object to check
+     * @return Result of test
+     */
+    boolean canUpdate( User user, IdentifiableObject object );
+
+    /**
+     * Can user delete this object
+     * <p/>
+     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
+     * 2. Can user write to this object?
+     *
+     * @param user   User to check against
+     * @param object Object to check
+     * @return Result of test
+     */
+    boolean canDelete( User user, IdentifiableObject object );
+
+    /**
+     * Can user manage (make public) this object
+     * <p/>
+     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
+     * 2. Can user write to this object?
+     *
+     * @param user   User to check against
+     * @param object Object to check
+     * @return Result of test
+     */
+    boolean canManage( User user, IdentifiableObject object );
+
+    /**
+     * Checks if a user can create a public instance of a certain object.
+     * <p/>
+     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
+     * 2. Does user have the authority to create public instances of that object
+     *
+     * @param user  User to check against
+     * @param klass Class to check
+     * @return Result of test
+     */
+    <T extends IdentifiableObject> boolean canCreatePublic( User user, Class<T> klass );
+
+    /**
+     * Checks if a user can create a private instance of a certain object.
+     * <p/>
+     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
+     * 2. Does user have the authority to create private instances of that object
+     *
+     * @param user  User to check against
+     * @param klass Class to check
+     * @return Result of test
+     */
+    <T extends IdentifiableObject> boolean canCreatePrivate( User user, Class<T> klass );
+
+    /**
+     * Can user make this object external? (read with no login)
+     *
+     * @param user   User to check against
+     * @param klass Type to check
+     * @return Result of test
+     */
+    <T extends IdentifiableObject> boolean canExternalize( User user, Class<T> klass );
+
+    <T extends IdentifiableObject> boolean defaultPublic( Class<T> klass );
+
+    Class<? extends IdentifiableObject> classForType( String type );
+}

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sharing/SharingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sharing/SharingService.java	2014-03-21 11:57:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sharing/SharingService.java	1970-01-01 00:00:00 +0000
@@ -1,150 +0,0 @@
-package org.hisp.dhis.sharing;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.user.User;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public interface SharingService
-{
-    public static final List<String> SHARING_OVERRIDE_AUTHORITIES = Arrays.asList( "ALL", "F_METADATA_IMPORT" );
-
-    boolean isSupported( String type );
-
-    boolean isSupported( Class<?> klass );
-
-    /**
-     * Can user write to this object (create)
-     * <p/>
-     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
-     * 2. Is the user for the object null?
-     * 3. Is the user of the object equal to current user?
-     * 4. Is the object public write?
-     * 5. Does any of the userGroupAccesses contain public write and the current user is in that group
-     *
-     * @param user   User to check against
-     * @param object Object to check
-     * @return Result of test
-     */
-    boolean canWrite( User user, IdentifiableObject object );
-
-    /**
-     * Can user read this object
-     * <p/>
-     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
-     * 2. Is the user for the object null?
-     * 3. Is the user of the object equal to current user?
-     * 4. Is the object public read?
-     * 5. Does any of the userGroupAccesses contain public read and the current user is in that group
-     *
-     * @param user   User to check against
-     * @param object Object to check
-     * @return Result of test
-     */
-    boolean canRead( User user, IdentifiableObject object );
-
-    /**
-     * Can user update this object
-     * <p/>
-     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
-     * 2. Can user write to this object?
-     *
-     * @param user   User to check against
-     * @param object Object to check
-     * @return Result of test
-     */
-    boolean canUpdate( User user, IdentifiableObject object );
-
-    /**
-     * Can user delete this object
-     * <p/>
-     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
-     * 2. Can user write to this object?
-     *
-     * @param user   User to check against
-     * @param object Object to check
-     * @return Result of test
-     */
-    boolean canDelete( User user, IdentifiableObject object );
-
-    /**
-     * Can user manage (make public) this object
-     * <p/>
-     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
-     * 2. Can user write to this object?
-     *
-     * @param user   User to check against
-     * @param object Object to check
-     * @return Result of test
-     */
-    boolean canManage( User user, IdentifiableObject object );
-
-    /**
-     * Checks if a user can create a public instance of a certain object.
-     * <p/>
-     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
-     * 2. Does user have the authority to create public instances of that object
-     *
-     * @param user  User to check against
-     * @param klass Class to check
-     * @return Result of test
-     */
-    <T extends IdentifiableObject> boolean canCreatePublic( User user, Class<T> klass );
-
-    /**
-     * Checks if a user can create a private instance of a certain object.
-     * <p/>
-     * 1. Does user have SHARING_OVERRIDE_AUTHORITY authority?
-     * 2. Does user have the authority to create private instances of that object
-     *
-     * @param user  User to check against
-     * @param klass Class to check
-     * @return Result of test
-     */
-    <T extends IdentifiableObject> boolean canCreatePrivate( User user, Class<T> klass );
-
-    /**
-     * Can user make this object external? (read with no login)
-     *
-     * @param user   User to check against
-     * @param klass Type to check
-     * @return Result of test
-     */
-    <T extends IdentifiableObject> boolean canExternalize( User user, Class<T> klass );
-
-    <T extends IdentifiableObject> boolean defaultPublic( Class<T> klass );
-
-    Class<? extends IdentifiableObject> classForType( String type );
-}

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/dimension/DefaultDimensionService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/dimension/DefaultDimensionService.java	2014-03-26 21:55:22 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/dimension/DefaultDimensionService.java	2014-03-27 04:38:53 +0000
@@ -56,7 +56,7 @@
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.period.RelativePeriodEnum;
 import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.sharing.SharingService;
+import org.hisp.dhis.sharing.AccessControlService;
 import org.hisp.dhis.system.util.UniqueArrayList;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeDimension;
@@ -100,7 +100,7 @@
     private DataElementService dataElementService;
 
     @Autowired
-    private SharingService sharingService;
+    private AccessControlService accessControlService;
 
     @Autowired
     private CurrentUserService currentUserService;
@@ -169,7 +169,7 @@
 
             for ( NameableObject item : dimension.getItems() )
             {
-                boolean canRead = sharingService.canRead( user, item );
+                boolean canRead = accessControlService.canRead( user, item );
 
                 if ( canRead )
                 {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java	2014-03-21 11:57:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java	2014-03-27 04:38:53 +0000
@@ -35,7 +35,7 @@
 import org.hisp.dhis.message.MessageSender;
 import org.hisp.dhis.period.Cal;
 import org.hisp.dhis.setting.SystemSettingManager;
-import org.hisp.dhis.sharing.SharingService;
+import org.hisp.dhis.sharing.AccessControlService;
 import org.hisp.dhis.system.util.ValidationUtils;
 import org.hisp.dhis.system.velocity.VelocityManager;
 import org.hisp.dhis.user.CurrentUserService;
@@ -104,7 +104,7 @@
     private CurrentUserService currentUserService;
 
     @Autowired
-    private SharingService sharingService;
+    private AccessControlService accessControlService;
 
     // -------------------------------------------------------------------------
     // SecurityService implementation
@@ -289,67 +289,67 @@
     @Override
     public boolean canCreatePublic( IdentifiableObject identifiableObject )
     {
-        return !sharingService.isSupported( identifiableObject.getClass() )
-            || sharingService.canCreatePublic( currentUserService.getCurrentUser(), identifiableObject.getClass() );
+        return !accessControlService.isSupported( identifiableObject.getClass() )
+            || accessControlService.canCreatePublic( currentUserService.getCurrentUser(), identifiableObject.getClass() );
     }
 
     @Override
     public boolean canCreatePublic( String type )
     {
-        Class<? extends IdentifiableObject> klass = sharingService.classForType( type );
+        Class<? extends IdentifiableObject> klass = accessControlService.classForType( type );
 
-        return !sharingService.isSupported( klass )
-            || sharingService.canCreatePublic( currentUserService.getCurrentUser(), klass );
+        return !accessControlService.isSupported( klass )
+            || accessControlService.canCreatePublic( currentUserService.getCurrentUser(), klass );
     }
 
     @Override
     public boolean canCreatePrivate( IdentifiableObject identifiableObject )
     {
-        return !sharingService.isSupported( identifiableObject.getClass() )
-            || sharingService.canCreatePrivate( currentUserService.getCurrentUser(), identifiableObject.getClass() );
+        return !accessControlService.isSupported( identifiableObject.getClass() )
+            || accessControlService.canCreatePrivate( currentUserService.getCurrentUser(), identifiableObject.getClass() );
     }
 
     @Override
     public boolean canCreatePrivate( String type )
     {
-        Class<? extends IdentifiableObject> klass = sharingService.classForType( type );
+        Class<? extends IdentifiableObject> klass = accessControlService.classForType( type );
 
-        return !sharingService.isSupported( klass )
-            || sharingService.canCreatePrivate( currentUserService.getCurrentUser(), klass );
+        return !accessControlService.isSupported( klass )
+            || accessControlService.canCreatePrivate( currentUserService.getCurrentUser(), klass );
     }
 
     @Override
     public boolean canRead( IdentifiableObject identifiableObject )
     {
-        return !sharingService.isSupported( identifiableObject.getClass() )
-            || sharingService.canRead( currentUserService.getCurrentUser(), identifiableObject );
+        return !accessControlService.isSupported( identifiableObject.getClass() )
+            || accessControlService.canRead( currentUserService.getCurrentUser(), identifiableObject );
     }
 
     @Override
     public boolean canWrite( IdentifiableObject identifiableObject )
     {
-        return !sharingService.isSupported( identifiableObject.getClass() )
-            || sharingService.canWrite( currentUserService.getCurrentUser(), identifiableObject );
+        return !accessControlService.isSupported( identifiableObject.getClass() )
+            || accessControlService.canWrite( currentUserService.getCurrentUser(), identifiableObject );
     }
 
     @Override
     public boolean canUpdate( IdentifiableObject identifiableObject )
     {
-        return !sharingService.isSupported( identifiableObject.getClass() )
-            || sharingService.canUpdate( currentUserService.getCurrentUser(), identifiableObject );
+        return !accessControlService.isSupported( identifiableObject.getClass() )
+            || accessControlService.canUpdate( currentUserService.getCurrentUser(), identifiableObject );
     }
 
     @Override
     public boolean canDelete( IdentifiableObject identifiableObject )
     {
-        return !sharingService.isSupported( identifiableObject.getClass() )
-            || sharingService.canDelete( currentUserService.getCurrentUser(), identifiableObject );
+        return !accessControlService.isSupported( identifiableObject.getClass() )
+            || accessControlService.canDelete( currentUserService.getCurrentUser(), identifiableObject );
     }
 
     @Override
     public boolean canManage( IdentifiableObject identifiableObject )
     {
-        return !sharingService.isSupported( identifiableObject.getClass() )
-            || sharingService.canManage( currentUserService.getCurrentUser(), identifiableObject );
+        return !accessControlService.isSupported( identifiableObject.getClass() )
+            || accessControlService.canManage( currentUserService.getCurrentUser(), identifiableObject );
     }
 }

=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sharing/DefaultAccessControlService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sharing/DefaultAccessControlService.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sharing/DefaultAccessControlService.java	2014-03-27 04:38:53 +0000
@@ -0,0 +1,279 @@
+package org.hisp.dhis.sharing;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.dashboard.Dashboard;
+import org.hisp.dhis.schema.AuthorityType;
+import org.hisp.dhis.schema.Schema;
+import org.hisp.dhis.schema.SchemaService;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupAccess;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.springframework.util.CollectionUtils.containsAny;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class DefaultAccessControlService implements AccessControlService
+{
+    @Autowired
+    private SchemaService schemaService;
+
+    @Override
+    public boolean isSupported( String type )
+    {
+        Schema schema = schemaService.getSchemaBySingularName( type );
+        return schema != null && schema.isShareable();
+    }
+
+    @Override
+    public boolean isSupported( Class<?> klass )
+    {
+        Schema schema = schemaService.getSchema( klass );
+        return schema != null && schema.isShareable();
+    }
+
+    @Override
+    public boolean canWrite( User user, IdentifiableObject object )
+    {
+        Schema schema = schemaService.getSchema( object.getClass() );
+
+        if ( schema == null || !schema.isShareable() )
+        {
+            return false;
+        }
+
+        //TODO ( (object instanceof User) && canCreatePrivate( user, object ) ): review possible security breaches and best way to give update access upon user import
+        if ( haveOverrideAuthority( user )
+            || (object.getUser() == null && canCreatePublic( user, object.getClass() ) && !schema.getAuthorityByType( AuthorityType.CREATE_PRIVATE ).isEmpty())
+            || (user != null && user.equals( object.getUser() ))
+            //|| authorities.contains( PRIVATE_AUTHORITIES.get( object.getClass() ) )
+            || ((object instanceof User) && canCreatePrivate( user, object.getClass() ))
+            || AccessStringHelper.canWrite( object.getPublicAccess() ) )
+        {
+            return true;
+        }
+
+        for ( UserGroupAccess userGroupAccess : object.getUserGroupAccesses() )
+        {
+            if ( AccessStringHelper.canWrite( userGroupAccess.getAccess() )
+                && userGroupAccess.getUserGroup().getMembers().contains( user ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean canRead( User user, IdentifiableObject object )
+    {
+        Schema schema = schemaService.getSchema( object.getClass() );
+
+        if ( schema == null || !schema.isShareable() )
+        {
+            return false;
+        }
+
+        if ( haveOverrideAuthority( user )
+            || UserGroup.class.isAssignableFrom( object.getClass() )
+            || object.getUser() == null
+            || user.equals( object.getUser() )
+            || AccessStringHelper.canRead( object.getPublicAccess() ) )
+        {
+            return true;
+        }
+
+        for ( UserGroupAccess userGroupAccess : object.getUserGroupAccesses() )
+        {
+            if ( AccessStringHelper.canRead( userGroupAccess.getAccess() )
+                && userGroupAccess.getUserGroup().getMembers().contains( user ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean canUpdate( User user, IdentifiableObject object )
+    {
+        Schema schema = schemaService.getSchema( object.getClass() );
+
+        if ( schema == null || !schema.isShareable() )
+        {
+            return false;
+        }
+
+        if ( schema.getAuthorityByType( AuthorityType.UPDATE ).isEmpty() )
+        {
+            return canWrite( user, object );
+        }
+
+        Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
+
+        return canAccess( authorities, schema.getAuthorityByType( AuthorityType.UPDATE ) ) && canWrite( user, object );
+    }
+
+    @Override
+    public boolean canDelete( User user, IdentifiableObject object )
+    {
+        Schema schema = schemaService.getSchema( object.getClass() );
+
+        if ( schema == null || !schema.isShareable() )
+        {
+            return false;
+        }
+
+        if ( schema.getAuthorityByType( AuthorityType.DELETE ).isEmpty() )
+        {
+            return canWrite( user, object );
+        }
+
+        Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
+
+        return canAccess( authorities, schema.getAuthorityByType( AuthorityType.DELETE ) ) && canWrite( user, object );
+    }
+
+    private boolean canAccess( Collection<String> userAuthorities, Collection<String> requiredAuthorities )
+    {
+        return containsAny( userAuthorities, SHARING_OVERRIDE_AUTHORITIES ) ||
+            containsAny( userAuthorities, requiredAuthorities );
+    }
+
+    @Override
+    public boolean canManage( User user, IdentifiableObject object )
+    {
+        Schema schema = schemaService.getSchema( object.getClass() );
+
+        if ( schema == null || !schema.isShareable() )
+        {
+            return false;
+        }
+
+        if ( haveOverrideAuthority( user )
+            || (object.getUser() == null && canCreatePublic( user, object.getClass() ) && !schema.getAuthorityByType( AuthorityType.CREATE_PRIVATE ).isEmpty())
+            || user.equals( object.getUser() )
+            || AccessStringHelper.canWrite( object.getPublicAccess() ) )
+        {
+            return true;
+        }
+
+        for ( UserGroupAccess userGroupAccess : object.getUserGroupAccesses() )
+        {
+            if ( AccessStringHelper.canWrite( userGroupAccess.getAccess() )
+                && userGroupAccess.getUserGroup().getMembers().contains( user ) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    @Override
+    public <T extends IdentifiableObject> boolean canCreatePublic( User user, Class<T> klass )
+    {
+        Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
+
+        Schema schema = schemaService.getSchema( klass );
+
+        if ( schema == null || !schema.isShareable() )
+        {
+            return false;
+        }
+
+        return containsAny( authorities, SHARING_OVERRIDE_AUTHORITIES ) || containsAny( authorities, schema.getAuthorityByType( AuthorityType.CREATE_PUBLIC ) );
+    }
+
+    @Override
+    public <T extends IdentifiableObject> boolean canCreatePrivate( User user, Class<T> klass )
+    {
+        Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
+
+        Schema schema = schemaService.getSchema( klass );
+
+        if ( schema == null || !schema.isShareable() )
+        {
+            return false;
+        }
+
+        return containsAny( authorities, SHARING_OVERRIDE_AUTHORITIES ) || containsAny( authorities, schema.getAuthorityByType( AuthorityType.CREATE_PRIVATE ) );
+    }
+
+    @Override
+    public <T extends IdentifiableObject> boolean canExternalize( User user, Class<T> klass )
+    {
+        Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
+
+        Schema schema = schemaService.getSchema( klass );
+
+        if ( schema == null || !schema.isShareable() )
+        {
+            return false;
+        }
+
+        return containsAny( authorities, SHARING_OVERRIDE_AUTHORITIES ) || containsAny( authorities, schema.getAuthorityByType( AuthorityType.EXTERNALIZE ) );
+    }
+
+    @Override
+    public <T extends IdentifiableObject> boolean defaultPublic( Class<T> klass )
+    {
+        // TODO this is quite nasty, should probably be added to schema
+        return !Dashboard.class.isAssignableFrom( klass );
+    }
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public Class<? extends IdentifiableObject> classForType( String type )
+    {
+        Schema schema = schemaService.getSchemaBySingularName( type );
+
+        if ( schema != null && schema.isShareable() && schema.isIdentifiableObject() )
+        {
+            return (Class<? extends IdentifiableObject>) schema.getKlass();
+        }
+
+        return null;
+    }
+
+    private boolean haveOverrideAuthority( User user )
+    {
+        return user == null || containsAny( user.getUserCredentials().getAllAuthorities(), SHARING_OVERRIDE_AUTHORITIES );
+    }
+}

=== removed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sharing/DefaultSharingService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sharing/DefaultSharingService.java	2014-03-27 04:04:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sharing/DefaultSharingService.java	1970-01-01 00:00:00 +0000
@@ -1,279 +0,0 @@
-package org.hisp.dhis.sharing;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.dashboard.Dashboard;
-import org.hisp.dhis.schema.AuthorityType;
-import org.hisp.dhis.schema.Schema;
-import org.hisp.dhis.schema.SchemaService;
-import org.hisp.dhis.user.User;
-import org.hisp.dhis.user.UserGroup;
-import org.hisp.dhis.user.UserGroupAccess;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.springframework.util.CollectionUtils.containsAny;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class DefaultSharingService implements SharingService
-{
-    @Autowired
-    private SchemaService schemaService;
-
-    @Override
-    public boolean isSupported( String type )
-    {
-        Schema schema = schemaService.getSchemaBySingularName( type );
-        return schema != null && schema.isShareable();
-    }
-
-    @Override
-    public boolean isSupported( Class<?> klass )
-    {
-        Schema schema = schemaService.getSchema( klass );
-        return schema != null && schema.isShareable();
-    }
-
-    @Override
-    public boolean canWrite( User user, IdentifiableObject object )
-    {
-        Schema schema = schemaService.getSchema( object.getClass() );
-
-        if ( schema == null || !schema.isShareable() )
-        {
-            return false;
-        }
-
-        //TODO ( (object instanceof User) && canCreatePrivate( user, object ) ): review possible security breaches and best way to give update access upon user import
-        if ( haveOverrideAuthority( user )
-            || (object.getUser() == null && canCreatePublic( user, object.getClass() ) && !schema.getAuthorityByType( AuthorityType.CREATE_PRIVATE ).isEmpty())
-            || (user != null && user.equals( object.getUser() ))
-            //|| authorities.contains( PRIVATE_AUTHORITIES.get( object.getClass() ) )
-            || ((object instanceof User) && canCreatePrivate( user, object.getClass() ))
-            || AccessStringHelper.canWrite( object.getPublicAccess() ) )
-        {
-            return true;
-        }
-
-        for ( UserGroupAccess userGroupAccess : object.getUserGroupAccesses() )
-        {
-            if ( AccessStringHelper.canWrite( userGroupAccess.getAccess() )
-                && userGroupAccess.getUserGroup().getMembers().contains( user ) )
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    @Override
-    public boolean canRead( User user, IdentifiableObject object )
-    {
-        Schema schema = schemaService.getSchema( object.getClass() );
-
-        if ( schema == null || !schema.isShareable() )
-        {
-            return false;
-        }
-
-        if ( haveOverrideAuthority( user )
-            || UserGroup.class.isAssignableFrom( object.getClass() )
-            || object.getUser() == null
-            || user.equals( object.getUser() )
-            || AccessStringHelper.canRead( object.getPublicAccess() ) )
-        {
-            return true;
-        }
-
-        for ( UserGroupAccess userGroupAccess : object.getUserGroupAccesses() )
-        {
-            if ( AccessStringHelper.canRead( userGroupAccess.getAccess() )
-                && userGroupAccess.getUserGroup().getMembers().contains( user ) )
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    @Override
-    public boolean canUpdate( User user, IdentifiableObject object )
-    {
-        Schema schema = schemaService.getSchema( object.getClass() );
-
-        if ( schema == null || !schema.isShareable() )
-        {
-            return false;
-        }
-
-        if ( schema.getAuthorityByType( AuthorityType.UPDATE ).isEmpty() )
-        {
-            return canWrite( user, object );
-        }
-
-        Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
-
-        return canAccess( authorities, schema.getAuthorityByType( AuthorityType.UPDATE ) ) && canWrite( user, object );
-    }
-
-    @Override
-    public boolean canDelete( User user, IdentifiableObject object )
-    {
-        Schema schema = schemaService.getSchema( object.getClass() );
-
-        if ( schema == null || !schema.isShareable() )
-        {
-            return false;
-        }
-
-        if ( schema.getAuthorityByType( AuthorityType.DELETE ).isEmpty() )
-        {
-            return canWrite( user, object );
-        }
-
-        Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
-
-        return canAccess( authorities, schema.getAuthorityByType( AuthorityType.DELETE ) ) && canWrite( user, object );
-    }
-
-    private boolean canAccess( Collection<String> userAuthorities, Collection<String> requiredAuthorities )
-    {
-        return containsAny( userAuthorities, SHARING_OVERRIDE_AUTHORITIES ) ||
-            containsAny( userAuthorities, requiredAuthorities );
-    }
-
-    @Override
-    public boolean canManage( User user, IdentifiableObject object )
-    {
-        Schema schema = schemaService.getSchema( object.getClass() );
-
-        if ( schema == null || !schema.isShareable() )
-        {
-            return false;
-        }
-
-        if ( haveOverrideAuthority( user )
-            || (object.getUser() == null && canCreatePublic( user, object.getClass() ) && !schema.getAuthorityByType( AuthorityType.CREATE_PRIVATE ).isEmpty())
-            || user.equals( object.getUser() )
-            || AccessStringHelper.canWrite( object.getPublicAccess() ) )
-        {
-            return true;
-        }
-
-        for ( UserGroupAccess userGroupAccess : object.getUserGroupAccesses() )
-        {
-            if ( AccessStringHelper.canWrite( userGroupAccess.getAccess() )
-                && userGroupAccess.getUserGroup().getMembers().contains( user ) )
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    @Override
-    public <T extends IdentifiableObject> boolean canCreatePublic( User user, Class<T> klass )
-    {
-        Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
-
-        Schema schema = schemaService.getSchema( klass );
-
-        if ( schema == null || !schema.isShareable() )
-        {
-            return false;
-        }
-
-        return containsAny( authorities, SHARING_OVERRIDE_AUTHORITIES ) || containsAny( authorities, schema.getAuthorityByType( AuthorityType.CREATE_PUBLIC ) );
-    }
-
-    @Override
-    public <T extends IdentifiableObject> boolean canCreatePrivate( User user, Class<T> klass )
-    {
-        Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
-
-        Schema schema = schemaService.getSchema( klass );
-
-        if ( schema == null || !schema.isShareable() )
-        {
-            return false;
-        }
-
-        return containsAny( authorities, SHARING_OVERRIDE_AUTHORITIES ) || containsAny( authorities, schema.getAuthorityByType( AuthorityType.CREATE_PRIVATE ) );
-    }
-
-    @Override
-    public <T extends IdentifiableObject> boolean canExternalize( User user, Class<T> klass )
-    {
-        Set<String> authorities = user != null ? user.getUserCredentials().getAllAuthorities() : new HashSet<String>();
-
-        Schema schema = schemaService.getSchema( klass );
-
-        if ( schema == null || !schema.isShareable() )
-        {
-            return false;
-        }
-
-        return containsAny( authorities, SHARING_OVERRIDE_AUTHORITIES ) || containsAny( authorities, schema.getAuthorityByType( AuthorityType.EXTERNALIZE ) );
-    }
-
-    @Override
-    public <T extends IdentifiableObject> boolean defaultPublic( Class<T> klass )
-    {
-        // TODO this is quite nasty, should probably be added to schema
-        return !Dashboard.class.isAssignableFrom( klass );
-    }
-
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public Class<? extends IdentifiableObject> classForType( String type )
-    {
-        Schema schema = schemaService.getSchemaBySingularName( type );
-
-        if ( schema != null && schema.isShareable() && schema.isIdentifiableObject() )
-        {
-            return (Class<? extends IdentifiableObject>) schema.getKlass();
-        }
-
-        return null;
-    }
-
-    private boolean haveOverrideAuthority( User user )
-    {
-        return user == null || containsAny( user.getUserCredentials().getAllAuthorities(), SHARING_OVERRIDE_AUTHORITIES );
-    }
-}

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2014-03-26 18:14:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2014-03-27 04:38:53 +0000
@@ -11,7 +11,7 @@
 
   <bean id="org.hisp.dhis.schema.PropertyIntrospectorService" class="org.hisp.dhis.schema.DefaultPropertyIntrospectorService" />
 
-  <bean id="org.hisp.dhis.sharing.SharingService" class="org.hisp.dhis.sharing.DefaultSharingService" />
+  <bean id="org.hisp.dhis.sharing.AccessControlService" class="org.hisp.dhis.sharing.DefaultAccessControlService" />
 
   <!-- Store definitions -->
 

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2014-03-21 12:20:36 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2014-03-27 04:38:53 +0000
@@ -55,7 +55,7 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.sharing.SharingService;
+import org.hisp.dhis.sharing.AccessControlService;
 import org.hisp.dhis.system.util.CollectionUtils;
 import org.hisp.dhis.system.util.ReflectionUtils;
 import org.hisp.dhis.system.util.functional.Function1;
@@ -110,7 +110,7 @@
     private SessionFactory sessionFactory;
 
     @Autowired
-    private SharingService sharingService;
+    private AccessControlService accessControlService;
 
     @Autowired( required = false )
     private List<ObjectHandler<T>> objectHandlers;
@@ -414,7 +414,7 @@
      */
     protected boolean deleteObject( User user, T persistedObject )
     {
-        if ( !sharingService.canDelete( user, persistedObject ) )
+        if ( !accessControlService.canDelete( user, persistedObject ) )
         {
             summaryType.getImportConflicts().add(
                 new ImportConflict( ImportUtils.getDisplayName( persistedObject ), "You do not have delete access to class type." ) );
@@ -452,7 +452,7 @@
      */
     protected boolean newObject( User user, T object )
     {
-        if ( !sharingService.canCreatePublic( user, object.getClass() ) && !sharingService.canCreatePrivate( user, object.getClass() ) )
+        if ( !accessControlService.canCreatePublic( user, object.getClass() ) && !accessControlService.canCreatePrivate( user, object.getClass() ) )
         {
             summaryType.getImportConflicts().add(
                 new ImportConflict( ImportUtils.getDisplayName( object ), "You do not have create access to class type." ) );
@@ -536,7 +536,7 @@
      */
     protected boolean updateObject( User user, T object, T persistedObject )
     {
-        if ( !sharingService.canUpdate( user, persistedObject ) )
+        if ( !accessControlService.canUpdate( user, persistedObject ) )
         {
             summaryType.getImportConflicts().add(
                 new ImportConflict( ImportUtils.getDisplayName( object ), "You do not have update access to object." ) );

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2014-03-21 11:57:24 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2014-03-27 04:38:53 +0000
@@ -46,8 +46,8 @@
 import org.hisp.dhis.hibernate.exception.ReadAccessDeniedException;
 import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
 import org.hisp.dhis.interpretation.Interpretation;
+import org.hisp.dhis.sharing.AccessControlService;
 import org.hisp.dhis.sharing.AccessStringHelper;
-import org.hisp.dhis.sharing.SharingService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.UserGroupAccess;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -85,7 +85,7 @@
     protected CurrentUserService currentUserService;
 
     @Autowired
-    protected SharingService sharingService;
+    protected AccessControlService accessControlService;
 
     protected Class<T> clazz;
 
@@ -227,7 +227,7 @@
     @Override
     public int save( T object )
     {
-        if ( !Interpretation.class.isAssignableFrom( clazz ) && currentUserService.getCurrentUser() != null && sharingService.isSupported( clazz ) )
+        if ( !Interpretation.class.isAssignableFrom( clazz ) && currentUserService.getCurrentUser() != null && accessControlService.isSupported( clazz ) )
         {
             BaseIdentifiableObject identifiableObject = (BaseIdentifiableObject) object;
 
@@ -240,9 +240,9 @@
                 identifiableObject.setUser( currentUserService.getCurrentUser() );
             }
 
-            if ( sharingService.canCreatePublic( currentUserService.getCurrentUser(), identifiableObject.getClass() ) )
+            if ( accessControlService.canCreatePublic( currentUserService.getCurrentUser(), identifiableObject.getClass() ) )
             {
-                if ( sharingService.defaultPublic( identifiableObject.getClass() ) )
+                if ( accessControlService.defaultPublic( identifiableObject.getClass() ) )
                 {
                     String build = AccessStringHelper.newInstance()
                         .enable( AccessStringHelper.Permission.READ )
@@ -257,7 +257,7 @@
                     identifiableObject.setPublicAccess( build );
                 }
             }
-            else if ( sharingService.canCreatePrivate( currentUserService.getCurrentUser(), identifiableObject.getClass() ) )
+            else if ( accessControlService.canCreatePrivate( currentUserService.getCurrentUser(), identifiableObject.getClass() ) )
             {
                 identifiableObject.setPublicAccess( AccessStringHelper.newInstance().build() );
             }
@@ -400,8 +400,8 @@
 
     protected boolean sharingEnabled()
     {
-        boolean enabled = forceAcl() || (sharingService.isSupported( clazz ) && !(currentUserService.getCurrentUser() == null ||
-            CollectionUtils.containsAny( currentUserService.getCurrentUser().getUserCredentials().getAllAuthorities(), SharingService.SHARING_OVERRIDE_AUTHORITIES )));
+        boolean enabled = forceAcl() || (accessControlService.isSupported( clazz ) && !(currentUserService.getCurrentUser() == null ||
+            CollectionUtils.containsAny( currentUserService.getCurrentUser().getUserCredentials().getAllAuthorities(), AccessControlService.SHARING_OVERRIDE_AUTHORITIES )));
 
         return enabled;
     }
@@ -414,7 +414,7 @@
 
             if ( sharingEnabled() )
             {
-                return sharingService.canRead( currentUserService.getCurrentUser(), idObject );
+                return accessControlService.canRead( currentUserService.getCurrentUser(), idObject );
             }
         }
 
@@ -429,7 +429,7 @@
 
             if ( sharingEnabled() )
             {
-                return sharingService.canWrite( currentUserService.getCurrentUser(), idObject );
+                return accessControlService.canWrite( currentUserService.getCurrentUser(), idObject );
             }
         }
 
@@ -442,9 +442,9 @@
         {
             IdentifiableObject idObject = (IdentifiableObject) object;
 
-            if ( sharingService.isSupported( clazz ) )
+            if ( accessControlService.isSupported( clazz ) )
             {
-                return sharingService.canUpdate( currentUserService.getCurrentUser(), idObject );
+                return accessControlService.canUpdate( currentUserService.getCurrentUser(), idObject );
             }
         }
 
@@ -457,9 +457,9 @@
         {
             IdentifiableObject idObject = (IdentifiableObject) object;
 
-            if ( sharingService.isSupported( clazz ) )
+            if ( accessControlService.isSupported( clazz ) )
             {
-                return sharingService.canDelete( currentUserService.getCurrentUser(), idObject );
+                return accessControlService.canDelete( currentUserService.getCurrentUser(), idObject );
             }
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java	2014-03-26 18:17:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java	2014-03-27 04:38:53 +0000
@@ -52,7 +52,7 @@
 import org.hisp.dhis.schema.Schema;
 import org.hisp.dhis.schema.SchemaService;
 import org.hisp.dhis.sharing.Access;
-import org.hisp.dhis.sharing.SharingService;
+import org.hisp.dhis.sharing.AccessControlService;
 import org.hisp.dhis.system.util.ReflectionUtils;
 import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -89,7 +89,7 @@
     protected FilterService filterService;
 
     @Autowired
-    protected SharingService sharingService;
+    protected AccessControlService accessControlService;
 
     @Autowired
     protected SchemaService schemaService;
@@ -233,7 +233,7 @@
             WebUtils.generateLinks( entity );
         }
 
-        if ( sharingService.isSupported( getEntityClass() ) )
+        if ( accessControlService.isSupported( getEntityClass() ) )
         {
             addAccessProperties( entity );
         }
@@ -372,12 +372,12 @@
     protected void addAccessProperties( T object )
     {
         Access access = new Access();
-        access.setManage( sharingService.canManage( currentUserService.getCurrentUser(), object ) );
-        access.setExternalize( sharingService.canExternalize( currentUserService.getCurrentUser(), object.getClass() ) );
-        access.setWrite( sharingService.canWrite( currentUserService.getCurrentUser(), object ) );
-        access.setRead( sharingService.canRead( currentUserService.getCurrentUser(), object ) );
-        access.setUpdate( sharingService.canUpdate( currentUserService.getCurrentUser(), object ) );
-        access.setDelete( sharingService.canDelete( currentUserService.getCurrentUser(), object ) );
+        access.setManage( accessControlService.canManage( currentUserService.getCurrentUser(), object ) );
+        access.setExternalize( accessControlService.canExternalize( currentUserService.getCurrentUser(), object.getClass() ) );
+        access.setWrite( accessControlService.canWrite( currentUserService.getCurrentUser(), object ) );
+        access.setRead( accessControlService.canRead( currentUserService.getCurrentUser(), object ) );
+        access.setUpdate( accessControlService.canUpdate( currentUserService.getCurrentUser(), object ) );
+        access.setDelete( accessControlService.canDelete( currentUserService.getCurrentUser(), object ) );
 
         ((BaseIdentifiableObject) object).setAccess( access );
     }
@@ -394,7 +394,7 @@
             return;
         }
 
-        if ( entityList != null && sharingService.isSupported( getEntityClass() ) )
+        if ( entityList != null && accessControlService.isSupported( getEntityClass() ) )
         {
             for ( T object : entityList )
             {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java	2014-03-21 11:57:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SharingController.java	2014-03-27 04:38:53 +0000
@@ -38,8 +38,8 @@
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.IdentifiableObjectManager;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.sharing.AccessControlService;
 import org.hisp.dhis.sharing.AccessStringHelper;
-import org.hisp.dhis.sharing.SharingService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.UserGroup;
 import org.hisp.dhis.user.UserGroupAccess;
@@ -81,18 +81,18 @@
     private UserGroupAccessService userGroupAccessService;
 
     @Autowired
-    private SharingService sharingService;
+    private AccessControlService accessControlService;
 
     @RequestMapping( value = "", produces = { "application/json", "text/*" } )
     public void getSharing( @RequestParam String type, @RequestParam String id, HttpServletResponse response ) throws IOException
     {
-        if ( !sharingService.isSupported( type ) )
+        if ( !accessControlService.isSupported( type ) )
         {
             ContextUtils.notFoundResponse( response, "Type " + type + " is not supported." );
             return;
         }
 
-        Class<? extends IdentifiableObject> klass = sharingService.classForType( type );
+        Class<? extends IdentifiableObject> klass = accessControlService.classForType( type );
         IdentifiableObject object = manager.get( klass, id );
 
         if ( object == null )
@@ -101,15 +101,15 @@
             return;
         }
 
-        if ( !sharingService.canManage( currentUserService.getCurrentUser(), object ) )
+        if ( !accessControlService.canManage( currentUserService.getCurrentUser(), object ) )
         {
             throw new AccessDeniedException( "You do not have manage access to this object." );
         }
 
         Sharing sharing = new Sharing();
 
-        sharing.getMeta().setAllowPublicAccess( sharingService.canCreatePublic( currentUserService.getCurrentUser(), object.getClass() ) );
-        sharing.getMeta().setAllowExternalAccess( sharingService.canExternalize( currentUserService.getCurrentUser(), object.getClass() ) );
+        sharing.getMeta().setAllowPublicAccess( accessControlService.canCreatePublic( currentUserService.getCurrentUser(), object.getClass() ) );
+        sharing.getMeta().setAllowExternalAccess( accessControlService.canExternalize( currentUserService.getCurrentUser(), object.getClass() ) );
 
         sharing.getObject().setId( object.getUid() );
         sharing.getObject().setName( object.getDisplayName() );
@@ -119,7 +119,7 @@
         {
             String access;
 
-            if ( sharingService.canCreatePublic( currentUserService.getCurrentUser(), klass ) )
+            if ( accessControlService.canCreatePublic( currentUserService.getCurrentUser(), klass ) )
             {
                 access = AccessStringHelper.newInstance().enable( AccessStringHelper.Permission.READ ).enable( AccessStringHelper.Permission.WRITE ).build();
             }
@@ -157,7 +157,7 @@
     @RequestMapping( value = "", method = { RequestMethod.POST, RequestMethod.PUT }, consumes = "application/json" )
     public void setSharing( @RequestParam String type, @RequestParam String id, HttpServletResponse response, HttpServletRequest request ) throws IOException
     {
-        BaseIdentifiableObject object = (BaseIdentifiableObject) manager.get( sharingService.classForType( type ), id );
+        BaseIdentifiableObject object = (BaseIdentifiableObject) manager.get( accessControlService.classForType( type ), id );
 
         if ( object == null )
         {
@@ -165,7 +165,7 @@
             return;
         }
 
-        if ( !sharingService.canManage( currentUserService.getCurrentUser(), object ) )
+        if ( !accessControlService.canManage( currentUserService.getCurrentUser(), object ) )
         {
             throw new AccessDeniedException( "You do not have manage access to this object." );
         }
@@ -173,13 +173,13 @@
         Sharing sharing = JacksonUtils.fromJson( request.getInputStream(), Sharing.class );
 
         // Ignore externalAccess if user is not allowed to make objects external
-        if ( sharingService.canExternalize( currentUserService.getCurrentUser(), object.getClass() ) )
+        if ( accessControlService.canExternalize( currentUserService.getCurrentUser(), object.getClass() ) )
         {
             object.setExternalAccess( sharing.getObject().hasExternalAccess() );
         }
 
         // Ignore publicAccess if user is not allowed to make objects public
-        if ( sharingService.canCreatePublic( currentUserService.getCurrentUser(), object.getClass() ) )
+        if ( accessControlService.canCreatePublic( currentUserService.getCurrentUser(), object.getClass() ) )
         {
             object.setPublicAccess( sharing.getObject().getPublicAccess() );
         }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2014-03-21 12:20:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2014-03-27 04:38:53 +0000
@@ -44,7 +44,7 @@
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.organisationunit.OrganisationUnitDataSetAssociationSet;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.sharing.SharingService;
+import org.hisp.dhis.sharing.AccessControlService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -117,7 +117,7 @@
     }
 
     @Autowired
-    protected SharingService sharingService;
+    protected AccessControlService accessControlService;
 
     // -------------------------------------------------------------------------
     // Output
@@ -272,7 +272,7 @@
         {
             for ( DataElementCategoryOption categoryOption : category.getCategoryOptions() )
             {
-                if ( sharingService.canRead( user, categoryOption ) )
+                if ( accessControlService.canRead( user, categoryOption ) )
                 {
                     categoryOptionMap.putValue( category.getUid(), categoryOption );
                 }