You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2013/10/11 16:27:13 UTC

svn commit: r1531307 [1/2] - in /syncope/trunk: ./ archetype/src/main/resources/ archetype/src/main/resources/META-INF/maven/ archetype/src/test/resources/projects/default/ common/src/main/java/org/apache/syncope/common/ console/src/main/java/org/apach...

Author: ilgrosso
Date: Fri Oct 11 14:27:12 2013
New Revision: 1531307

URL: http://svn.apache.org/r1531307
Log:
[SYNCOPE-132] Introducing a special 'anonymous' user, with only fixed capabilities to perform self-registration via web console, distinct from actual unauthenticated user that cannot now access any REST resource

Modified:
    syncope/trunk/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
    syncope/trunk/archetype/src/main/resources/meta-pom.xml
    syncope/trunk/archetype/src/test/resources/projects/default/archetype.properties
    syncope/trunk/common/src/main/java/org/apache/syncope/common/SyncopeConstants.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeRequestCycleListener.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ResultStatusModalPage.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/UserRequestModalPage.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/WelcomePage.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/UserDetailsPanel.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java
    syncope/trunk/console/src/main/resources/applicationContext.xml
    syncope/trunk/console/src/main/resources/authorizations.xml
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication.properties
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication_it.properties
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication_pt_BR.properties
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/BasePage.html
    syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/WelcomePage.html
    syncope/trunk/console/src/test/java/org/apache/syncope/console/EditProfileTestITCase.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeUserValidator.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeUserDetailsService.java
    syncope/trunk/core/src/main/java/org/apache/syncope/core/util/EntitlementUtil.java
    syncope/trunk/core/src/main/resources/content.xml
    syncope/trunk/core/src/main/resources/security.properties
    syncope/trunk/core/src/main/resources/securityContext.xml
    syncope/trunk/core/src/main/resources/syncopeContext.xml
    syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/EntitlementTest.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java
    syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserRequestTestITCase.java
    syncope/trunk/core/src/test/resources/content.xml
    syncope/trunk/pom.xml

Modified: syncope/trunk/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml (original)
+++ syncope/trunk/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml Fri Oct 11 14:27:12 2013
@@ -22,6 +22,7 @@ under the License.
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <requiredProperties>
     <requiredProperty key="secretKey"/>
+    <requiredProperty key="anonymousKey"/>
   </requiredProperties>
   
   <modules>

Modified: syncope/trunk/archetype/src/main/resources/meta-pom.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/archetype/src/main/resources/meta-pom.xml?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/archetype/src/main/resources/meta-pom.xml (original)
+++ syncope/trunk/archetype/src/main/resources/meta-pom.xml Fri Oct 11 14:27:12 2013
@@ -34,6 +34,7 @@ under the License.
   <properties>
     <syncope.version></syncope.version>
     <secretKey>${secretKey}</secretKey>
+    <anonymousKey>${anonymousKey}</anonymousKey>
   </properties>
 
   <name>Apache Syncope sample project</name>

Modified: syncope/trunk/archetype/src/test/resources/projects/default/archetype.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/archetype/src/test/resources/projects/default/archetype.properties?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/archetype/src/test/resources/projects/default/archetype.properties (original)
+++ syncope/trunk/archetype/src/test/resources/projects/default/archetype.properties Fri Oct 11 14:27:12 2013
@@ -18,3 +18,4 @@ groupId=org.apache.syncope.test
 artifactId=syncope-test
 version=1.0-SNAPSHOT
 secretKey=testSecretKey
