← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9431: expose securityService in velocity templates as

 

------------------------------------------------------------
revno: 9431
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-01-03 14:11:54 +0100
message:
  expose securityService in velocity templates as 
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/intercept/XWorkSecurityInterceptor.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml


--
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
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/intercept/XWorkSecurityInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/intercept/XWorkSecurityInterceptor.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/security/intercept/XWorkSecurityInterceptor.java	2013-01-03 13:11:54 +0000
@@ -27,18 +27,18 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.HashMap;
-import java.util.Map;
-
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.interceptor.Interceptor;
 import org.hisp.dhis.security.ActionAccessResolver;
+import org.hisp.dhis.security.SecurityService;
 import org.hisp.dhis.security.authority.RequiredAuthoritiesProvider;
 import org.springframework.security.access.SecurityMetadataSource;
 import org.springframework.security.access.intercept.AbstractSecurityInterceptor;
 import org.springframework.security.access.intercept.InterceptorStatusToken;
 
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.config.entities.ActionConfig;
-import com.opensymphony.xwork2.interceptor.Interceptor;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * @author Torgeir Lorange Ostby
@@ -55,6 +55,8 @@
 
     private static final String KEY_ACTION_ACCESS_RESOLVER = "auth";
 
+    private static final String KEY_SECURITY_SERVICE = "security";
+
     private ThreadLocal<SecurityMetadataSource> definitionSourceTag = new ThreadLocal<SecurityMetadataSource>();
 
     // -------------------------------------------------------------------------
@@ -75,6 +77,13 @@
         this.actionAccessResolver = actionAccessResolver;
     }
 
+    private SecurityService securityService;
+
+    public void setSecurityService( SecurityService securityService )
+    {
+        this.securityService = securityService;
+    }
+
     // -------------------------------------------------------------------------
     // WebWork Interceptor
     // -------------------------------------------------------------------------
@@ -152,7 +161,10 @@
     private void addActionAccessResolver( ActionInvocation invocation )
     {
         Map<String, Object> accessResolverMap = new HashMap<String, Object>( 1 );
+
         accessResolverMap.put( KEY_ACTION_ACCESS_RESOLVER, actionAccessResolver );
+        accessResolverMap.put( KEY_SECURITY_SERVICE, securityService );
+
         invocation.getStack().push( accessResolverMap );
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml	2012-12-14 13:46:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/security.xml	2013-01-03 13:11:54 +0000
@@ -174,6 +174,7 @@
     <property name="validateConfigAttributes" value="false" />
     <property name="requiredAuthoritiesProvider" ref="org.hisp.dhis.security.authority.RequiredAuthoritiesProvider" />
     <property name="actionAccessResolver" ref="org.hisp.dhis.security.ActionAccessResolver" />
+    <property name="securityService" ref="org.hisp.dhis.security.SecurityService" />
   </bean>
 
   <!-- Security : AuthorityProvider -->