[SYNCOPE-952] Realm management now working for enduser
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/55b9e83d Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/55b9e83d Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/55b9e83d Branch: refs/heads/master Commit: 55b9e83d76d6f8c576a235aeb6f1e3d634656bcf Parents: bf1b627 Author: Francesco Chicchiriccò <ilgro...@apache.org> Authored: Thu Sep 29 15:59:37 2016 +0200 Committer: Francesco Chicchiriccò <ilgro...@apache.org> Committed: Thu Sep 29 16:00:14 2016 +0200 ---------------------------------------------------------------------- .../enduser/SyncopeEnduserApplication.java | 27 +++++-- .../enduser/resources/AnyTypeClassResource.java | 77 ++++++++++++++++++ .../enduser/resources/AnyTypeResource.java | 77 ++++++++++++++++++ .../resources/ExternalResourceResource.java | 78 +++++++++++++++++++ .../client/enduser/resources/GroupResource.java | 79 +++++++++++++++++++ .../client/enduser/resources/RealmResource.java | 76 ++++++++++++++++++ .../resources/SyncopeAnyClassTypeResource.java | 81 ------------------- .../resources/SyncopeAnyTypeResource.java | 81 ------------------- .../enduser/resources/SyncopeGroupResource.java | 82 -------------------- .../resources/SyncopeResourceResource.java | 82 -------------------- .../app/js/controllers/UserController.js | 31 ++++---- .../resources/app/js/services/anyService.js | 6 +- .../resources/app/js/services/groupService.js | 2 +- .../resources/app/js/services/realmService.js | 10 +-- .../app/js/services/resourceService.js | 2 +- .../app/js/services/securityQuestionService.js | 2 +- .../app/js/services/userSelfService.js | 1 - .../resources/app/views/user-groups.html | 3 +- .../apache/syncope/core/logic/RealmLogic.java | 14 ++-- .../provisioning/api/data/RealmDataBinder.java | 2 +- .../java/data/RealmDataBinderImpl.java | 21 ++--- .../pushpull/RealmPullResultHandlerImpl.java | 16 ++-- .../pushpull/RealmPushResultHandlerImpl.java | 8 +- 23 files changed, 466 insertions(+), 392 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java index 71de4db..f47ec8b 100644 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/SyncopeEnduserApplication.java @@ -31,10 +31,11 @@ import org.apache.syncope.client.enduser.resources.LoginResource; import org.apache.syncope.client.enduser.resources.LogoutResource; import org.apache.syncope.client.enduser.resources.SchemaResource; import org.apache.syncope.client.enduser.resources.SecurityQuestionResource; -import org.apache.syncope.client.enduser.resources.SyncopeAnyClassTypeResource; -import org.apache.syncope.client.enduser.resources.SyncopeAnyTypeResource; -import org.apache.syncope.client.enduser.resources.SyncopeGroupResource; -import org.apache.syncope.client.enduser.resources.SyncopeResourceResource; +import org.apache.syncope.client.enduser.resources.AnyTypeClassResource; +import org.apache.syncope.client.enduser.resources.AnyTypeResource; +import org.apache.syncope.client.enduser.resources.GroupResource; +import org.apache.syncope.client.enduser.resources.ExternalResourceResource; +import org.apache.syncope.client.enduser.resources.RealmResource; import org.apache.syncope.client.enduser.resources.UserSelfChangePassword; import org.apache.syncope.client.enduser.resources.UserSelfConfirmPasswordReset; import org.apache.syncope.client.enduser.resources.UserSelfCreateResource; @@ -245,7 +246,7 @@ public class SyncopeEnduserApplication extends WebApplication implements Seriali @Override public IResource getResource() { - return new SyncopeResourceResource(); + return new ExternalResourceResource(); } }); @@ -290,13 +291,23 @@ public class SyncopeEnduserApplication extends WebApplication implements Seriali } }); + mountResource("/api/realms", new ResourceReference("realms") { + + private static final long serialVersionUID = -128426276529456602L; + + @Override + public IResource getResource() { + return new RealmResource(); + } + }); + mountResource("/api/groups", new ResourceReference("groups") { private static final long serialVersionUID = -128426276529456602L; @Override public IResource getResource() { - return new SyncopeGroupResource(); + return new GroupResource(); } }); @@ -306,7 +317,7 @@ public class SyncopeEnduserApplication extends WebApplication implements Seriali @Override public IResource getResource() { - return new SyncopeAnyClassTypeResource(); + return new AnyTypeClassResource(); } }); @@ -316,7 +327,7 @@ public class SyncopeEnduserApplication extends WebApplication implements Seriali @Override public IResource getResource() { - return new SyncopeAnyTypeResource(); + return new AnyTypeResource(); } }); http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeClassResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeClassResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeClassResource.java new file mode 100644 index 0000000..6d230c1 --- /dev/null +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeClassResource.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.client.enduser.resources; + +import java.io.IOException; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; +import org.apache.syncope.client.enduser.SyncopeEnduserSession; +import org.apache.syncope.common.lib.to.AnyTypeClassTO; +import org.apache.syncope.common.rest.api.service.AnyTypeClassService; +import org.apache.wicket.request.resource.AbstractResource; + +public class AnyTypeClassResource extends AbstractBaseResource { + + private static final long serialVersionUID = 7475706378304995200L; + + private final AnyTypeClassService anyTypeClassService; + + public AnyTypeClassResource() { + anyTypeClassService = SyncopeEnduserSession.get().getService(AnyTypeClassService.class); + } + + @Override + protected ResourceResponse newResourceResponse(final Attributes attributes) { + + LOG.debug("Get all available auxiliary classes"); + + ResourceResponse response = new ResourceResponse(); + + try { + + HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); + if (!xsrfCheck(request)) { + LOG.error("XSRF TOKEN does not match"); + response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); + return response; + } + + final List<AnyTypeClassTO> anyTypeClassTOs = anyTypeClassService.list(); + + response.setWriteCallback(new AbstractResource.WriteCallback() { + + @Override + public void writeData(final Attributes attributes) throws IOException { + attributes.getResponse().write(MAPPER.writeValueAsString(anyTypeClassTOs)); + } + }); + response.setStatusCode(Response.Status.OK.getStatusCode()); + } catch (Exception e) { + LOG.error("Error retrieving available auxiliary classes", e); + response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() + .append("ErrorMessage{{ ") + .append(e.getMessage()) + .append(" }}") + .toString()); + } + return response; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeResource.java new file mode 100644 index 0000000..5d58f37 --- /dev/null +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/AnyTypeResource.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.client.enduser.resources; + +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; +import org.apache.syncope.client.enduser.SyncopeEnduserSession; +import org.apache.syncope.common.lib.to.AnyTypeTO; +import org.apache.syncope.common.rest.api.service.AnyTypeService; +import org.apache.wicket.request.resource.AbstractResource; + +public class AnyTypeResource extends AbstractBaseResource { + + private static final long serialVersionUID = 7475706378304995200L; + + private final AnyTypeService anyTypeService; + + public AnyTypeResource() { + anyTypeService = SyncopeEnduserSession.get().getService(AnyTypeService.class); + } + + @Override + protected ResourceResponse newResourceResponse(final Attributes attributes) { + + LOG.debug("Get all available auxiliary classes"); + + ResourceResponse response = new ResourceResponse(); + + try { + + HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); + if (!xsrfCheck(request)) { + LOG.error("XSRF TOKEN does not match"); + response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); + return response; + } + + String kind = attributes.getParameters().get(0).toString(); + final AnyTypeTO anyTypeTO = anyTypeService.read(kind); + + response.setWriteCallback(new AbstractResource.WriteCallback() { + + @Override + public void writeData(final Attributes attributes) throws IOException { + attributes.getResponse().write(MAPPER.writeValueAsString(anyTypeTO)); + } + }); + response.setStatusCode(Response.Status.OK.getStatusCode()); + } catch (Exception e) { + LOG.error("Error retrieving available any type details", e); + response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() + .append("ErrorMessage{{ ") + .append(e.getMessage()) + .append(" }}") + .toString()); + } + return response; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/ExternalResourceResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/ExternalResourceResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/ExternalResourceResource.java new file mode 100644 index 0000000..e779a94 --- /dev/null +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/ExternalResourceResource.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.client.enduser.resources; + +import java.io.IOException; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; +import org.apache.syncope.client.enduser.SyncopeEnduserSession; +import org.apache.syncope.common.lib.to.ResourceTO; +import org.apache.syncope.common.rest.api.service.ResourceService; +import org.apache.wicket.request.resource.AbstractResource; +import org.apache.wicket.request.resource.IResource; + +public class ExternalResourceResource extends AbstractBaseResource { + + private static final long serialVersionUID = 7475706378304995200L; + + private final ResourceService resourceService; + + public ExternalResourceResource() { + resourceService = SyncopeEnduserSession.get().getService(ResourceService.class); + } + + @Override + protected AbstractResource.ResourceResponse newResourceResponse(final IResource.Attributes attributes) { + + LOG.debug("Search all available resources"); + + AbstractResource.ResourceResponse response = new AbstractResource.ResourceResponse(); + + try { + + HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); + if (!xsrfCheck(request)) { + LOG.error("XSRF TOKEN does not match"); + response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); + return response; + } + + final List<ResourceTO> resourceTOs = resourceService.list(); + + response.setWriteCallback(new AbstractResource.WriteCallback() { + + @Override + public void writeData(final IResource.Attributes attributes) throws IOException { + attributes.getResponse().write(MAPPER.writeValueAsString(resourceTOs)); + } + }); + response.setStatusCode(Response.Status.OK.getStatusCode()); + } catch (Exception e) { + LOG.error("Error retrieving available resources", e); + response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() + .append("ErrorMessage{{ ") + .append(e.getMessage()) + .append(" }}") + .toString()); + } + return response; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/GroupResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/GroupResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/GroupResource.java new file mode 100644 index 0000000..365d7df --- /dev/null +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/GroupResource.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.client.enduser.resources; + +import java.io.IOException; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; +import org.apache.syncope.client.enduser.SyncopeEnduserSession; +import org.apache.syncope.common.lib.SyncopeConstants; +import org.apache.syncope.common.lib.to.GroupTO; +import org.apache.syncope.common.rest.api.beans.AnyQuery; +import org.apache.syncope.common.rest.api.service.GroupService; +import org.apache.wicket.request.resource.AbstractResource; + +public class GroupResource extends AbstractBaseResource { + + private static final long serialVersionUID = 7475706378304995200L; + + private final GroupService groupService; + + public GroupResource() { + groupService = SyncopeEnduserSession.get().getService(GroupService.class); + } + + @Override + protected ResourceResponse newResourceResponse(final Attributes attributes) { + LOG.debug("Search all available groups"); + + ResourceResponse response = new ResourceResponse(); + try { + + HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); + if (!xsrfCheck(request)) { + LOG.error("XSRF TOKEN does not match"); + response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); + return response; + } + + String realm = java.net.URLDecoder.decode(attributes.getParameters().get("realm"). + toString(SyncopeConstants.ROOT_REALM), "UTF-8"); + final List<GroupTO> groupTOs = groupService.search(new AnyQuery.Builder().realm(realm).build()).getResult(); + + response.setWriteCallback(new AbstractResource.WriteCallback() { + + @Override + public void writeData(final Attributes attributes) throws IOException { + attributes.getResponse().write(MAPPER.writeValueAsString(groupTOs)); + } + }); + response.setStatusCode(Response.Status.OK.getStatusCode()); + } catch (Exception e) { + LOG.error("Error retrieving available groups", e); + response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() + .append("ErrorMessage{{ ") + .append(e.getMessage()) + .append(" }}") + .toString()); + } + return response; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/RealmResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/RealmResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/RealmResource.java new file mode 100644 index 0000000..6d5049b --- /dev/null +++ b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/RealmResource.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.client.enduser.resources; + +import java.io.IOException; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; +import org.apache.syncope.client.enduser.SyncopeEnduserSession; +import org.apache.syncope.common.lib.to.RealmTO; +import org.apache.syncope.common.rest.api.service.RealmService; +import org.apache.wicket.request.resource.AbstractResource; + +public class RealmResource extends AbstractBaseResource { + + private static final long serialVersionUID = 7475706378304995200L; + + private final RealmService realmService; + + public RealmResource() { + realmService = SyncopeEnduserSession.get().getService(RealmService.class); + } + + @Override + protected ResourceResponse newResourceResponse(final Attributes attributes) { + LOG.debug("Search all available realms"); + + ResourceResponse response = new ResourceResponse(); + + try { + HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); + if (!xsrfCheck(request)) { + LOG.error("XSRF TOKEN does not match"); + response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); + return response; + } + + final List<RealmTO> realmTOs = realmService.list(); + + response.setWriteCallback(new AbstractResource.WriteCallback() { + + @Override + public void writeData(final Attributes attributes) throws IOException { + attributes.getResponse().write(MAPPER.writeValueAsString(realmTOs)); + } + }); + response.setStatusCode(Response.Status.OK.getStatusCode()); + } catch (Exception e) { + LOG.error("Error retrieving available realms", e); + response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() + .append("ErrorMessage{{ ") + .append(e.getMessage()) + .append(" }}") + .toString()); + } + + return response; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeAnyClassTypeResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeAnyClassTypeResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeAnyClassTypeResource.java deleted file mode 100644 index bdb6f98..0000000 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeAnyClassTypeResource.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.client.enduser.resources; - -import java.io.IOException; -import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Response; -import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.to.AnyTypeClassTO; -import org.apache.syncope.common.rest.api.service.AnyTypeClassService; -import org.apache.wicket.request.resource.AbstractResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SyncopeAnyClassTypeResource extends AbstractBaseResource { - - private static final long serialVersionUID = 7475706378304995200L; - - private static final Logger LOG = LoggerFactory.getLogger(SyncopeAnyClassTypeResource.class); - - private final AnyTypeClassService anyTypeClassService; - - public SyncopeAnyClassTypeResource() { - anyTypeClassService = SyncopeEnduserSession.get().getService(AnyTypeClassService.class); - } - - @Override - protected ResourceResponse newResourceResponse(final Attributes attributes) { - - LOG.debug("Get all available auxiliary classes"); - - ResourceResponse response = new ResourceResponse(); - - try { - - HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); - if (!xsrfCheck(request)) { - LOG.error("XSRF TOKEN does not match"); - response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); - return response; - } - - final List<AnyTypeClassTO> anyTypeClassTOs = anyTypeClassService.list(); - - response.setWriteCallback(new AbstractResource.WriteCallback() { - - @Override - public void writeData(final Attributes attributes) throws IOException { - attributes.getResponse().write(MAPPER.writeValueAsString(anyTypeClassTOs)); - } - }); - response.setStatusCode(Response.Status.OK.getStatusCode()); - } catch (Exception e) { - LOG.error("Error retrieving available auxiliary classes", e); - response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() - .append("ErrorMessage{{ ") - .append(e.getMessage()) - .append(" }}") - .toString()); - } - return response; - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeAnyTypeResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeAnyTypeResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeAnyTypeResource.java deleted file mode 100644 index 9c9b1ad..0000000 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeAnyTypeResource.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.client.enduser.resources; - -import java.io.IOException; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Response; -import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.to.AnyTypeTO; -import org.apache.syncope.common.rest.api.service.AnyTypeService; -import org.apache.wicket.request.resource.AbstractResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SyncopeAnyTypeResource extends AbstractBaseResource { - - private static final long serialVersionUID = 7475706378304995200L; - - private static final Logger LOG = LoggerFactory.getLogger(SyncopeAnyTypeResource.class); - - private final AnyTypeService anyTypeService; - - public SyncopeAnyTypeResource() { - anyTypeService = SyncopeEnduserSession.get().getService(AnyTypeService.class); - } - - @Override - protected ResourceResponse newResourceResponse(final Attributes attributes) { - - LOG.debug("Get all available auxiliary classes"); - - ResourceResponse response = new ResourceResponse(); - - try { - - HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); - if (!xsrfCheck(request)) { - LOG.error("XSRF TOKEN does not match"); - response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); - return response; - } - - String kind = attributes.getParameters().get(0).toString(); - final AnyTypeTO anyTypeTO = anyTypeService.read(kind); - - response.setWriteCallback(new AbstractResource.WriteCallback() { - - @Override - public void writeData(final Attributes attributes) throws IOException { - attributes.getResponse().write(MAPPER.writeValueAsString(anyTypeTO)); - } - }); - response.setStatusCode(Response.Status.OK.getStatusCode()); - } catch (Exception e) { - LOG.error("Error retrieving available any type details", e); - response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() - .append("ErrorMessage{{ ") - .append(e.getMessage()) - .append(" }}") - .toString()); - } - return response; - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeGroupResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeGroupResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeGroupResource.java deleted file mode 100644 index 7757532..0000000 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeGroupResource.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.client.enduser.resources; - -import java.io.IOException; -import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Response; -import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.SyncopeConstants; -import org.apache.syncope.common.lib.to.GroupTO; -import org.apache.syncope.common.rest.api.beans.AnyQuery; -import org.apache.syncope.common.rest.api.service.GroupService; -import org.apache.wicket.request.resource.AbstractResource; - -public class SyncopeGroupResource extends AbstractBaseResource { - - private static final long serialVersionUID = 7475706378304995200L; - - private final GroupService groupService; - - public SyncopeGroupResource() { - groupService = SyncopeEnduserSession.get().getService(GroupService.class); - } - - @Override - protected ResourceResponse newResourceResponse(final Attributes attributes) { - - LOG.debug("Search all available groups"); - - ResourceResponse response = new ResourceResponse(); - - try { - - HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); - if (!xsrfCheck(request)) { - LOG.error("XSRF TOKEN does not match"); - response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); - return response; - } - - String realm = java.net.URLDecoder.decode(attributes.getParameters().get("realm").toString( - SyncopeConstants.ROOT_REALM), "UTF-8"); - final List<GroupTO> groupTOs = groupService.search(new AnyQuery.Builder().realm(realm).build()). - getResult(); - - response.setWriteCallback(new AbstractResource.WriteCallback() { - - @Override - public void writeData(final Attributes attributes) throws IOException { - attributes.getResponse().write(MAPPER.writeValueAsString(groupTOs)); - } - }); - response.setStatusCode(Response.Status.OK.getStatusCode()); - } catch (Exception e) { - LOG.error("Error retrieving available grupss", e); - response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() - .append("ErrorMessage{{ ") - .append(e.getMessage()) - .append(" }}") - .toString()); - } - return response; - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeResourceResource.java ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeResourceResource.java b/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeResourceResource.java deleted file mode 100644 index 8a6d0a9..0000000 --- a/client/enduser/src/main/java/org/apache/syncope/client/enduser/resources/SyncopeResourceResource.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.client.enduser.resources; - -import java.io.IOException; -import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Response; -import org.apache.syncope.client.enduser.SyncopeEnduserSession; -import org.apache.syncope.common.lib.to.ResourceTO; -import org.apache.syncope.common.rest.api.service.ResourceService; -import org.apache.wicket.request.resource.AbstractResource; -import org.apache.wicket.request.resource.IResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SyncopeResourceResource extends AbstractBaseResource { - - private static final long serialVersionUID = 7475706378304995200L; - - private static final Logger LOG = LoggerFactory.getLogger(SyncopeResourceResource.class); - - private final ResourceService resourceService; - - public SyncopeResourceResource() { - resourceService = SyncopeEnduserSession.get().getService(ResourceService.class); - } - - @Override - protected AbstractResource.ResourceResponse newResourceResponse(final IResource.Attributes attributes) { - - LOG.debug("Search all available resources"); - - AbstractResource.ResourceResponse response = new AbstractResource.ResourceResponse(); - - try { - - HttpServletRequest request = (HttpServletRequest) attributes.getRequest().getContainerRequest(); - if (!xsrfCheck(request)) { - LOG.error("XSRF TOKEN does not match"); - response.setError(Response.Status.BAD_REQUEST.getStatusCode(), "XSRF TOKEN does not match"); - return response; - } - - final List<ResourceTO> resourceTOs = resourceService.list(); - - response.setWriteCallback(new AbstractResource.WriteCallback() { - - @Override - public void writeData(final IResource.Attributes attributes) throws IOException { - attributes.getResponse().write(MAPPER.writeValueAsString(resourceTOs)); - } - }); - response.setStatusCode(Response.Status.OK.getStatusCode()); - } catch (Exception e) { - LOG.error("Error retrieving available resources", e); - response.setError(Response.Status.BAD_REQUEST.getStatusCode(), new StringBuilder() - .append("ErrorMessage{{ ") - .append(e.getMessage()) - .append(" }}") - .toString()); - } - return response; - } - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js index e93e3a2..1d33e3d 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js +++ b/client/enduser/src/main/resources/META-INF/resources/app/js/controllers/UserController.js @@ -21,9 +21,9 @@ 'use strict'; -angular.module("self").controller("UserController", ['$scope', '$rootScope', '$location', '$compile', "$state", 'AuthService', - 'UserSelfService', 'SchemaService', 'RealmService', 'ResourceService', 'SecurityQuestionService', 'GroupService', - 'AnyService', 'UserUtil', 'GenericUtil', "ValidationExecutor", +angular.module("self").controller("UserController", ['$scope', '$rootScope', '$location', '$compile', "$state", + 'AuthService', 'UserSelfService', 'SchemaService', 'RealmService', 'ResourceService', 'SecurityQuestionService', + 'GroupService', 'AnyService', 'UserUtil', 'GenericUtil', "ValidationExecutor", function ($scope, $rootScope, $location, $compile, $state, AuthService, UserSelfService, SchemaService, RealmService, ResourceService, SecurityQuestionService, GroupService, AnyService, UserUtil, GenericUtil, ValidationExecutor) { @@ -106,7 +106,8 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l }; // add other values for (var j = 1; j < $scope.user.plainAttrs[plainSchemaKey].values.length; j++) { - $scope.dynamicForm.attributeTable[schemas.plainSchemas[i].key].fields.push(schemas.plainSchemas[i].key + "_" + j); + $scope.dynamicForm.attributeTable[schemas.plainSchemas[i].key].fields. + push(schemas.plainSchemas[i].key + "_" + j); } } } @@ -141,7 +142,8 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l }; // add other values for (var j = 1; j < $scope.user.virAttrs[virSchemaKey].values.length; j++) { - $scope.dynamicForm.virtualAttributeTable[schemas.virSchemas[i].key].fields.push(schemas.virSchemas[i].key + "_" + j); + $scope.dynamicForm.virtualAttributeTable[schemas.virSchemas[i].key].fields. + push(schemas.virSchemas[i].key + "_" + j); } } } @@ -166,11 +168,12 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l }; var initRealms = function () { - $scope.availableRealms = RealmService.getAvailableRealmsStub(); - }; - - var initUserRealm = function () { - $scope.user.realm = RealmService.getUserRealm(); + RealmService.getAvailableRealms().then(function (response) { + for (var i in response) { + $scope.availableRealms.push(response[i].fullPath); + } + $scope.availableRealms.sort(); + }); }; var initResources = function () { @@ -193,6 +196,10 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l }); }; + $scope.refreshGroups = function () { + initGroups(); + } + var initAuxClasses = function () { //fetching default user classes, that should remain in any case AnyService.getAnyType("USER").then(function (response) { @@ -330,7 +337,7 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l $scope.user = { username: '', password: '', - realm: '', + realm: '/', securityQuestion: undefined, securityAnswer: '', plainAttrs: {}, @@ -339,8 +346,6 @@ angular.module("self").controller("UserController", ['$scope', '$rootScope', '$l resources: [], auxClasses: [] }; - // retrieve user realm or all available realms - initUserRealm(); // initialize auxiliary schemas in case of pre-existing classes for (var index in $scope.dynamicForm.selectedAuxClasses) { initUserSchemas($scope.dynamicForm.selectedAuxClasses[index]); http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/resources/META-INF/resources/app/js/services/anyService.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/services/anyService.js b/client/enduser/src/main/resources/META-INF/resources/app/js/services/anyService.js index a424013..59f8ec3 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/services/anyService.js +++ b/client/enduser/src/main/resources/META-INF/resources/app/js/services/anyService.js @@ -30,7 +30,8 @@ angular.module('self') .then(function (response) { return response.data; }, function (response) { - console.debug("Something went wrong during auxiliaryClasses retrieval, exit with status: ", response); + console.error("Something went wrong during auxiliaryClasses retrieval, exit with status: ", + response); return $q.reject(response.data || response.statusText); }); }; @@ -40,7 +41,8 @@ angular.module('self') .then(function (response) { return response.data; }, function (response) { - console.error("Something went wrong during anyType user API retrieval, exit with status: ", response); + console.error("Something went wrong during anyType user API retrieval, exit with status: ", + response); return $q.reject(response.data || response.statusText); }); }; http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/resources/META-INF/resources/app/js/services/groupService.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/services/groupService.js b/client/enduser/src/main/resources/META-INF/resources/app/js/services/groupService.js index 7b1f8d0..1de1ef1 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/services/groupService.js +++ b/client/enduser/src/main/resources/META-INF/resources/app/js/services/groupService.js @@ -26,7 +26,7 @@ angular.module('self') var groupService = {}; groupService.getGroups = function (realm) { - return $http.get("/syncope-enduser/api/groups?realm="+encodeURI(realm)) + return $http.get("/syncope-enduser/api/groups?realm=" + encodeURI(realm)) .then(function (response) { return response.data; }, function (response) { http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/resources/META-INF/resources/app/js/services/realmService.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/services/realmService.js b/client/enduser/src/main/resources/META-INF/resources/app/js/services/realmService.js index 3c030ac..a129df7 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/services/realmService.js +++ b/client/enduser/src/main/resources/META-INF/resources/app/js/services/realmService.js @@ -25,14 +25,9 @@ angular.module('self') var realmService = {}; - realmService.getAvailableRealmsStub = function () { - return ["/"]; - }; - realmService.getAvailableRealms = function () { - return $http.get("/syncope-enduser/api/realms") + return $http.get("/syncope-enduser/api/realms") .then(function (response) { - console.debug("realms response: ", response); return response.data; }, function (response) { console.error("Something went wrong during realms retrieval, exit with status: ", response); @@ -40,8 +35,5 @@ angular.module('self') }); }; - realmService.getUserRealm = function () { - return "/"; - }; return realmService; }]); http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/resources/META-INF/resources/app/js/services/resourceService.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/services/resourceService.js b/client/enduser/src/main/resources/META-INF/resources/app/js/services/resourceService.js index 9ad2cc4..e5d2d2a 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/services/resourceService.js +++ b/client/enduser/src/main/resources/META-INF/resources/app/js/services/resourceService.js @@ -31,7 +31,7 @@ angular.module('self') .then(function (response) { return response.data; }, function (response) { - console.debug("Something went wrong during resources retrieval, exit with status: ", response); + console.error("Something went wrong during resources retrieval, exit with status: ", response); return $q.reject(response.data || response.statusText); }); }; http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/resources/META-INF/resources/app/js/services/securityQuestionService.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/services/securityQuestionService.js b/client/enduser/src/main/resources/META-INF/resources/app/js/services/securityQuestionService.js index 417468c..45fa80b 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/services/securityQuestionService.js +++ b/client/enduser/src/main/resources/META-INF/resources/app/js/services/securityQuestionService.js @@ -35,7 +35,7 @@ angular.module('self') }; securityQuestionService.getSecurityQuestionByUser = function (username) { - return $http.get("/syncope-enduser/api/securityQuestions/byUser/"+username) + return $http.get("/syncope-enduser/api/securityQuestions/byUser/" + username) .then(function (response) { return response.data; }, function (response) { http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/resources/META-INF/resources/app/js/services/userSelfService.js ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/js/services/userSelfService.js b/client/enduser/src/main/resources/META-INF/resources/app/js/services/userSelfService.js index 09a8ac8..9f9f444 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/js/services/userSelfService.js +++ b/client/enduser/src/main/resources/META-INF/resources/app/js/services/userSelfService.js @@ -40,7 +40,6 @@ angular.module('login') headers: {'captcha': captcha} }) .then(function (response) { - console.debug("response save: ", response); var username = response; return username; }, function (response) { http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/client/enduser/src/main/resources/META-INF/resources/app/views/user-groups.html ---------------------------------------------------------------------- diff --git a/client/enduser/src/main/resources/META-INF/resources/app/views/user-groups.html b/client/enduser/src/main/resources/META-INF/resources/app/views/user-groups.html index 7f28dd5..632da03 100644 --- a/client/enduser/src/main/resources/META-INF/resources/app/views/user-groups.html +++ b/client/enduser/src/main/resources/META-INF/resources/app/views/user-groups.html @@ -19,8 +19,7 @@ under the License. <div id="attribute" class="form-group row upper-select"> <label>{{"REALM"|translate}}</label> <select class="form-control" - ng-disabled="true" - ng-model="user.realm" + ng-model="user.realm" ng-change="refreshGroups()" ng-required="true"> <option ng-repeat="realm in availableRealms" value="{{realm}}">{{realm}}</option> </select> http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/core/logic/src/main/java/org/apache/syncope/core/logic/RealmLogic.java ---------------------------------------------------------------------- diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/RealmLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/RealmLogic.java index 6cc22fd..e82e495 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/RealmLogic.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/RealmLogic.java @@ -48,6 +48,7 @@ import org.apache.syncope.core.provisioning.api.data.RealmDataBinder; import org.apache.syncope.core.provisioning.api.propagation.PropagationManager; import org.apache.syncope.core.provisioning.api.propagation.PropagationReporter; import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor; +import org.apache.syncope.core.spring.security.AuthContextUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Component; @@ -70,7 +71,7 @@ public class RealmLogic extends AbstractTransactionalLogic<RealmTO> { @Autowired private PropagationTaskExecutor taskExecutor; - @PreAuthorize("hasRole('" + StandardEntitlement.REALM_LIST + "')") + @PreAuthorize("isAuthenticated()") public List<RealmTO> list(final String fullPath) { Realm realm = realmDAO.findByFullPath(fullPath); if (realm == null) { @@ -79,11 +80,12 @@ public class RealmLogic extends AbstractTransactionalLogic<RealmTO> { throw new NotFoundException(fullPath); } + final boolean admin = AuthContextUtils.getAuthorizations().keySet().contains(StandardEntitlement.REALM_LIST); return CollectionUtils.collect(realmDAO.findDescendants(realm), new Transformer<Realm, RealmTO>() { @Override public RealmTO transform(final Realm input) { - return binder.getRealmTO(input); + return binder.getRealmTO(input, admin); } }, new ArrayList<RealmTO>()); } @@ -105,7 +107,7 @@ public class RealmLogic extends AbstractTransactionalLogic<RealmTO> { PropagationReporter propagationReporter = taskExecutor.execute(tasks, false); ProvisioningResult<RealmTO> result = new ProvisioningResult<>(); - result.setEntity(binder.getRealmTO(realm)); + result.setEntity(binder.getRealmTO(realm, true)); result.getPropagationStatuses().addAll(propagationReporter.getStatuses()); return result; @@ -127,7 +129,7 @@ public class RealmLogic extends AbstractTransactionalLogic<RealmTO> { PropagationReporter propagationReporter = taskExecutor.execute(tasks, false); ProvisioningResult<RealmTO> result = new ProvisioningResult<>(); - result.setEntity(binder.getRealmTO(realm)); + result.setEntity(binder.getRealmTO(realm, true)); result.getPropagationStatuses().addAll(propagationReporter.getStatuses()); return result; @@ -170,7 +172,7 @@ public class RealmLogic extends AbstractTransactionalLogic<RealmTO> { PropagationReporter propagationReporter = taskExecutor.execute(tasks, false); ProvisioningResult<RealmTO> result = new ProvisioningResult<>(); - result.setEntity(binder.getRealmTO(realm)); + result.setEntity(binder.getRealmTO(realm, true)); result.getPropagationStatuses().addAll(propagationReporter.getStatuses()); realmDAO.delete(realm); @@ -196,7 +198,7 @@ public class RealmLogic extends AbstractTransactionalLogic<RealmTO> { if (fullPath != null) { try { - return binder.getRealmTO(realmDAO.findByFullPath(fullPath)); + return binder.getRealmTO(realmDAO.findByFullPath(fullPath), true); } catch (Throwable e) { LOG.debug("Unresolved reference", e); throw new UnresolvedReferenceException(e); http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/RealmDataBinder.java ---------------------------------------------------------------------- diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/RealmDataBinder.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/RealmDataBinder.java index 380cb30..44e00fc 100644 --- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/RealmDataBinder.java +++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/data/RealmDataBinder.java @@ -28,6 +28,6 @@ public interface RealmDataBinder { PropagationByResource update(Realm realm, RealmTO realmTO); - RealmTO getRealmTO(Realm realm); + RealmTO getRealmTO(Realm realm, boolean admin); } http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RealmDataBinderImpl.java ---------------------------------------------------------------------- diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RealmDataBinderImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RealmDataBinderImpl.java index 015612e..32678cc 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RealmDataBinderImpl.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/data/RealmDataBinderImpl.java @@ -210,23 +210,26 @@ public class RealmDataBinderImpl implements RealmDataBinder { } @Override - public RealmTO getRealmTO(final Realm realm) { + public RealmTO getRealmTO(final Realm realm, final boolean admin) { RealmTO realmTO = new RealmTO(); realmTO.setKey(realm.getKey()); realmTO.setName(realm.getName()); realmTO.setParent(realm.getParent() == null ? null : realm.getParent().getKey()); realmTO.setFullPath(realm.getFullPath()); - realmTO.setAccountPolicy(realm.getAccountPolicy() == null ? null : realm.getAccountPolicy().getKey()); - realmTO.setPasswordPolicy(realm.getPasswordPolicy() == null ? null : realm.getPasswordPolicy().getKey()); - realmTO.getActionsClassNames().addAll(realm.getActionsClassNames()); - for (AnyTemplate template : realm.getTemplates()) { - realmTO.getTemplates().put(template.getAnyType().getKey(), template.get()); - } + if (admin) { + realmTO.setAccountPolicy(realm.getAccountPolicy() == null ? null : realm.getAccountPolicy().getKey()); + realmTO.setPasswordPolicy(realm.getPasswordPolicy() == null ? null : realm.getPasswordPolicy().getKey()); + realmTO.getActionsClassNames().addAll(realm.getActionsClassNames()); + + for (AnyTemplate template : realm.getTemplates()) { + realmTO.getTemplates().put(template.getAnyType().getKey(), template.get()); + } - for (ExternalResource resource : realm.getResources()) { - realmTO.getResources().add(resource.getKey()); + for (ExternalResource resource : realm.getResources()) { + realmTO.getResources().add(resource.getKey()); + } } return realmTO; http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/RealmPullResultHandlerImpl.java ---------------------------------------------------------------------- diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/RealmPullResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/RealmPullResultHandlerImpl.java index d2d9dc5..db285a8 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/RealmPullResultHandlerImpl.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/RealmPullResultHandlerImpl.java @@ -221,9 +221,9 @@ public class RealmPullResultHandlerImpl propByRes.add(ResourceOperation.CREATE, resource); } List<PropagationTask> tasks = propagationManager.createTasks(realm, propByRes, null); - PropagationReporter propagationReporter = taskExecutor.execute(tasks, false); + taskExecutor.execute(tasks, false); - RealmTO actual = binder.getRealmTO(realm); + RealmTO actual = binder.getRealmTO(realm, true); result.setKey(actual.getKey()); result.setName(profile.getTask().getDestinatioRealm().getFullPath() + "/" + actual.getName()); @@ -265,7 +265,7 @@ public class RealmPullResultHandlerImpl LOG.debug("About to update {}", realm); - RealmTO before = binder.getRealmTO(realm); + RealmTO before = binder.getRealmTO(realm, true); ProvisioningReport result = new ProvisioningReport(); result.setOperation(ResourceOperation.UPDATE); @@ -327,7 +327,7 @@ public class RealmPullResultHandlerImpl result.setStatus(ProvisioningReport.Status.SUCCESS); result.setKey(realm.getKey()); - RealmTO before = binder.getRealmTO(realm); + RealmTO before = binder.getRealmTO(realm, true); Object output; Result resultStatus; @@ -351,9 +351,9 @@ public class RealmPullResultHandlerImpl if (unlink) { realm.getResources().remove(profile.getTask().getResource()); - output = binder.getRealmTO(realmDAO.save(realm)); + output = binder.getRealmTO(realmDAO.save(realm), true); } else { - output = binder.getRealmTO(realm); + output = binder.getRealmTO(realm, true); } for (PullActions action : profile.getActions()) { @@ -403,7 +403,7 @@ public class RealmPullResultHandlerImpl result.setStatus(ProvisioningReport.Status.SUCCESS); result.setKey(realm.getKey()); - RealmTO before = binder.getRealmTO(realm); + RealmTO before = binder.getRealmTO(realm, true); Object output; Result resultStatus; @@ -476,7 +476,7 @@ public class RealmPullResultHandlerImpl ProvisioningReport result = new ProvisioningReport(); try { - RealmTO before = binder.getRealmTO(realm); + RealmTO before = binder.getRealmTO(realm, true); result.setKey(realm.getKey()); result.setName(realm.getFullPath()); http://git-wip-us.apache.org/repos/asf/syncope/blob/55b9e83d/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/RealmPushResultHandlerImpl.java ---------------------------------------------------------------------- diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/RealmPushResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/RealmPushResultHandlerImpl.java index 2425ac4..f0b4438 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/RealmPushResultHandlerImpl.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/RealmPushResultHandlerImpl.java @@ -107,7 +107,7 @@ public class RealmPushResultHandlerImpl } private void link(final Realm realm, final Boolean unlink) { - RealmTO realmTO = binder.getRealmTO(realm); + RealmTO realmTO = binder.getRealmTO(realm, true); if (unlink) { realmTO.getResources().remove(profile.getTask().getResource().getKey()); } else { @@ -118,14 +118,14 @@ public class RealmPushResultHandlerImpl } private void unassign(final Realm realm) { - RealmTO realmTO = binder.getRealmTO(realm); + RealmTO realmTO = binder.getRealmTO(realm, true); realmTO.getResources().remove(profile.getTask().getResource().getKey()); deprovision(update(realmTO)); } private void assign(final Realm realm) { - RealmTO realmTO = binder.getRealmTO(realm); + RealmTO realmTO = binder.getRealmTO(realm, true); realmTO.getResources().add(profile.getTask().getResource().getKey()); provision(update(realmTO)); @@ -222,7 +222,7 @@ public class RealmPushResultHandlerImpl if (!profile.getTask().isPerformUpdate()) { LOG.debug("PushTask not configured for update"); } else { - update(binder.getRealmTO(realm)); + update(binder.getRealmTO(realm, true)); } break;