+anonymousKey=testAnonymousKey

Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/SyncopeConstants.java
URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/SyncopeConstants.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/common/src/main/java/org/apache/syncope/common/SyncopeConstants.java (original)
+++ syncope/trunk/common/src/main/java/org/apache/syncope/common/SyncopeConstants.java Fri Oct 11 14:27:12 2013
@@ -20,7 +20,9 @@ package org.apache.syncope.common;
 
 public class SyncopeConstants {
 
-    public static final String ANONYMOUS_USER = "anonymous";
+    public static final String UNAUTHENTICATED = "unauthenticated";
+
+    public static final String ANONYMOUS_ENTITLEMENT = "anonymous";
 
     public static final String ENUM_VALUES_SEPARATOR = ";";
 

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeApplication.java Fri Oct 11 14:27:12 2013
@@ -19,6 +19,7 @@
 package org.apache.syncope.console;
 
 import java.io.Serializable;
+import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.console.commons.Constants;
 import org.apache.syncope.console.commons.XMLRolesReader;
 import org.apache.syncope.console.pages.Configuration;
@@ -31,8 +32,11 @@ import org.apache.syncope.console.pages.
 import org.apache.syncope.console.pages.Schema;
 import org.apache.syncope.console.pages.Tasks;
 import org.apache.syncope.console.pages.Todo;
+import org.apache.syncope.console.pages.UserModalPage;
+import org.apache.syncope.console.pages.UserRequestModalPage;
 import org.apache.syncope.console.pages.Users;
 import org.apache.syncope.console.pages.WelcomePage;
+import org.apache.syncope.console.rest.UserRestClient;
 import org.apache.wicket.Component;
 import org.apache.wicket.Page;
 import org.apache.wicket.RestartResponseAtInterceptPageException;
@@ -46,6 +50,7 @@ import org.apache.wicket.authroles.autho
 import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
 import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
 import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.image.Image;
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;
 import org.apache.wicket.protocol.http.WebApplication;
@@ -61,11 +66,15 @@ public class SyncopeApplication
         extends WebApplication
         implements IUnauthorizedComponentInstantiationListener, IRoleCheckingStrategy, Serializable {
 
+    private static final long serialVersionUID = -2920378752291913495L;
+
     public static final String IMG_PREFIX = "/img/menu/";
 
     public static final String IMG_NOTSEL = "notsel/";
 
-    private static final long serialVersionUID = -2920378752291913495L;
+    private final static int EDIT_PROFILE_WIN_HEIGHT = 550;
+
+    private final static int EDIT_PROFILE_WIN_WIDTH = 800;
 
     @Override
     protected void init() {
@@ -113,45 +122,48 @@ public class SyncopeApplication
         page.add(infoLink);
 
         BookmarkablePageLink<Void> schemaLink = new BookmarkablePageLink<Void>("schema", Schema.class);
-        MetaDataRoleAuthorizationStrategy.authorizeAll(schemaLink, WebPage.ENABLE);
+        MetaDataRoleAuthorizationStrategy.authorize(
+                schemaLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Schema", "list"));
         page.add(schemaLink);
         schemaLink.add(new Image("schemaIcon", new ContextRelativeResource(IMG_PREFIX + (notsel
                 ? IMG_NOTSEL
                 : "") + "schema" + Constants.PNG_EXT)));
 
         BookmarkablePageLink<Void> usersLink = new BookmarkablePageLink<Void>("users", Users.class);
-        String allowedUsersRoles = xmlRolesReader.getAllAllowedRoles("Users", "list");
-        MetaDataRoleAuthorizationStrategy.authorize(usersLink, WebPage.ENABLE, allowedUsersRoles);
+        MetaDataRoleAuthorizationStrategy.authorize(
+                usersLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Users", "list"));
         page.add(usersLink);
         usersLink.add(new Image("usersIcon", new ContextRelativeResource(IMG_PREFIX + (notsel
                 ? IMG_NOTSEL
                 : "") + "users" + Constants.PNG_EXT)));
 
         BookmarkablePageLink<Void> rolesLink = new BookmarkablePageLink<Void>("roles", Roles.class);
-        MetaDataRoleAuthorizationStrategy.authorizeAll(rolesLink, WebPage.ENABLE);
+        MetaDataRoleAuthorizationStrategy.authorize(
+                rolesLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Roles", "list"));
         page.add(rolesLink);
         rolesLink.add(new Image("rolesIcon", new ContextRelativeResource(IMG_PREFIX + (notsel
                 ? IMG_NOTSEL
                 : "") + "roles" + Constants.PNG_EXT)));
 
         BookmarkablePageLink<Void> resourcesLink = new BookmarkablePageLink<Void>("resources", Resources.class);
-        MetaDataRoleAuthorizationStrategy.authorizeAll(resourcesLink, WebPage.ENABLE);
+        MetaDataRoleAuthorizationStrategy.authorize(
+                resourcesLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Resources", "list"));
         page.add(resourcesLink);
         resourcesLink.add(new Image("resourcesIcon", new ContextRelativeResource(IMG_PREFIX + (notsel
                 ? IMG_NOTSEL
                 : "") + "resources" + Constants.PNG_EXT)));
 
         BookmarkablePageLink<Void> todoLink = new BookmarkablePageLink<Void>("todo", Todo.class);
-        MetaDataRoleAuthorizationStrategy.authorize(todoLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles(
-                "Approval", "list"));
+        MetaDataRoleAuthorizationStrategy.authorize(
+                todoLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Approval", "list"));
         page.add(todoLink);
         todoLink.add(new Image("todoIcon", new ContextRelativeResource(IMG_PREFIX + (notsel
                 ? IMG_NOTSEL
                 : "") + "todo" + Constants.PNG_EXT)));
 
         BookmarkablePageLink<Void> reportLink = new BookmarkablePageLink<Void>("reports", Reports.class);
-        String allowedReportRoles = xmlRolesReader.getAllAllowedRoles("Reports", "list");
-        MetaDataRoleAuthorizationStrategy.authorize(reportLink, WebPage.ENABLE, allowedReportRoles);
+        MetaDataRoleAuthorizationStrategy.authorize(
+                reportLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Reports", "list"));
         page.add(reportLink);
         reportLink.add(new Image("reportsIcon", new ContextRelativeResource(IMG_PREFIX + (notsel
                 ? IMG_NOTSEL
@@ -159,16 +171,16 @@ public class SyncopeApplication
 
         BookmarkablePageLink<Void> configurationLink = new BookmarkablePageLink<Void>("configuration",
                 Configuration.class);
-        String allowedConfigurationRoles = xmlRolesReader.getAllAllowedRoles("Configuration", "list");
-        MetaDataRoleAuthorizationStrategy.authorize(configurationLink, WebPage.ENABLE, allowedConfigurationRoles);
+        MetaDataRoleAuthorizationStrategy.authorize(
+                configurationLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Configuration", "list"));
         page.add(configurationLink);
         configurationLink.add(new Image("configurationIcon", new ContextRelativeResource(IMG_PREFIX + (notsel
                 ? IMG_NOTSEL
                 : "") + "configuration" + Constants.PNG_EXT)));
 
         BookmarkablePageLink<Void> taskLink = new BookmarkablePageLink<Void>("tasks", Tasks.class);
-        String allowedTasksRoles = xmlRolesReader.getAllAllowedRoles("Tasks", "list");
-        MetaDataRoleAuthorizationStrategy.authorize(taskLink, WebPage.ENABLE, allowedTasksRoles);
+        MetaDataRoleAuthorizationStrategy.authorize(
+                taskLink, WebPage.ENABLE, xmlRolesReader.getAllAllowedRoles("Tasks", "list"));
         page.add(taskLink);
         taskLink.add(new Image("tasksIcon", new ContextRelativeResource(IMG_PREFIX + (notsel
                 ? IMG_NOTSEL
@@ -177,6 +189,49 @@ public class SyncopeApplication
         page.add(new BookmarkablePageLink<Void>("logout", Logout.class));
     }
 
+    public void setupEditProfileModal(final WebPage page, final UserRestClient userRestClient) {
+        // Modal window for editing user profile
+        final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal");
+        editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
+        editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT);
+        editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH);
+        editProfileModalWin.setCookieName("edit-profile-modal");
+        page.add(editProfileModalWin);
+
+        final AjaxLink<Void> editProfileLink = new AjaxLink<Void>("editProfileLink") {
+
+            private static final long serialVersionUID = -7978723352517770644L;
+
+            @Override
+            public void onClick(final AjaxRequestTarget target) {
+                final UserTO userTO = SyncopeSession.get().isAuthenticated()
+                        ? userRestClient.readSelf()
+                        : new UserTO();
+
+                editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {
+
+                    private static final long serialVersionUID = -7834632442532690940L;
+
+                    @Override
+                    public Page createPage() {
+                        return new UserRequestModalPage(page.getPageReference(), editProfileModalWin,
+                                userTO, UserModalPage.Mode.SELF);
+                    }
+                });
+
+                editProfileModalWin.show(target);
+            }
+        };
+
+        editProfileLink.add(new Label("username", SyncopeSession.get().getUsername()));
+
+        if ("admin".equals(SyncopeSession.get().getUsername())) {
+            editProfileLink.setEnabled(false);
+        }
+
+        page.add(editProfileLink);
+    }
+
     @Override
     public Session newSession(final Request request, final Response response) {
         return new SyncopeSession(request);

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeRequestCycleListener.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeRequestCycleListener.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeRequestCycleListener.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeRequestCycleListener.java Fri Oct 11 14:27:12 2013
@@ -18,6 +18,10 @@
  */
 package org.apache.syncope.console;
 
+import java.security.AccessControlException;
+import javax.ws.rs.BadRequestException;
+import javax.xml.ws.WebServiceException;
+import org.apache.syncope.common.validation.SyncopeClientCompositeException;
 import org.apache.syncope.console.pages.ErrorPage;
 import org.apache.wicket.Page;
 import org.apache.wicket.authorization.UnauthorizedInstantiationException;
@@ -31,8 +35,6 @@ import org.apache.wicket.request.cycle.R
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.web.client.HttpClientErrorException;
-import org.springframework.web.client.RestClientException;
 
 public class SyncopeRequestCycleListener extends AbstractRequestCycleListener {
 
@@ -46,7 +48,6 @@ public class SyncopeRequestCycleListener
      */
     @Override
     public IRequestHandler onException(final RequestCycle cycle, final Exception e) {
-
         LOG.error("Exception found", e);
 
         final Page errorPage;
@@ -54,21 +55,20 @@ public class SyncopeRequestCycleListener
         errorParameters.add("errorTitle", new StringResourceModel("alert", null).getString());
 
         if (e instanceof UnauthorizedInstantiationException) {
-            errorParameters.add("errorMessage", new StringResourceModel("unauthorizedInstantiationException", null)
-                    .getString());
+            errorParameters.add("errorMessage",
+                    new StringResourceModel("unauthorizedInstantiationException", null).getString());
 
             errorPage = new ErrorPage(errorParameters);
-        } else if (e instanceof HttpClientErrorException) {
-            errorParameters.add("errorMessage", new StringResourceModel("httpClientException", null).getString());
+        } else if (e.getCause() instanceof AccessControlException) {
+            errorParameters.add("errorMessage", new StringResourceModel("accessControlException", null).getString());
 
             errorPage = new ErrorPage(errorParameters);
         } else if (e instanceof PageExpiredException || !(SyncopeSession.get()).isAuthenticated()) {
-
             errorParameters.add("errorMessage", new StringResourceModel("pageExpiredException", null).getString());
 
             errorPage = new ErrorPage(errorParameters);
-        } else if (e.getCause() != null && e.getCause().getCause() != null
-                && e.getCause().getCause() instanceof RestClientException) {
+        } else if (e.getCause() instanceof BadRequestException || e.getCause() instanceof WebServiceException
+                || e.getCause() instanceof SyncopeClientCompositeException) {
 
             errorParameters.add("errorMessage", new StringResourceModel("restClientException", null).getString());
 

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java Fri Oct 11 14:27:12 2013
@@ -24,7 +24,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.syncope.client.SyncopeClient;
 import org.apache.syncope.client.SyncopeClientFactoryBean;
 import org.apache.wicket.Session;
 import org.apache.wicket.authroles.authorization.strategies.role.Roles;
@@ -54,7 +55,7 @@ public class SyncopeSession extends WebS
 
     private final SyncopeClientFactoryBean clientFactory;
 
-    private final Map<Class<?>, Object> restServices = new HashMap<Class<?>, Object>();
+    private final Map<Integer, SyncopeClient> clients = new HashMap<Integer, SyncopeClient>();
 
     public static SyncopeSession get() {
         return (SyncopeSession) Session.get();
@@ -73,19 +74,17 @@ public class SyncopeSession extends WebS
         return getService(service, this.username, this.password);
     }
 
-    @SuppressWarnings("unchecked")
     public <T> T getService(final Class<T> serviceClass, final String username, final String password) {
-        T res;
-        if (restServices.containsKey(serviceClass)) {
-            res = (T) restServices.get(serviceClass);
-        } else {
-            res = clientFactory.create(username, password).getService(serviceClass);
-            if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
-                restServices.put(serviceClass, res);
-            }
+        final int clientKey = new HashCodeBuilder().
+                append(username).
+                append(password).
+                toHashCode();
+
+        if (!clients.containsKey(clientKey)) {
+            clients.put(clientKey, clientFactory.create(username, password));
         }
 
-        return res;
+        return clients.get(clientKey).getService(serviceClass);
     }
 
     public String getUsername() {

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java Fri Oct 11 14:27:12 2013
@@ -18,22 +18,17 @@
  */
 package org.apache.syncope.console.pages;
 
-import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.console.SyncopeApplication;
-import org.apache.syncope.console.SyncopeSession;
 import org.apache.syncope.console.commons.Constants;
 import org.apache.wicket.Component;
-import org.apache.wicket.Page;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.IAjaxIndicatorAware;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
 import org.apache.wicket.behavior.Behavior;
 import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.head.IHeaderResponse;
 import org.apache.wicket.markup.head.PriorityHeaderItem;
 import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 
@@ -44,10 +39,6 @@ public class BasePage extends AbstractBa
 
     private static final long serialVersionUID = 1571997737305598502L;
 
-    private final static int EDIT_PROFILE_WIN_HEIGHT = 550;
-
-    private final static int EDIT_PROFILE_WIN_WIDTH = 800;
-
     public BasePage() {
         super();
 
@@ -72,7 +63,6 @@ public class BasePage extends AbstractBa
 
                 @Override
                 public void onComponentTag(final Component component, final ComponentTag tag) {
-
                     tag.put("class", kind);
                 }
             });
@@ -85,53 +75,13 @@ public class BasePage extends AbstractBa
 
                     @Override
                     public void onComponentTag(final Component component, final ComponentTag tag) {
-
                         tag.put("src", "../.." + SyncopeApplication.IMG_PREFIX + kind + Constants.PNG_EXT);
                     }
                 });
             }
         }
 
-        // Modal window for editing user profile
-        final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal");
-        editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
-        editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT);
-        editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH);
-        editProfileModalWin.setCookieName("edit-profile-modal");
-        add(editProfileModalWin);
-
-        final AjaxLink editProfileLink = new AjaxLink("editProfileLink") {
-
-            private static final long serialVersionUID = -7978723352517770644L;
-
-            @Override
-            public void onClick(final AjaxRequestTarget target) {
-                final UserTO userTO = SyncopeSession.get().isAuthenticated()
-                        ? userRestClient.readProfile()
-                        : new UserTO();
-
-                editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {
-
-                    private static final long serialVersionUID = -7834632442532690940L;
-
-                    @Override
-                    public Page createPage() {
-                        return new UserRequestModalPage(BasePage.this.getPageReference(), editProfileModalWin,
-                                userTO, UserModalPage.Mode.SELF);
-                    }
-                });
-
-                editProfileModalWin.show(target);
-            }
-        };
-
-        editProfileLink.add(new Label("username", SyncopeSession.get().getUsername()));
-
-        if ("admin".equals(SyncopeSession.get().getUsername())) {
-            editProfileLink.setEnabled(false);
-        }
-
-        add(editProfileLink);
+        ((SyncopeApplication) getApplication()).setupEditProfileModal(this, userRestClient);
     }
 
     @Override

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java Fri Oct 11 14:27:12 2013
@@ -77,6 +77,12 @@ public class Login extends WebPage {
     @SpringBean(name = "baseURL")
     private String baseURL;
 
+    @SpringBean(name = "anonymousUser")
+    private String anonymousUser;
+
+    @SpringBean(name = "anonymousKey")
+    private String anonymousKey;
+
     private Form<Void> form;
 
     private TextField<String> userIdField;
@@ -109,12 +115,11 @@ public class Login extends WebPage {
             @Override
             public void onSubmit() {
                 try {
-                    String[] entitlements = authenticate(userIdField.getRawInput(), passwordField.getRawInput());
+                    if (anonymousUser.equals(userIdField.getRawInput())) {
+                        throw new AccessControlException("Illegal username");
+                    }
 
-                    SyncopeSession.get().setUsername(userIdField.getRawInput());
-                    SyncopeSession.get().setPassword(passwordField.getRawInput());
-                    SyncopeSession.get().setEntitlements(entitlements);
-                    SyncopeSession.get().setVersion(getSyncopeVersion());
+                    authenticate(userIdField.getRawInput(), passwordField.getRawInput());
 
                     setResponsePage(WelcomePage.class, parameters);
                 } catch (AccessControlException e) {
@@ -153,11 +158,24 @@ public class Login extends WebPage {
 
                         @Override
                         public Page createPage() {
+                            // anonymous authentication needed for self-registration
+                            authenticate(anonymousUser, anonymousKey);
+
                             return new UserRequestModalPage(Login.this.getPageReference(), editProfileModalWin,
                                     new UserTO(), UserModalPage.Mode.SELF);
                         }
                     });
 
+                    editProfileModalWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
+
+                        private static final long serialVersionUID = 251794406325329768L;
+
+                        @Override
+                        public void onClose(final AjaxRequestTarget target) {
+                            SyncopeSession.get().invalidate();
+                        }
+                    });
+
                     editProfileModalWin.show(target);
                 }
             };
@@ -172,10 +190,14 @@ public class Login extends WebPage {
         add(selfRegFrag);
     }
 
-    private String[] authenticate(final String username, final String password) {
+    private void authenticate(final String username, final String password) {
         Set<EntitlementTO> entitlements = SyncopeSession.get().
                 getService(EntitlementService.class, username, password).getMyEntitlements();
-        return CollectionWrapper.unwrap(entitlements).toArray(new String[0]);
+
+        SyncopeSession.get().setUsername(username);
+        SyncopeSession.get().setPassword(password);
+        SyncopeSession.get().setEntitlements(CollectionWrapper.unwrap(entitlements).toArray(new String[0]));
+        SyncopeSession.get().setVersion(getSyncopeVersion());
     }
 
     private boolean isSelfRegistrationAllowed() {

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ResultStatusModalPage.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ResultStatusModalPage.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ResultStatusModalPage.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ResultStatusModalPage.java Fri Oct 11 14:27:12 2013
@@ -37,6 +37,7 @@ import org.apache.syncope.common.to.Prop
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.types.PropagationTaskExecStatus;
+import org.apache.syncope.console.SyncopeSession;
 import org.apache.syncope.console.commons.ConnIdSpecialAttributeName;
 import org.apache.syncope.console.commons.Constants;
 import org.apache.syncope.console.commons.StatusUtils;
@@ -55,6 +56,7 @@ import org.apache.wicket.markup.html.lis
 import org.apache.wicket.markup.html.list.ListView;
 import org.apache.wicket.markup.html.panel.Fragment;
 import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
 
 /**
  * Show user or role status after performing a successful operation.
@@ -65,6 +67,9 @@ public class ResultStatusModalPage exten
 
     private static final String IMG_STATUSES = "statuses/";
 
+    @SpringBean(name = "anonymousUser")
+    private String anonymousUser;
+
     private final AbstractAttributableTO attributable;
 
     private final UserModalPage.Mode mode;
@@ -227,7 +232,6 @@ public class ResultStatusModalPage exten
                     });
                     failureWindow.setCookieName("failureWindow");
                     failureWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
-                    //attrhead.add(image);
                     failureWindowLink.add(image);
                     attrhead.add(failureWindowLink);
                     attrhead.add(failureWindow);
@@ -242,6 +246,9 @@ public class ResultStatusModalPage exten
 
             @Override
             public void onClick(final AjaxRequestTarget target) {
+                if (mode == UserModalPage.Mode.SELF && anonymousUser.equals(SyncopeSession.get().getUsername())) {
+                    SyncopeSession.get().invalidate();
+                }
                 builder.window.close(target);
             }
         };

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/UserRequestModalPage.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/UserRequestModalPage.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/UserRequestModalPage.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/UserRequestModalPage.java Fri Oct 11 14:27:12 2013
@@ -37,7 +37,7 @@ public class UserRequestModalPage extend
     private static final long serialVersionUID = 603212869211672852L;
 
     @SpringBean
-    private UserRequestRestClient requestRestClient;
+    private UserRequestRestClient restClient;
 
     private UserTO initialUserTO;
 
@@ -83,11 +83,11 @@ public class UserRequestModalPage extend
         if (updatedUserTO.getId() == 0) {
             switch (mode) {
                 case SELF:
-                    requestRestClient.requestCreate(updatedUserTO);
+                    restClient.requestCreate(updatedUserTO);
                     break;
 
                 case ADMIN:
-                    requestRestClient.executeCreate(userRequestTO.getId(), userTO);
+                    restClient.executeCreate(userRequestTO.getId(), userTO);
                     break;
 
                 default:
@@ -95,7 +95,7 @@ public class UserRequestModalPage extend
             }
         } else {
             final UserTO originalUserTO = mode == Mode.SELF
-                    ? userRestClient.read(updatedUserTO.getUsername())
+                    ? userRestClient.readSelf()
                     : userRestClient.read(updatedUserTO.getId());
             final UserMod userMod = AttributableOperations.diff(updatedUserTO, originalUserTO);
 
@@ -103,11 +103,11 @@ public class UserRequestModalPage extend
             if (!userMod.isEmpty()) {
                 switch (mode) {
                     case SELF:
-                        requestRestClient.requestUpdate(userMod);
+                        restClient.requestUpdate(userMod);
                         break;
 
                     case ADMIN:
-                        requestRestClient.executeUpdate(userRequestTO.getId(), userMod);
+                        restClient.executeUpdate(userRequestTO.getId(), userMod);
                         break;
 
                     default:

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/WelcomePage.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/WelcomePage.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/WelcomePage.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/WelcomePage.java Fri Oct 11 14:27:12 2013
@@ -20,6 +20,7 @@ package org.apache.syncope.console.pages
 
 import org.apache.syncope.console.SyncopeApplication;
 import org.apache.syncope.console.commons.XMLRolesReader;
+import org.apache.syncope.console.rest.UserRestClient;
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.spring.injection.annot.SpringBean;
@@ -34,15 +35,21 @@ public class WelcomePage extends WebPage
     @SpringBean
     private XMLRolesReader xmlRolesReader;
 
+    @SpringBean
+    protected UserRestClient userRestClient;
+
     public WelcomePage(final PageParameters parameters) {
         super(parameters);
         setupNavigationPanel();
-
-
+        setupEditProfileModal();
     }
 
     //To prevent warning: "leaking this in constructor java" 
     private void setupNavigationPanel() {
         ((SyncopeApplication) getApplication()).setupNavigationPanel(this, xmlRolesReader, false);
     }
+
+    private void setupEditProfileModal() {
+        ((SyncopeApplication) getApplication()).setupEditProfileModal(this, userRestClient);
+    }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/UserDetailsPanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/UserDetailsPanel.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/UserDetailsPanel.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/UserDetailsPanel.java Fri Oct 11 14:27:12 2013
@@ -68,16 +68,15 @@ public class UserDetailsPanel extends Pa
         // ------------------------
         // Password
         // ------------------------
-        FieldPanel<String> password;
-        Label confirmPasswordLabel = new Label("confirmPasswordLabel", new ResourceModel("confirmPassword"));
-        FieldPanel<String> confirmPassword;
-
         final WebMarkupContainer pwdJexlHelp = JexlHelpUtil.getJexlHelpWebContainer("pwdJexlHelp");
         add(pwdJexlHelp);
 
         final AjaxLink<?> pwdQuestionMarkJexlHelp = JexlHelpUtil.getAjaxLink(pwdJexlHelp, "pwdQuestionMarkJexlHelp");
         add(pwdQuestionMarkJexlHelp);
 
+        FieldPanel<String> password;
+        Label confirmPasswordLabel = new Label("confirmPasswordLabel", new ResourceModel("confirmPassword"));
+        FieldPanel<String> confirmPassword;
         if (templateMode) {
             password = new AjaxTextFieldPanel("password", "password", new PropertyModel<String>(userTO, "password"));
 

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/UserRestClient.java Fri Oct 11 14:27:12 2013
@@ -94,7 +94,7 @@ public class UserRestClient extends Abst
         return userTO;
     }
 
-    public UserTO readProfile() {
+    public UserTO readSelf() {
         return getService(UserService.class).readSelf();
     }
 

Modified: syncope/trunk/console/src/main/resources/applicationContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/applicationContext.xml?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/applicationContext.xml (original)
+++ syncope/trunk/console/src/main/resources/applicationContext.xml Fri Oct 11 14:27:12 2013
@@ -55,6 +55,13 @@ under the License.
   <bean id="license" class="java.lang.String">
     <constructor-arg value="${licenseUrl}"/>
   </bean>
+  
+  <bean id="anonymousUser" class="java.lang.String">
+    <constructor-arg value="${anonymousUser}"/>
+  </bean>
+  <bean id="anonymousKey" class="java.lang.String">
+    <constructor-arg value="${anonymousKey}"/>
+  </bean>
 
   <bean id="syncopeApplication" class="org.apache.syncope.console.SyncopeApplication"/>
 

Modified: syncope/trunk/console/src/main/resources/authorizations.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/authorizations.xml?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/authorizations.xml (original)
+++ syncope/trunk/console/src/main/resources/authorizations.xml Fri Oct 11 14:27:12 2013
@@ -16,10 +16,13 @@ software distributed under the License i
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-
 -->
 <auth>
   <page id="Schema">
+    <action id="list">
+      <entitlement>SCHEMA_LIST</entitlement>
+    </action>
+
     <action id="create">
       <entitlement>SCHEMA_CREATE</entitlement>
     </action>
@@ -64,6 +67,10 @@ under the License.
   </page>
 
   <page id="Roles">
+    <action id="list">
+      <entitlement>ROLE_LIST</entitlement>
+    </action>
+
     <action id="create">
       <entitlement>ROLE_CREATE</entitlement>
     </action>
@@ -82,6 +89,10 @@ under the License.
   </page>
 
   <page id="Resources">
+    <action id="list">
+      <entitlement>RESOURCE_LIST</entitlement>
+    </action>
+
     <action id="create">
       <entitlement>RESOURCE_CREATE</entitlement>
     </action>

Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication.properties?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication.properties (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication.properties Fri Oct 11 14:27:12 2013
@@ -33,7 +33,7 @@ confirmDeprovision=Do you really want to
 
 
 unauthorizedInstantiationException=Missing authorization.
-httpClientException=Missing authorization while contacting Syncope core.
+accessControlException=Missing authorization while contacting Syncope core.
 restClientException=Error while contacting Syncope core.
 pageExpiredException=Session expired: please login again.
 

Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication_it.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication_it.properties?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication_it.properties (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication_it.properties Fri Oct 11 14:27:12 2013
@@ -32,7 +32,7 @@ confirmUnassign=Vuoi davvero procedere r
 confirmDeprovision=Vuoi davvero procedere con il de-provisioning dell'utente?
 
 unauthorizedInstantiationException=Autorizzazione mancante.
-httpClientException=Autorizzazione mancante durante la comunicazione con Syncope core.
+accessControlException=Autorizzazione mancante durante la comunicazione con Syncope core.
 restClientException=Errore durante la comunicazione con Syncope core.
 pageExpiredException=Sessione scaduta: eseguire di nuovo l'accesso.
 

Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication_pt_BR.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication_pt_BR.properties?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication_pt_BR.properties (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/SyncopeApplication_pt_BR.properties Fri Oct 11 14:27:12 2013
@@ -23,7 +23,7 @@ reports=Relat\u00f3rios
 tasks=Tarefas
 logout=Sair
 schema=Esquemas
-operation_succeded=Opera\u00e7\u00e3o executada com sucesso
+operation_succeeded=Opera\u00e7\u00e3o executada com sucesso
 operation_error=Um erro ocorreu ao executar esta opera\u00e7\u00e3o
 alert=Alerta:
 confirmDelete=Voc\u00ea realmente deseja apagar este item selecionado?
@@ -32,7 +32,7 @@ confirmUnassign=Voc\u00ea realmente dese
 confirmDeprovision=Voc\u00ea realmente de-provision usu\u00e1rio?
 
 unauthorizedInstantiationException=Falta de autoriza\u00e7\u00e3o para concluir.
-httpClientException=Falta de autoriza\u00e7\u00e3o ao comunicar-se com o Syncope core.
+accessControlException=Falta de autoriza\u00e7\u00e3o ao comunicar-se com o Syncope core.
 restClientException=Erro ao comunicar-se com o Syncope core.
 pageExpiredException=Sess\u00e3o encerrada, favor logar-se novamente.
 

Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/BasePage.html
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/BasePage.html?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/BasePage.html (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/BasePage.html Fri Oct 11 14:27:12 2013
@@ -127,7 +127,7 @@ under the License.
           </div>
         </li>
       </ul>
-      <div wicket:id="editProfileModal" ></div>
+      <div wicket:id="editProfileModal"></div>
     </div>
 
     <div wicket:id="feedback"/>

Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/WelcomePage.html
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/WelcomePage.html?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/WelcomePage.html (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/WelcomePage.html Fri Oct 11 14:27:12 2013
@@ -40,8 +40,19 @@ under the License.
   <body style="text-align:center">
     <div id="splash">
       <img src="img/logo.png" alt="syncope" title="syncope" id="logo" />
-      <div wicket:id="infoModal"/>
-      <a style="position: relative; top: 20px; left: -103px;" wicket:id="infoLink"><img src="img/info.png" alt="info" title="info"/></a>
+      <div style="display: table-row;">
+        <div id="username" style="padding-right: 5px;cursor: pointer;display: table-cell;">          
+          <a href="#" wicket:id="editProfileLink" style="font-family: monospace;padding-left: 130px;">
+            <span style="color: #B9CFB3;"><wicket:message key="welcome"/>,
+              <span wicket:id="username" style="color: #B9CFB3;text-decoration: underline;"/>
+            </span>
+          </a>
+        </div>
+        <div>
+          <div wicket:id="infoModal"/>
+          <a wicket:id="infoLink"><img src="img/info.png" alt="info" style="padding-right: 10px;"/></a>
+        </div>
+      </div>
       <ul>
         <li><a href="#" wicket:id="todo" class="todo"><img wicket:id="todoIcon" alt="TODO" width="80" height="80" /><br /><wicket:message key="todo"/></a></li>
         <li><a href="#" wicket:id="schema" class="schema"><img wicket:id="schemaIcon" alt="Schema" width="80" height="80" /><br /><wicket:message key="schema"/></a></li>
@@ -54,5 +65,6 @@ under the License.
         <li><a href="#" wicket:id="logout" class="logout"><img src="img/menu/logout.png" alt="Logout" width="80" height="80" /><br /><wicket:message key="logout"/></a></li>
       </ul>
     </div>
+    <div wicket:id="editProfileModal"></div>
   </body>
 </html>

Modified: syncope/trunk/console/src/test/java/org/apache/syncope/console/EditProfileTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/test/java/org/apache/syncope/console/EditProfileTestITCase.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/console/src/test/java/org/apache/syncope/console/EditProfileTestITCase.java (original)
+++ syncope/trunk/console/src/test/java/org/apache/syncope/console/EditProfileTestITCase.java Fri Oct 11 14:27:12 2013
@@ -40,10 +40,11 @@ public class EditProfileTestITCase exten
         selenium.click("css=a.w_close");
 
         // only to have some "Logout" availabe for @After
-        selenium.type("name=userId", "rossini");
-        selenium.type("name=password", "password");
+        selenium.open("/syncope-console/");
+        selenium.waitForPageToLoad("30000");
+        selenium.type("name=userId", ADMIN);
+        selenium.type("name=password", PASSWORD);
         selenium.click("name=:submit");
-
         selenium.waitForPageToLoad("30000");
     }
 
@@ -53,12 +54,9 @@ public class EditProfileTestITCase exten
         selenium.type("name=userId", "rossini");
         selenium.type("name=password", "password");
         selenium.click("name=:submit");
-        selenium.waitForPageToLoad("30000");
-
-        selenium.click("css=img[alt=\"Schema\"]");
-        selenium.waitForPageToLoad("30000");
 
-        selenium.click("//div/ul/li[10]/div/div/a/span");
+        selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='username']/a\");", "30000");
+        selenium.click("//div[@id='username']/a");
 
         selenium.waitForCondition("selenium.isElementPresent(\"//span[contains(text(),'Attributes')]\");", "30000");
         selenium.waitForCondition("selenium.isElementPresent(\"//input[@value='rossini']\");", "30000");

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeUserValidator.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeUserValidator.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeUserValidator.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/SyncopeUserValidator.java Fri Oct 11 14:27:12 2013
@@ -20,6 +20,7 @@ package org.apache.syncope.core.persiste
 
 import java.util.ArrayList;
 import java.util.List;
+import javax.annotation.Resource;
 import javax.validation.ConstraintValidatorContext;
 import org.apache.syncope.common.types.AccountPolicySpec;
 import org.apache.syncope.common.types.EntityViolationType;
@@ -32,12 +33,19 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
 import org.apache.syncope.core.persistence.dao.PolicyDAO;
 import org.apache.syncope.core.policy.AccountPolicyEnforcer;
+import org.apache.syncope.core.policy.AccountPolicyException;
 import org.apache.syncope.core.policy.PasswordPolicyEnforcer;
 import org.apache.syncope.core.policy.PolicyEvaluator;
 import org.springframework.beans.factory.annotation.Autowired;
 
 public class SyncopeUserValidator extends AbstractValidator<SyncopeUserCheck, SyncopeUser> {
 
+    @Resource(name = "adminUser")
+    private String adminUser;
+
+    @Resource(name = "anonymousUser")
+    private String anonymousUser;
+
     @Autowired
     private PolicyDAO policyDAO;
 
@@ -51,7 +59,7 @@ public class SyncopeUserValidator extend
     private AccountPolicyEnforcer apEnforcer;
 
     @Override
-    public boolean isValid(final SyncopeUser object, final ConstraintValidatorContext context) {
+    public boolean isValid(final SyncopeUser user, final ConstraintValidatorContext context) {
         context.disableDefaultConstraintViolation();
 
         // ------------------------------
@@ -59,14 +67,14 @@ public class SyncopeUserValidator extend
         // ------------------------------
         LOG.debug("Password Policy enforcement");
 
-        if (object.getClearPassword() != null) {
+        if (user.getClearPassword() != null) {
             try {
                 int maxPPSpecHistory = 0;
-                for (Policy policy : getPasswordPolicies(object)) {
+                for (Policy policy : getPasswordPolicies(user)) {
                     // evaluate policy
-                    final PasswordPolicySpec ppSpec = evaluator.evaluate(policy, object);
+                    final PasswordPolicySpec ppSpec = evaluator.evaluate(policy, user);
                     // enforce policy
-                    ppEnforcer.enforce(ppSpec, policy.getType(), object.getClearPassword());
+                    ppEnforcer.enforce(ppSpec, policy.getType(), user.getClearPassword());
 
                     if (ppSpec.getHistoryLength() > maxPPSpecHistory) {
                         maxPPSpecHistory = ppSpec.getHistoryLength();
@@ -74,13 +82,13 @@ public class SyncopeUserValidator extend
                 }
 
                 // update user's password history with encrypted password
-                if (maxPPSpecHistory > 0 && object.getPassword() != null) {
-                    object.getPasswordHistory().add(object.getPassword());
+                if (maxPPSpecHistory > 0 && user.getPassword() != null) {
+                    user.getPasswordHistory().add(user.getPassword());
                 }
                 // keep only the last maxPPSpecHistory items in user's password history
-                if (maxPPSpecHistory < object.getPasswordHistory().size()) {
-                    for (int i = 0; i < object.getPasswordHistory().size() - maxPPSpecHistory; i++) {
-                        object.getPasswordHistory().remove(i);
+                if (maxPPSpecHistory < user.getPasswordHistory().size()) {
+                    for (int i = 0; i < user.getPasswordHistory().size() - maxPPSpecHistory; i++) {
+                        user.getPasswordHistory().remove(i);
                     }
                 }
             } catch (Exception e) {
@@ -93,7 +101,7 @@ public class SyncopeUserValidator extend
                 return false;
             } finally {
                 // password has been validated, let's remove its clear version
-                object.removeClearPassword();
+                user.removeClearPassword();
             }
         }
         // ------------------------------
@@ -104,13 +112,17 @@ public class SyncopeUserValidator extend
         LOG.debug("Account Policy enforcement");
 
         try {
-            // missing username
-            for (Policy policy : getAccountPolicies(object)) {
+            if (adminUser.equals(user.getUsername()) || anonymousUser.equals(user.getUsername())) {
+                throw new AccountPolicyException("Not allowed: " + user.getUsername());
+            }
+
+            // invalid username
+            for (Policy policy : getAccountPolicies(user)) {
                 // evaluate policy
-                final AccountPolicySpec accountPolicy = evaluator.evaluate(policy, object);
+                final AccountPolicySpec accountPolicy = evaluator.evaluate(policy, user);
 
                 // enforce policy
-                apEnforcer.enforce(accountPolicy, policy.getType(), object);
+                apEnforcer.enforce(accountPolicy, policy.getType(), user);
             }
         } catch (Exception e) {
             LOG.debug("Invalid username");

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java Fri Oct 11 14:27:12 2013
@@ -192,6 +192,7 @@ public class ResourceController extends 
         return actionsClasses;
     }
 
+    @PreAuthorize("isAuthenticated()")
     @Transactional(readOnly = true)
     public List<ResourceTO> list(final Long connInstanceId) {
         List<ExternalResource> resources;

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/RoleController.java Fri Oct 11 14:27:12 2013
@@ -23,6 +23,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
+import javax.annotation.Resource;
 import org.apache.syncope.common.mod.RoleMod;
 import org.apache.syncope.common.search.NodeCond;
 import org.apache.syncope.common.services.InvalidSearchConditionException;
@@ -91,20 +92,21 @@ public class RoleController {
     @Autowired
     private PropagationTaskExecutor taskExecutor;
 
-    /**
-     * ConnectorObject util.
-     */
     @Autowired
     private ConnObjectUtil connObjectUtil;
 
-    @PreAuthorize("hasRole('ROLE_READ')")
+    @Resource(name = "anonymousUser")
+    private String anonymousUser;
+
+    @PreAuthorize("hasAnyRole('ROLE_READ', T(org.apache.syncope.common.SyncopeConstants).ANONYMOUS_ENTITLEMENT)")
     @Transactional(readOnly = true)
     public RoleTO read(final Long roleId) {
-        SyncopeRole role = binder.getRoleFromId(roleId);
-
-        Set<Long> allowedRoleIds = EntitlementUtil.getRoleIds(EntitlementUtil.getOwnedEntitlementNames());
-        if (!allowedRoleIds.contains(role.getId())) {
-            throw new UnauthorizedRoleException(role.getId());
+        SyncopeRole role;
+        // bypass role entitlements check
+        if (anonymousUser.equals(EntitlementUtil.getAuthenticatedUsername())) {
+            role = roleDAO.find(roleId);
+        } else {
+            role = binder.getRoleFromId(roleId);
         }
 
         auditManager.audit(Category.role, RoleSubCategory.read, Result.success,
@@ -113,7 +115,8 @@ public class RoleController {
         return binder.getRoleTO(role);
     }
 
-    @PreAuthorize("isAuthenticated()")
+    @PreAuthorize("isAuthenticated() "
+            + "and not(hasRole(T(org.apache.syncope.common.SyncopeConstants).ANONYMOUS_ENTITLEMENT))")
     @Transactional(readOnly = true)
     public RoleTO selfRead(final Long roleId) {
         // Explicit search instead of using binder.getRoleFromId() in order to bypass auth checks - will do here
@@ -234,6 +237,7 @@ public class RoleController {
         return searchDAO.count(adminRoleIds, searchCondition, AttributableUtil.getInstance(AttributableType.ROLE));
     }
 
+    @PreAuthorize("isAuthenticated()")
     @Transactional(readOnly = true)
     public List<RoleTO> list() {
         List<SyncopeRole> roles = roleDAO.findAll();

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/SchemaController.java Fri Oct 11 14:27:12 2013
@@ -169,6 +169,7 @@ public class SchemaController extends Ab
                 "Successfully deleted schema: " + schemaType + "/" + attrType + "/" + schemaName);
     }
 
+    @PreAuthorize("isAuthenticated()")
     @SuppressWarnings("unchecked")
     public <T extends AbstractSchemaTO> List<T> list(final AttributableType attrType, final SchemaType schemaType) {
         final AttributableUtil attrUtil = AttributableUtil.getInstance(attrType);

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java Fri Oct 11 14:27:12 2013
@@ -191,7 +191,8 @@ public class UserController {
         return result;
     }
 
-    @PreAuthorize("isAuthenticated()")
+    @PreAuthorize("isAuthenticated() "
+            + "and not(hasRole(T(org.apache.syncope.common.SyncopeConstants).ANONYMOUS_ENTITLEMENT))")
     @Transactional(readOnly = true)
     public UserTO read() {
         UserTO userTO = binder.getAuthenticatedUserTO();

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/UserRequestController.java Fri Oct 11 14:27:12 2013
@@ -80,6 +80,7 @@ public class UserRequestController {
         return Boolean.valueOf(createRequestAllowed.getValue());
     }
 
+    @PreAuthorize("isAuthenticated()")
     public UserRequestTO create(final UserTO userTO) {
         if (!isCreateAllowed()) {
             LOG.error("Create requests are not allowed");
@@ -107,7 +108,8 @@ public class UserRequestController {
         return binder.getUserRequestTO(request);
     }
 
-    @PreAuthorize("isAuthenticated()")
+    @PreAuthorize("isAuthenticated() "
+            + "and not(hasRole(T(org.apache.syncope.common.SyncopeConstants).ANONYMOUS_ENTITLEMENT))")
     public UserRequestTO update(final UserMod userMod) {
         LOG.debug("Request user update called with {}", userMod);
 
@@ -129,7 +131,8 @@ public class UserRequestController {
         return binder.getUserRequestTO(request);
     }
 
-    @PreAuthorize("isAuthenticated()")
+    @PreAuthorize("isAuthenticated() "
+            + "and not(hasRole(T(org.apache.syncope.common.SyncopeConstants).ANONYMOUS_ENTITLEMENT))")
     public UserRequestTO delete(final Long userId) {
         LOG.debug("Request user delete called with {}", userId);
 
@@ -182,6 +185,8 @@ public class UserRequestController {
         return result;
     }
 
+    @PreAuthorize("hasRole('USER_REQUEST_LIST')")
+    @Transactional(readOnly = true)
     public List<UserRequestTO> listByUsername(final String username) {
         List<UserRequestTO> result = new ArrayList<UserRequestTO>();
 

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java Fri Oct 11 14:27:12 2013
@@ -74,6 +74,9 @@ public class UserDataBinder extends Abst
     @Resource(name = "adminUser")
     private String adminUser;
 
+    @Resource(name = "anonymousUser")
+    private String anonymousUser;
+
     @Transactional(readOnly = true)
     public SyncopeUser getUserFromId(final Long userId) {
         if (userId == null) {
@@ -102,7 +105,11 @@ public class UserDataBinder extends Abst
         final UserTO authUserTO;
 
         final String authUsername = SecurityContextHolder.getContext().getAuthentication().getName();
-        if (adminUser.equals(authUsername)) {
+        if (anonymousUser.equals(authUsername)) {
+            authUserTO = new UserTO();
+            authUserTO.setId(-2);
+            authUserTO.setUsername(anonymousUser);
+        } else if (adminUser.equals(authUsername)) {
             authUserTO = new UserTO();
             authUserTO.setId(-1);
             authUserTO.setUsername(adminUser);

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeAuthenticationProvider.java Fri Oct 11 14:27:12 2013
@@ -57,10 +57,15 @@ public class SyncopeAuthenticationProvid
     @Resource(name = "adminUser")
     private String adminUser;
 
+    @Resource(name = "anonymousUser")
+    private String anonymousUser;
+
     private String adminPassword;
 
     private String adminPasswordAlgorithm;
 
+    private String anonymousKey;
+
     private SyncopeUserDetailsService userDetailsService;
 
     /**
@@ -77,6 +82,13 @@ public class SyncopeAuthenticationProvid
         this.adminPasswordAlgorithm = adminPasswordAlgorithm;
     }
 
+    /**
+     * @param anonymousKey the anonymousKey to set
+     */
+    public void setAnonymousKey(final String anonymousKey) {
+        this.anonymousKey = anonymousKey;
+    }
+
     public void setSyncopeUserDetailsService(final SyncopeUserDetailsService syncopeUserDetailsService) {
         this.userDetailsService = syncopeUserDetailsService;
     }
@@ -90,7 +102,9 @@ public class SyncopeAuthenticationProvid
         SyncopeUser user = null;
 
         String username = authentication.getName();
-        if (adminUser.equals(username)) {
+        if (anonymousUser.equals(username)) {
+            authenticated = authentication.getCredentials().toString().equals(anonymousKey);
+        } else if (adminUser.equals(username)) {
             authenticated = authenticate(
                     authentication.getCredentials().toString(),
                     CipherAlgorithm.valueOf(adminPasswordAlgorithm),

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeUserDetailsService.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeUserDetailsService.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeUserDetailsService.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/security/SyncopeUserDetailsService.java Fri Oct 11 14:27:12 2013
@@ -22,6 +22,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import javax.annotation.Resource;
+import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.core.persistence.beans.Entitlement;
 import org.apache.syncope.core.persistence.beans.role.SyncopeRole;
 import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
@@ -53,10 +54,15 @@ public class SyncopeUserDetailsService i
     @Resource(name = "adminUser")
     private String adminUser;
 
+    @Resource(name = "anonymousUser")
+    private String anonymousUser;
+
     @Override
     public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException, DataAccessException {
         final Set<SimpleGrantedAuthority> authorities = new HashSet<SimpleGrantedAuthority>();
-        if (adminUser.equals(username)) {
+        if (anonymousUser.equals(username)) {
+            authorities.add(new SimpleGrantedAuthority(SyncopeConstants.ANONYMOUS_ENTITLEMENT));
+        } else if (adminUser.equals(username)) {
             for (Entitlement entitlement : entitlementDAO.findAll()) {
                 authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
             }

Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/util/EntitlementUtil.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/util/EntitlementUtil.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/util/EntitlementUtil.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/util/EntitlementUtil.java Fri Oct 11 14:27:12 2013
@@ -23,11 +23,13 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.regex.Pattern;
-import org.apache.syncope.common.SyncopeConstants;
 
+import org.apache.syncope.common.SyncopeConstants;
 import org.apache.syncope.core.persistence.beans.Entitlement;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.GrantedAuthority;
@@ -46,7 +48,7 @@ public final class EntitlementUtil {
 
     public static String getAuthenticatedUsername() {
         Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
-        return authentication == null ? SyncopeConstants.ANONYMOUS_USER : authentication.getName();
+        return authentication == null ? SyncopeConstants.UNAUTHENTICATED : authentication.getName();
     }
 
     public static Set<String> getOwnedEntitlementNames() {
@@ -76,7 +78,7 @@ public final class EntitlementUtil {
 
         if (isRoleEntitlement(entitlementName)) {
             try {
-                result = Long.valueOf(entitlementName.substring(entitlementName.indexOf("_") + 1));
+                result = Long.valueOf(entitlementName.substring(entitlementName.indexOf('_') + 1));
             } catch (Exception e) {
                 LOG.error("unable to parse {} to Long", entitlementName, e);
             }

Modified: syncope/trunk/core/src/main/resources/content.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/content.xml?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/content.xml (original)
+++ syncope/trunk/core/src/main/resources/content.xml Fri Oct 11 14:27:12 2013
@@ -32,6 +32,7 @@ under the License.
   <SyncopeConf confKey="notification.maxRetries" confValue="0"/>
     
   <!-- Authentication and authorization -->
+  <Entitlement name="SCHEMA_LIST"/>
   <Entitlement name="SCHEMA_CREATE"/>
   <Entitlement name="SCHEMA_READ"/>
   <Entitlement name="SCHEMA_UPDATE"/>
@@ -42,10 +43,12 @@ under the License.
   <Entitlement name="USER_UPDATE"/>
   <Entitlement name="USER_DELETE"/>
   <Entitlement name="USER_VIEW"/>
+  <Entitlement name="ROLE_LIST"/>
   <Entitlement name="ROLE_CREATE"/>
   <Entitlement name="ROLE_READ"/>
   <Entitlement name="ROLE_UPDATE"/>
   <Entitlement name="ROLE_DELETE"/>
+  <Entitlement name="RESOURCE_LIST"/>
   <Entitlement name="RESOURCE_CREATE"/>
   <Entitlement name="RESOURCE_READ"/>
   <Entitlement name="RESOURCE_UPDATE"/>
@@ -62,14 +65,14 @@ under the License.
   <Entitlement name="CONFIGURATION_READ"/>
   <Entitlement name="CONFIGURATION_UPDATE"/>
   <Entitlement name="CONFIGURATION_DELETE"/>
-  <Entitlement name="TASK_CREATE"/>
   <Entitlement name="TASK_LIST"/>
-  <Entitlement name="TASK_EXECUTE"/>
+  <Entitlement name="TASK_CREATE"/>
   <Entitlement name="TASK_READ"/>
   <Entitlement name="TASK_UPDATE"/>
   <Entitlement name="TASK_DELETE"/>
-  <Entitlement name="POLICY_CREATE"/>
+  <Entitlement name="TASK_EXECUTE"/>
   <Entitlement name="POLICY_LIST"/>
+  <Entitlement name="POLICY_CREATE"/>
   <Entitlement name="POLICY_READ"/>
   <Entitlement name="POLICY_UPDATE"/>
   <Entitlement name="POLICY_DELETE"/>

Modified: syncope/trunk/core/src/main/resources/security.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/security.properties?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/security.properties (original)
+++ syncope/trunk/core/src/main/resources/security.properties Fri Oct 11 14:27:12 2013
@@ -17,4 +17,6 @@
 adminUser=admin
 adminPassword=5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
 adminPasswordAlgorithm=SHA1
+anonymousUser=${anonymousUser}
+anonymousKey=${anonymousKey}
 secretKey=${secretKey}

Modified: syncope/trunk/core/src/main/resources/securityContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/securityContext.xml?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/securityContext.xml (original)
+++ syncope/trunk/core/src/main/resources/securityContext.xml Fri Oct 11 14:27:12 2013
@@ -52,6 +52,7 @@ under the License.
         class="org.apache.syncope.core.security.SyncopeAuthenticationProvider">
     <property name="adminPassword" value="${adminPassword}"/>
     <property name="adminPasswordAlgorithm" value="${adminPasswordAlgorithm}"/>
+    <property name="anonymousKey" value="anonymousKey"/>
     <property name="syncopeUserDetailsService" ref="syncopeUserDetailsService"/>
   </bean>
 

Modified: syncope/trunk/core/src/main/resources/syncopeContext.xml
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/resources/syncopeContext.xml?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/main/resources/syncopeContext.xml (original)
+++ syncope/trunk/core/src/main/resources/syncopeContext.xml Fri Oct 11 14:27:12 2013
@@ -43,6 +43,9 @@ under the License.
   <bean id="adminUser" class="java.lang.String">
     <constructor-arg value="${adminUser}"/>
   </bean>
+  <bean id="anonymousUser" class="java.lang.String">
+    <constructor-arg value="${anonymousUser}"/>
+  </bean>
 
   <bean class="org.apache.syncope.core.util.ApplicationContextProvider"/>
 

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/EntitlementTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/EntitlementTest.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/EntitlementTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/persistence/dao/EntitlementTest.java Fri Oct 11 14:27:12 2013
@@ -41,7 +41,7 @@ public class EntitlementTest extends Abs
     @Test
     public void findAll() {
         List<Entitlement> list = entitlementDAO.findAll();
-        assertEquals("did not get expected number of entitlements ", 86, list.size());
+        assertEquals("did not get expected number of entitlements ", 89, list.size());
     }
 
     @Test

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Fri Oct 11 14:27:12 2013
@@ -18,13 +18,17 @@
  */
 package org.apache.syncope.core.rest;
 
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
+import java.io.InputStream;
+import java.util.Properties;
 import java.util.UUID;
 
 import javax.sql.DataSource;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 
 import org.apache.http.HttpStatus;
@@ -54,6 +58,7 @@ import org.apache.syncope.common.to.Role
 import org.apache.syncope.common.to.UserTO;
 import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.SchemaType;
+import org.apache.syncope.core.util.PasswordEncoder;
 import org.junit.BeforeClass;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
@@ -79,12 +84,13 @@ public abstract class AbstractTest {
 
     private static final String ENV_KEY_CONTENT_TYPE = "jaxrsContentType";
 
-    protected static SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean().setAddress(ADDRESS);
+    protected static final SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean().setAddress(ADDRESS);
 
-    protected static SyncopeClient adminClient;
+    protected static String ANONYMOUS_UNAME;
 
-    @Autowired
-    protected DataSource testDataSource;
+    protected static String ANONYMOUS_KEY;
+
+    protected static SyncopeClient adminClient;
 
     protected static UserService userService;
 
@@ -116,8 +122,31 @@ public abstract class AbstractTest {
 
     protected static PolicyService policyService;
 
+    @Autowired
+    protected DataSource testDataSource;
+
+    @BeforeClass
+    public static void securitySetup() {
+        InputStream propStream = null;
+        try {
+            propStream = PasswordEncoder.class.getResourceAsStream("/security.properties");
+            Properties props = new Properties();
+            props.load(propStream);
+
+            ANONYMOUS_UNAME = props.getProperty("anonymousUser");
+            ANONYMOUS_KEY = props.getProperty("anonymousKey");
+        } catch (Exception e) {
+            LOG.error("Could not read secretKey", e);
+        } finally {
+            IOUtils.closeQuietly(propStream);
+        }
+
+        assertNotNull(ANONYMOUS_UNAME);
+        assertNotNull(ANONYMOUS_KEY);
+    }
+
     @BeforeClass
-    public static void setup() {
+    public static void restSetup() {
         final String envContentType = System.getProperty(ENV_KEY_CONTENT_TYPE);
         if (StringUtils.isNotBlank(envContentType)) {
             clientFactory.getRestClientFactoryBean().setContentType(envContentType);

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java Fri Oct 11 14:27:12 2013
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.security.AccessControlException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
@@ -55,6 +56,40 @@ import org.junit.runners.MethodSorters;
 @FixMethodOrder(MethodSorters.JVM)
 public class ResourceTestITCase extends AbstractTest {
 
+    private ResourceTO buildResourceTO(final String resourceName) {
+        ResourceTO resourceTO = new ResourceTO();
+
+        resourceTO.setName(resourceName);
+        resourceTO.setConnectorId(102L);
+
+        MappingTO mapping = new MappingTO();
+
+        MappingItemTO item = new MappingItemTO();
+        item.setExtAttrName("uid");
+        item.setIntAttrName("userId");
+        item.setIntMappingType(IntMappingType.UserSchema);
+        item.setPurpose(MappingPurpose.BOTH);
+        mapping.addItem(item);
+
+        item = new MappingItemTO();
+        item.setExtAttrName("username");
+        item.setIntAttrName("fullname");
+        item.setIntMappingType(IntMappingType.UserId);
+        item.setPurpose(MappingPurpose.BOTH);
+        mapping.setAccountIdItem(item);
+
+        item = new MappingItemTO();
+        item.setExtAttrName("fullname");
+        item.setIntAttrName("cn");
+        item.setIntMappingType(IntMappingType.UserSchema);
+        item.setAccountid(false);
+        item.setPurpose(MappingPurpose.BOTH);
+        mapping.addItem(item);
+
+        resourceTO.setUmapping(mapping);
+        return resourceTO;
+    }
+
     @Test
     public void getPropagationActionsClasses() {
         Set<PropagationActionClassTO> actions = resourceService.getPropagationActionsClasses();
@@ -502,37 +537,18 @@ public class ResourceTestITCase extends 
         }
     }
 
-    private ResourceTO buildResourceTO(final String resourceName) {
-        ResourceTO resourceTO = new ResourceTO();
-
-        resourceTO.setName(resourceName);
-        resourceTO.setConnectorId(102L);
-
-        MappingTO mapping = new MappingTO();
-
-        MappingItemTO item = new MappingItemTO();
-        item.setExtAttrName("uid");
-        item.setIntAttrName("userId");
-        item.setIntMappingType(IntMappingType.UserSchema);
-        item.setPurpose(MappingPurpose.BOTH);
-        mapping.addItem(item);
-
-        item = new MappingItemTO();
-        item.setExtAttrName("username");
-        item.setIntAttrName("fullname");
-        item.setIntMappingType(IntMappingType.UserId);
-        item.setPurpose(MappingPurpose.BOTH);
-        mapping.setAccountIdItem(item);
-
-        item = new MappingItemTO();
-        item.setExtAttrName("fullname");
-        item.setIntAttrName("cn");
-        item.setIntMappingType(IntMappingType.UserSchema);
-        item.setAccountid(false);
-        item.setPurpose(MappingPurpose.BOTH);
-        mapping.addItem(item);
+    @Test
+    public void anonymous() {
+        ResourceService unauthenticated = clientFactory.create(null, null).getService(ResourceService.class);
+        try {
+            unauthenticated.list();
+            fail();
+        } catch (AccessControlException e) {
+            assertNotNull(e);
+        }
 
-        resourceTO.setUmapping(mapping);
-        return resourceTO;
+        ResourceService anonymous = clientFactory.create(ANONYMOUS_UNAME, ANONYMOUS_KEY).
+                getService(ResourceService.class);
+        assertFalse(anonymous.list().isEmpty());
     }
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/RoleTestITCase.java Fri Oct 11 14:27:12 2013
@@ -507,4 +507,18 @@ public class RoleTestITCase extends Abst
         assertNotNull(roleTO);
         assertTrue(roleTO.getAttrMap().containsKey(badge.getName()));
     }
+
+    @Test
+    public void anonymous() {
+        RoleService unauthenticated = clientFactory.create(null, null).getService(RoleService.class);
+        try {
+            unauthenticated.list();
+            fail();
+        } catch (AccessControlException e) {
+            assertNotNull(e);
+        }
+
+        RoleService anonymous = clientFactory.create(ANONYMOUS_UNAME, ANONYMOUS_KEY).getService(RoleService.class);
+        assertFalse(anonymous.list().isEmpty());
+    }
 }

Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java?rev=1531307&r1=1531306&r2=1531307&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/SchemaTestITCase.java Fri Oct 11 14:27:12 2013
@@ -25,10 +25,12 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.security.AccessControlException;
 import java.util.List;
 import org.apache.http.HttpStatus;
 
 import org.apache.syncope.common.mod.UserMod;
+import org.apache.syncope.common.services.SchemaService;
 import org.apache.syncope.common.to.MembershipTO;
 import org.apache.syncope.common.to.SchemaTO;
 import org.apache.syncope.common.to.UserTO;
@@ -47,6 +49,13 @@ import org.junit.runners.MethodSorters;
 @FixMethodOrder(MethodSorters.JVM)
 public class SchemaTestITCase extends AbstractTest {
 
+    private SchemaTO buildSchemaTO(final String name, final AttributeSchemaType type) {
+        SchemaTO schemaTO = new SchemaTO();
+        schemaTO.setName(name + getUUIDString());
+        schemaTO.setType(type);
+        return schemaTO;
+    }
+
     @Test
     public void create() {
         SchemaTO schemaTO = buildSchemaTO("testAttribute", AttributeSchemaType.String);
@@ -283,10 +292,17 @@ public class SchemaTestITCase extends Ab
         }
     }
 
-    private SchemaTO buildSchemaTO(final String name, final AttributeSchemaType type) {
-        SchemaTO schemaTO = new SchemaTO();
-        schemaTO.setName(name + getUUIDString());
-        schemaTO.setType(type);
-        return schemaTO;
+    @Test
+    public void anonymous() {
+        SchemaService unauthenticated = clientFactory.create(null, null).getService(SchemaService.class);
+        try {
+            unauthenticated.list(AttributableType.USER, SchemaType.VIRTUAL);
+            fail();
+        } catch (AccessControlException e) {
+            assertNotNull(e);
+        }
+
+        SchemaService anonymous = clientFactory.create(ANONYMOUS_UNAME, ANONYMOUS_KEY).getService(SchemaService.class);
+        assertFalse(anonymous.list(AttributableType.USER, SchemaType.VIRTUAL).isEmpty());
     }
 }