Fix Remote RCP not working
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.core / src / main / java / org / argeo / security / jcr / RemoteJcrAuthenticationProvider.java
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