Fix Remote RCP not working
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 19 Mar 2013 17:48:06 +0000 (17:48 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 19 Mar 2013 17:48:06 +0000 (17:48 +0000)
https://www.argeo.org/bugzilla/show_bug.cgi?id=148

git-svn-id: https://svn.argeo.org/commons/trunk@6175 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

demo/argeo_node_rcp_remote.properties
security/modules/org.argeo.security.dao.jackrabbit/META-INF/spring/repofactory.xml [new file with mode: 0644]
security/modules/org.argeo.security.dao.jackrabbit/META-INF/spring/security-jcr-osgi.xml
security/plugins/org.argeo.security.ui/plugin.xml
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/jcr/RemoteJcrAuthenticationProvider.java
security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/jcr/SimpleJcrSecurityModel.java

index 171de44e8490abfe8586b89f1c24c1ed134794c8..1a6dfba67e6aa5d0a2c4d77aee4eca8df0f057ab 100644 (file)
@@ -5,7 +5,7 @@ org.argeo.security.dao.jackrabbit,\
 org.argeo.security.equinox,\
 
 #org.argeo.security.ui.initialPerspective=org.argeo.osgi.ui.explorer.perspective
-argeo.node.repo.uri=http://localhost:7070/org.argeo.jcr.webapp/remoting/node
+argeo.node.repo.uri=http://localhost:7070/data/jcr/node
 
 log4j.configuration=file:../../log4j.properties
 
diff --git a/security/modules/org.argeo.security.dao.jackrabbit/META-INF/spring/repofactory.xml b/security/modules/org.argeo.security.dao.jackrabbit/META-INF/spring/repofactory.xml
new file mode 100644 (file)
index 0000000..a00c9b0
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+       <bean id="repositoryFactory" class="org.argeo.jackrabbit.OsgiJackrabbitRepositoryFactory">
+               <property name="bundleContext" ref="bundleContext" />
+       </bean>
+
+</beans>
\ No newline at end of file
index de60f22ea2165fd650ae2f7296ff3a4e9e18a4f9..7ce6f05521affc44f6d549c5da774bfece8b3ff7 100644 (file)
@@ -9,11 +9,10 @@
        http://www.springframework.org/schema/util\r
        http://www.springframework.org/schema/util/spring-util-2.5.xsd">\r
 \r
-       <!-- REFERENCE -->\r
-       <reference id="repositoryFactory" interface="javax.jcr.RepositoryFactory" />\r
-\r
        <!-- SERVICES -->\r
        <service ref="authenticationManager"\r
                interface="org.springframework.security.AuthenticationManager" />\r
 \r
+       <service ref="repositoryFactory" interface="javax.jcr.RepositoryFactory" />\r
+\r
 </beans:beans>
\ No newline at end of file
index b21c138087df98c9ce1fd2cdfe9901c5c272a9f8..cb139d7b687744f8db9b224bff352231ffddbee5 100644 (file)
@@ -75,7 +75,7 @@
         <activity
               description="Non admins"
               id="org.argeo.security.ui.notAdminActivity"
-              name="Admin">
+              name="Not Admin">
                  <enabledWhen>
                        <not>
                    <with variable="roles">
                        </not>
                  </enabledWhen>
         </activity>
+        <activity
+              description="Non remote"
+              id="org.argeo.security.ui.notRemoteActivity"
+              name="NonRemote">
+                 <enabledWhen>
+                       <not>
+                   <with variable="roles">
+                     <iterate ifEmpty="false" operator="or">
+                       <equals value="ROLE_REMOTE" />
+                     </iterate>
+                   </with>
+                       </not>
+                 </enabledWhen>
+        </activity>
         <activityPatternBinding
               activityId="org.argeo.security.ui.adminActivity"
               isEqualityPattern="true"
index a7cf268ad21227e62a1195d60c88e3a3da1b7e1f..b32ba8ea9ab25d5cd49f5469e3971a2a1b9c9f2c 100644 (file)
@@ -46,6 +46,8 @@ public class RemoteJcrAuthenticationProvider implements AuthenticationProvider,
        private RepositoryFactory repositoryFactory;
        private BundleContext bundleContext;
 
+       public final static String ROLE_REMOTE = "ROLE_REMOTE";
+
        public Authentication authenticate(Authentication authentication)
                        throws AuthenticationException {
                NodeAuthenticationToken siteAuth = (NodeAuthenticationToken) authentication;
@@ -95,17 +97,18 @@ public class RemoteJcrAuthenticationProvider implements AuthenticationProvider,
                }
 
                try {
-                       Node userHome = UserJcrUtils.getUserHome(session);
+                       // Node userHome = UserJcrUtils.getUserHome(session);
                        // retrieve remote roles
                        List<GrantedAuthority> authoritiesList = new ArrayList<GrantedAuthority>();
-                       if (userHome != null
-                                       && userHome.hasProperty(ArgeoNames.ARGEO_REMOTE_ROLES)) {
-                               Value[] roles = userHome.getProperty(
+                       if (userProfile != null
+                                       && userProfile.hasProperty(ArgeoNames.ARGEO_REMOTE_ROLES)) {
+                               Value[] roles = userProfile.getProperty(
                                                ArgeoNames.ARGEO_REMOTE_ROLES).getValues();
                                for (int i = 0; i < roles.length; i++)
                                        authoritiesList.add(new GrantedAuthorityImpl(roles[i]
                                                        .getString()));
                        }
+                       authoritiesList.add(new GrantedAuthorityImpl(ROLE_REMOTE));
 
                        // create authenticated objects
                        GrantedAuthority[] authorities = authoritiesList
index b1c21b005f08baa2b8be958cc6f2de065a73f265..fc01587383c980a2acd6eb2fbe00769b5866cf6a 100644 (file)
@@ -102,6 +102,12 @@ public class SimpleJcrSecurityModel implements JcrSecurityModel {
                                                .getVersionManager();
                                if (versionManager.isCheckedOut(userProfile.getPath()))
                                        versionManager.checkin(userProfile.getPath());
+
+                       }
+
+                       // Remote roles
+                       if (roles != null) {
+                               writeRemoteRoles(userProfile, roles);
                        }
                        return userProfile;
                } catch (RepositoryException e) {