http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/SyncopeApplication.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeApplication.java b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeApplication.java deleted file mode 100644 index a1e781d..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeApplication.java +++ /dev/null @@ -1,306 +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.console; - -import java.io.Serializable; -import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.commons.XMLRolesReader; -import org.apache.syncope.client.console.pages.Configuration; -import org.apache.syncope.client.console.pages.InfoModalPage; -import org.apache.syncope.client.console.pages.Login; -import org.apache.syncope.client.console.pages.Logout; -import org.apache.syncope.client.console.pages.Reports; -import org.apache.syncope.client.console.pages.Resources; -import org.apache.syncope.client.console.pages.Groups; -import org.apache.syncope.client.console.pages.Schema; -import org.apache.syncope.client.console.pages.Tasks; -import org.apache.syncope.client.console.pages.Todo; -import org.apache.syncope.client.console.pages.UserSelfModalPage; -import org.apache.syncope.client.console.pages.Users; -import org.apache.syncope.client.console.pages.WelcomePage; -import org.apache.syncope.client.console.resources.FilesystemResource; -import org.apache.syncope.client.console.resources.WorkflowDefGETResource; -import org.apache.syncope.client.console.resources.WorkflowDefPUTResource; -import org.apache.syncope.client.console.rest.UserSelfRestClient; -import org.apache.syncope.common.lib.to.UserTO; -import org.apache.wicket.Component; -import org.apache.wicket.Page; -import org.apache.wicket.RestartResponseAtInterceptPageException; -import org.apache.wicket.Session; -import org.apache.wicket.WicketRuntimeException; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener; -import org.apache.wicket.authorization.UnauthorizedInstantiationException; -import org.apache.wicket.authroles.authorization.strategies.role.IRoleCheckingStrategy; -import org.apache.wicket.authroles.authorization.strategies.role.RoleAuthorizationStrategy; -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; -import org.apache.wicket.request.Request; -import org.apache.wicket.request.Response; -import org.apache.wicket.request.resource.ContextRelativeResource; -import org.apache.wicket.request.resource.IResource; -import org.apache.wicket.request.resource.ResourceReference; -import org.apache.wicket.spring.injection.annot.SpringComponentInjector; -import org.springframework.web.context.support.WebApplicationContextUtils; - -/** - * SyncopeApplication class. - */ -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 String ACTIVITI_MODELER_CONTEXT = "activiti-modeler"; - - private static final int EDIT_PROFILE_WIN_HEIGHT = 550; - - private static final int EDIT_PROFILE_WIN_WIDTH = 800; - - @Override - protected void init() { - super.init(); - - getComponentInstantiationListeners().add(new SpringComponentInjector(this)); - - getResourceSettings().setThrowExceptionOnMissingResource(true); - - getSecuritySettings().setAuthorizationStrategy(new RoleAuthorizationStrategy(this)); - getSecuritySettings().setUnauthorizedComponentInstantiationListener(this); - - getMarkupSettings().setStripWicketTags(true); - getMarkupSettings().setCompressWhitespace(true); - - getRequestCycleListeners().add(new SyncopeRequestCycleListener()); - - final String activitiModelerDirectory = WebApplicationContextUtils.getWebApplicationContext( - WebApplication.get().getServletContext()).getBean("activitiModelerDirectory", String.class); - mountResource("/" + ACTIVITI_MODELER_CONTEXT, new ResourceReference(ACTIVITI_MODELER_CONTEXT) { - - private static final long serialVersionUID = -128426276529456602L; - - @Override - public IResource getResource() { - return new FilesystemResource(ACTIVITI_MODELER_CONTEXT, activitiModelerDirectory); - } - - }); - mountResource("/workflowDefGET", new ResourceReference("workflowDefGET") { - - private static final long serialVersionUID = -128426276529456602L; - - @Override - public IResource getResource() { - return new WorkflowDefGETResource(); - } - }); - mountResource("/workflowDefPUT", new ResourceReference("workflowDefPUT") { - - private static final long serialVersionUID = -128426276529456602L; - - @Override - public IResource getResource() { - return new WorkflowDefPUTResource(); - } - }); - } - - public void setupNavigationPanel(final WebPage page, final XMLRolesReader xmlRolesReader, final boolean notsel) { - final ModalWindow infoModal = new ModalWindow("infoModal"); - page.add(infoModal); - infoModal.setInitialWidth(350); - infoModal.setInitialHeight(300); - infoModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY); - infoModal.setCookieName("infoModal"); - infoModal.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new InfoModalPage(); - } - }); - - final AjaxLink<Page> infoLink = new AjaxLink<Page>("infoLink") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - infoModal.show(target); - } - }; - page.add(infoLink); - - BookmarkablePageLink<Page> schemaLink = new BookmarkablePageLink<>("schema", Schema.class); - MetaDataRoleAuthorizationStrategy.authorize( - schemaLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Schema", "list")); - page.add(schemaLink); - schemaLink.add(new Image("schemaIcon", new ContextRelativeResource(IMG_PREFIX + (notsel - ? IMG_NOTSEL - : StringUtils.EMPTY) + "schema" + Constants.PNG_EXT))); - - BookmarkablePageLink<Page> usersLink = new BookmarkablePageLink<>("users", Users.class); - MetaDataRoleAuthorizationStrategy.authorize( - usersLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Users", "list")); - page.add(usersLink); - usersLink.add(new Image("usersIcon", new ContextRelativeResource(IMG_PREFIX + (notsel - ? IMG_NOTSEL - : StringUtils.EMPTY) + "users" + Constants.PNG_EXT))); - - BookmarkablePageLink<Page> groupsLink = new BookmarkablePageLink<>("groups", Groups.class); - MetaDataRoleAuthorizationStrategy.authorize( - groupsLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Groups", "list")); - page.add(groupsLink); - groupsLink.add(new Image("groupsIcon", new ContextRelativeResource(IMG_PREFIX + (notsel - ? IMG_NOTSEL - : StringUtils.EMPTY) + "groups" + Constants.PNG_EXT))); - - BookmarkablePageLink<Page> resourcesLink = new BookmarkablePageLink<>("resources", Resources.class); - MetaDataRoleAuthorizationStrategy.authorize( - resourcesLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Resources", "list")); - page.add(resourcesLink); - resourcesLink.add(new Image("resourcesIcon", new ContextRelativeResource(IMG_PREFIX + (notsel - ? IMG_NOTSEL - : StringUtils.EMPTY) + "resources" + Constants.PNG_EXT))); - - BookmarkablePageLink<Page> todoLink = new BookmarkablePageLink<>("todo", Todo.class); - MetaDataRoleAuthorizationStrategy.authorize( - todoLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Approval", "list")); - page.add(todoLink); - todoLink.add(new Image("todoIcon", new ContextRelativeResource(IMG_PREFIX + (notsel - ? IMG_NOTSEL - : StringUtils.EMPTY) + "todo" + Constants.PNG_EXT))); - - BookmarkablePageLink<Page> reportLink = new BookmarkablePageLink<>("reports", Reports.class); - MetaDataRoleAuthorizationStrategy.authorize( - reportLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Reports", "list")); - page.add(reportLink); - reportLink.add(new Image("reportsIcon", new ContextRelativeResource(IMG_PREFIX + (notsel - ? IMG_NOTSEL - : StringUtils.EMPTY) + "reports" + Constants.PNG_EXT))); - - BookmarkablePageLink<Page> configurationLink = new BookmarkablePageLink<>("configuration", - Configuration.class); - MetaDataRoleAuthorizationStrategy.authorize( - configurationLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Configuration", "list")); - page.add(configurationLink); - configurationLink.add(new Image("configurationIcon", new ContextRelativeResource(IMG_PREFIX + (notsel - ? IMG_NOTSEL - : StringUtils.EMPTY) + "configuration" + Constants.PNG_EXT))); - - BookmarkablePageLink<Page> taskLink = new BookmarkablePageLink<>("tasks", Tasks.class); - MetaDataRoleAuthorizationStrategy.authorize( - taskLink, WebPage.ENABLE, xmlRolesReader.getEntitlement("Tasks", "list")); - page.add(taskLink); - taskLink.add(new Image("tasksIcon", new ContextRelativeResource(IMG_PREFIX + (notsel - ? IMG_NOTSEL - : StringUtils.EMPTY) + "tasks" + Constants.PNG_EXT))); - - page.add(new BookmarkablePageLink<Page>("logout", Logout.class)); - } - - public void setupEditProfileModal(final WebPage page, final UserSelfRestClient userSelfRestClient) { - // 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<Page> editProfileLink = new AjaxLink<Page>("editProfileLink") { - - private static final long serialVersionUID = -7978723352517770644L; - - @Override - public void onClick(final AjaxRequestTarget target) { - final UserTO userTO; - if (SyncopeSession.get().isAuthenticated()) { - try { - userTO = userSelfRestClient.read(); - } catch (Exception e) { - throw new WicketRuntimeException(e); - } - } else { - userTO = new UserTO(); - } - - editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() { - - private static final long serialVersionUID = -7834632442532690940L; - - @Override - public Page createPage() { - return new UserSelfModalPage(page.getPageReference(), editProfileModalWin, userTO); - } - }); - - 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); - } - - @Override - public Class<? extends Page> getHomePage() { - return SyncopeSession.get().isAuthenticated() ? WelcomePage.class : Login.class; - } - - @Override - public void onUnauthorizedInstantiation(final Component component) { - SyncopeSession.get().invalidate(); - - if (component instanceof Page) { - throw new UnauthorizedInstantiationException(component.getClass()); - } - - throw new RestartResponseAtInterceptPageException(Login.class); - } - - @Override - public boolean hasAnyRole(final org.apache.wicket.authroles.authorization.strategies.role.Roles roles) { - return SyncopeSession.get().hasAnyRole(roles); - } -}
http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java new file mode 100644 index 0000000..d3de8b2 --- /dev/null +++ b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java @@ -0,0 +1,60 @@ +/* + * 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.console; + +import org.apache.syncope.client.console.pages.HomePage; +import org.apache.wicket.Page; +import org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession; +import org.apache.wicket.authroles.authentication.AuthenticatedWebApplication; +import org.apache.wicket.authroles.authentication.pages.SignInPage; +import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.spring.injection.annot.SpringComponentInjector; + +public class SyncopeConsoleApplication extends AuthenticatedWebApplication { + + @Override + protected void init() { + super.init(); + + getComponentInstantiationListeners().add(new SpringComponentInjector(this)); + getSecuritySettings().setAuthorizationStrategy(new MetaDataRoleAuthorizationStrategy(this)); + + MetaDataRoleAuthorizationStrategy.authorize(getHomePage(), SyncopeConsoleSession.AUTHENTICATED); + + mountPage("/home", HomePage.class); + mountPage("/login", SignInPage.class); + } + + @Override + protected Class<? extends AbstractAuthenticatedWebSession> getWebSessionClass() { + return SyncopeConsoleSession.class; + } + + @Override + protected Class<? extends WebPage> getSignInPageClass() { + return SignInPage.class; + } + + @Override + public Class<? extends Page> getHomePage() { + return HomePage.class; + } + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleSession.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleSession.java b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleSession.java new file mode 100644 index 0000000..b63a86a --- /dev/null +++ b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleSession.java @@ -0,0 +1,179 @@ +/* + * 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.console; + +import java.text.DateFormat; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import javax.ws.rs.core.EntityTag; +import javax.ws.rs.core.MediaType; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.cxf.jaxrs.client.WebClient; +import org.apache.syncope.client.lib.SyncopeClient; +import org.apache.syncope.client.lib.SyncopeClientFactoryBean; +import org.apache.syncope.common.lib.to.SyncopeTO; +import org.apache.syncope.common.lib.to.UserTO; +import org.apache.syncope.common.rest.api.service.SyncopeService; +import org.apache.wicket.Session; +import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; +import org.apache.wicket.authroles.authorization.strategies.role.Roles; +import org.apache.wicket.protocol.http.WebApplication; +import org.apache.wicket.request.Request; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +public class SyncopeConsoleSession extends AuthenticatedWebSession { + + private static final long serialVersionUID = 747562246415852166L; + + public static final List<Locale> SUPPORTED_LOCALES = Collections.unmodifiableList(Arrays.asList( + new Locale[] { + Locale.ENGLISH, Locale.ITALIAN, new Locale("pt", "BR") + })); + + public static final String AUTHENTICATED = "AUTHENTICATED"; + + private static final Logger LOG = LoggerFactory.getLogger(SyncopeConsoleSession.class); + + private final SyncopeClientFactoryBean clientFactory; + + private final String version; + + private final SyncopeTO syncopeTO; + + private final Map<Class<?>, Object> services = Collections.synchronizedMap(new HashMap<Class<?>, Object>()); + + private SyncopeClient client; + + private UserTO selfTO; + + private Map<String, Set<String>> auth; + + private Roles roles; + + public static SyncopeConsoleSession get() { + return (SyncopeConsoleSession) Session.get(); + } + + public SyncopeConsoleSession(final Request request) { + super(request); + + ApplicationContext ctx = WebApplicationContextUtils. + getWebApplicationContext(WebApplication.get().getServletContext()); + + clientFactory = ctx.getBean(SyncopeClientFactoryBean.class). + setContentType(SyncopeClientFactoryBean.ContentType.JSON); + String anonymousUser = ctx.getBean("anonymousUser", String.class); + String anonymousKey = ctx.getBean("anonymousKey", String.class); + + version = ctx.getBean("version", String.class); + + syncopeTO = clientFactory.create(anonymousUser, anonymousKey).getService(SyncopeService.class).info(); + } + + public String getVersion() { + return version; + } + + public SyncopeTO getSyncopeTO() { + return syncopeTO; + } + + @Override + public boolean authenticate(final String username, final String password) { + boolean authenticated = false; + + try { + client = clientFactory.create(username, password); + + Pair<Map<String, Set<String>>, UserTO> self = client.self(); + auth = self.getKey(); + selfTO = self.getValue(); + + authenticated = true; + } catch (Exception e) { + LOG.error("Authentication failed", e); + } + + return authenticated; + } + + public UserTO getSelfTO() { + return selfTO; + } + + @Override + public Roles getRoles() { + if (isSignedIn() && roles == null && auth != null) { + roles = new Roles(auth.keySet().toArray(new String[] {})); + roles.add(AUTHENTICATED); + } + + return roles; + } + + @SuppressWarnings("unchecked") + private <T> T getCachedService(final Class<T> serviceClass) { + T service; + if (services.containsKey(serviceClass)) { + service = (T) services.get(serviceClass); + } else { + service = client.getService(serviceClass); + services.put(serviceClass, service); + } + + return service; + } + + public <T> T getService(final Class<T> serviceClass) { + return getCachedService(serviceClass); + } + + public <T> T getService(final String etag, final Class<T> serviceClass) { + T serviceInstance = getCachedService(serviceClass); + WebClient.client(serviceInstance).match(new EntityTag(etag), false); + + return serviceInstance; + } + + public <T> T getService(final MediaType mediaType, final Class<T> serviceClass) { + T service = client.getService(serviceClass); + WebClient.client(service).type(mediaType).accept(mediaType); + + return service; + } + + public <T> void resetClient(final Class<T> service) { + T serviceInstance = getCachedService(service); + WebClient.client(serviceInstance).reset(); + } + + public DateFormat getDateFormat() { + final Locale locale = getLocale() == null ? Locale.ENGLISH : getLocale(); + + return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale); + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/SyncopeRequestCycleListener.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeRequestCycleListener.java b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeRequestCycleListener.java deleted file mode 100644 index 8b27260..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeRequestCycleListener.java +++ /dev/null @@ -1,84 +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.console; - -import java.security.AccessControlException; -import javax.ws.rs.BadRequestException; -import javax.xml.ws.WebServiceException; -import org.apache.syncope.client.console.pages.ErrorPage; -import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.wicket.Page; -import org.apache.wicket.authorization.UnauthorizedInstantiationException; -import org.apache.wicket.core.request.handler.PageProvider; -import org.apache.wicket.core.request.handler.RenderPageRequestHandler; -import org.apache.wicket.markup.html.pages.ExceptionErrorPage; -import org.apache.wicket.model.StringResourceModel; -import org.apache.wicket.protocol.http.PageExpiredException; -import org.apache.wicket.request.IRequestHandler; -import org.apache.wicket.request.cycle.AbstractRequestCycleListener; -import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SyncopeRequestCycleListener extends AbstractRequestCycleListener { - - /** - * Logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(SyncopeRequestCycleListener.class); - - /** - * {@inheritDoc} - */ - @Override - public IRequestHandler onException(final RequestCycle cycle, final Exception e) { - LOG.error("Exception found", e); - - PageParameters errorParameters = new PageParameters(); - errorParameters.add("errorTitle", new StringResourceModel("alert", null).getString()); - - final Page errorPage; - if (e instanceof UnauthorizedInstantiationException) { - errorParameters.add("errorMessage", - new StringResourceModel("unauthorizedInstantiationException", null).getString()); - - errorPage = new ErrorPage(errorParameters); - } 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() instanceof BadRequestException || e.getCause() instanceof WebServiceException - || e.getCause() instanceof SyncopeClientException) { - - errorParameters.add("errorMessage", new StringResourceModel("restClientException", null).getString()); - - errorPage = new ErrorPage(errorParameters); - } else { - // redirect to default Wicket error page - errorPage = new ExceptionErrorPage(e, null); - } - - return new RenderPageRequestHandler(new PageProvider(errorPage)); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/SyncopeSession.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeSession.java b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeSession.java deleted file mode 100644 index fc7f7b9..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeSession.java +++ /dev/null @@ -1,185 +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.console; - -import java.text.DateFormat; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import javax.ws.rs.core.EntityTag; -import javax.ws.rs.core.MediaType; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.cxf.jaxrs.client.WebClient; -import org.apache.syncope.client.lib.SyncopeClient; -import org.apache.syncope.client.lib.SyncopeClientFactoryBean; -import org.apache.syncope.common.lib.to.SyncopeTO; -import org.apache.syncope.common.rest.api.service.SyncopeService; -import org.apache.wicket.Session; -import org.apache.wicket.authroles.authorization.strategies.role.Roles; -import org.apache.wicket.protocol.http.WebApplication; -import org.apache.wicket.protocol.http.WebSession; -import org.apache.wicket.request.Request; -import org.springframework.context.ApplicationContext; -import org.springframework.web.context.support.WebApplicationContextUtils; - -/** - * Custom Syncope Session class. - */ -public class SyncopeSession extends WebSession { - - private static final long serialVersionUID = 7743446298924805872L; - - public static final List<Locale> SUPPORTED_LOCALES = Arrays.asList(new Locale[] { - Locale.ENGLISH, Locale.ITALIAN, new Locale("pt", "BR") }); - - private String username; - - private String password; - - private String version; - - private Roles roles = new Roles(); - - private final SyncopeClientFactoryBean clientFactory; - - private final String anonymousUser; - - private final String anonymousKey; - - private final SyncopeTO syncopeTO; - - private final Map<Integer, SyncopeClient> clients = - Collections.synchronizedMap(new HashMap<Integer, SyncopeClient>()); - - public static SyncopeSession get() { - return (SyncopeSession) Session.get(); - } - - public SyncopeSession(final Request request) { - super(request); - - final ApplicationContext ctx = WebApplicationContextUtils. - getWebApplicationContext(WebApplication.get().getServletContext()); - - clientFactory = ctx.getBean(SyncopeClientFactoryBean.class). - setContentType(SyncopeClientFactoryBean.ContentType.JSON); - anonymousUser = ctx.getBean("anonymousUser", String.class); - anonymousKey = ctx.getBean("anonymousKey", String.class); - - syncopeTO = clientFactory.create(anonymousUser, anonymousKey).getService(SyncopeService.class).info(); - } - - public SyncopeTO getSyncopeTO() { - return syncopeTO; - } - - public void resetClients() { - clients.clear(); - } - - public <T> T getService(final Class<T> service) { - return getService(service, this.username, this.password); - } - - public <T> T getService(final String etag, final Class<T> service) { - T serviceInstance = getService(service, this.username, this.password); - WebClient.client(serviceInstance).match(new EntityTag(etag), false); - - return serviceInstance; - } - - public <T> void resetClient(final Class<T> service) { - T serviceInstance = getService(service, this.username, this.password); - WebClient.client(serviceInstance).reset(); - } - - public <T> T getService(final MediaType mediaType, final Class<T> serviceClass) { - T service; - - synchronized (clientFactory) { - SyncopeClientFactoryBean.ContentType preType = clientFactory.getContentType(); - - clientFactory.setContentType(SyncopeClientFactoryBean.ContentType.fromString(mediaType.toString())); - service = clientFactory.create(username, password).getService(serviceClass); - clientFactory.setContentType(preType); - } - - return service; - } - - public <T> T getAnonymousService(final Class<T> serviceClass) { - return getService(serviceClass, this.anonymousUser, this.anonymousKey); - } - - public <T> T getService(final Class<T> serviceClass, final String username, final String password) { - final int clientKey = new HashCodeBuilder().append(username).append(password).toHashCode(); - - if (!clients.containsKey(clientKey)) { - clients.put(clientKey, clientFactory.create(username, password)); - } - - return clients.get(clientKey).getService(serviceClass); - } - - public String getUsername() { - return username; - } - - public void setUsername(final String username) { - this.username = username; - } - - public void setPassword(final String password) { - this.password = password; - } - - public String getVersion() { - return version; - } - - public void setVersion(final String version) { - this.version = version; - } - - public void setEntitlements(final String[] entitlements) { - String[] defensiveCopy = entitlements.clone(); - roles = new Roles(defensiveCopy); - } - - public Roles getEntitlements() { - return roles; - } - - public boolean isAuthenticated() { - return getUsername() != null; - } - - public boolean hasAnyRole(final Roles roles) { - return this.roles.hasAnyRole(roles); - } - - public DateFormat getDateFormat() { - final Locale locale = getLocale() == null ? Locale.ENGLISH : getLocale(); - - return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/annotations/BinaryPreview.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/annotations/BinaryPreview.java b/client/console/src/main/java/org/apache/syncope/client/console/annotations/BinaryPreview.java new file mode 100644 index 0000000..51e22bc --- /dev/null +++ b/client/console/src/main/java/org/apache/syncope/client/console/annotations/BinaryPreview.java @@ -0,0 +1,34 @@ +/* + * 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.console.annotations; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface BinaryPreview { + + public String[] mimeTypes() default {}; + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/annotations/ExtensionPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/annotations/ExtensionPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/annotations/ExtensionPanel.java new file mode 100644 index 0000000..26b359f --- /dev/null +++ b/client/console/src/main/java/org/apache/syncope/client/console/annotations/ExtensionPanel.java @@ -0,0 +1,34 @@ +/* + * 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.console.annotations; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ExtensionPanel { + + public String value(); + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/ActionTableCheckGroup.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/ActionTableCheckGroup.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/ActionTableCheckGroup.java deleted file mode 100644 index 453e0c0..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/ActionTableCheckGroup.java +++ /dev/null @@ -1,40 +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.console.commons; - -import java.util.Collection; -import org.apache.wicket.markup.html.form.CheckGroup; -import org.apache.wicket.model.IModel; - -public class ActionTableCheckGroup<T> extends CheckGroup<T> { - - private static final long serialVersionUID = 1288270558573401394L; - - public ActionTableCheckGroup(final String id, final Collection<T> collection) { - super(id, collection); - } - - public ActionTableCheckGroup(final String id, final IModel<Collection<T>> model) { - super(id, model); - } - - public boolean isCheckable(final T element) { - return true; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/AttributableDataProvider.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/AttributableDataProvider.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/AttributableDataProvider.java deleted file mode 100644 index 91a797e..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/AttributableDataProvider.java +++ /dev/null @@ -1,101 +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.console.commons; - -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import org.apache.syncope.client.console.rest.AbstractSubjectRestClient; -import org.apache.syncope.common.lib.to.AbstractAttributableTO; -import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder; -import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; -import org.apache.wicket.model.CompoundPropertyModel; -import org.apache.wicket.model.IModel; - -public class AttributableDataProvider extends SortableDataProvider<AbstractAttributableTO, String> { - - private static final long serialVersionUID = 6267494272884913376L; - - private final SortableAttributableProviderComparator comparator; - - private String fiql = null; - - private final int paginatorRows; - - private final boolean filtered; - - private final AbstractSubjectRestClient restClient; - - public AttributableDataProvider(final AbstractSubjectRestClient restClient, - final int paginatorRows, final boolean filtered) { - - super(); - - this.restClient = restClient; - this.filtered = filtered; - this.paginatorRows = paginatorRows; - - // default sorting - setSort("key", SortOrder.ASCENDING); - - this.comparator = new SortableAttributableProviderComparator(this); - } - - public void setFIQL(final String fiql) { - this.fiql = fiql; - } - - @Override - public Iterator<? extends AbstractAttributableTO> iterator(final long first, final long count) { - List<? extends AbstractAttributableTO> result; - - final int page = ((int) first / paginatorRows); - - if (filtered) { - result = fiql == null - ? Collections.<AbstractAttributableTO>emptyList() - : restClient.search(fiql, (page < 0 ? 0 : page) + 1, paginatorRows, getSort()); - } else { - result = restClient.list((page < 0 ? 0 : page) + 1, paginatorRows, getSort()); - } - - Collections.sort(result, comparator); - return result.iterator(); - } - - @Override - public long size() { - long result; - - if (filtered) { - result = fiql == null - ? 0 - : restClient.searchCount(fiql); - } else { - result = restClient.count(); - } - - return result; - } - - @Override - public IModel<AbstractAttributableTO> model(final AbstractAttributableTO object) { - return new CompoundPropertyModel<>(object); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/CloseOnESCBehavior.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/CloseOnESCBehavior.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/CloseOnESCBehavior.java deleted file mode 100644 index 2e62431..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/CloseOnESCBehavior.java +++ /dev/null @@ -1,55 +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.console.commons; - -import org.apache.wicket.Component; -import org.apache.wicket.ajax.AjaxEventBehavior; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.attributes.AjaxCallListener; -import org.apache.wicket.ajax.attributes.AjaxRequestAttributes; -import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; - -public class CloseOnESCBehavior extends AjaxEventBehavior { - - private static final long serialVersionUID = 5826308247642534260L; - - public CloseOnESCBehavior(String event) { - super(event); - } - - @Override - protected void onEvent(final AjaxRequestTarget target) { - ModalWindow.closeCurrent(target); - } - - @Override - protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { - super.updateAjaxAttributes(attributes); - - attributes.getAjaxCallListeners().add(new AjaxCallListener() { - - private static final long serialVersionUID = 7160235486520935153L; - - @Override - public CharSequence getPrecondition(final Component aComponent) { - return " if(Wicket.Event.keyCode(attrs.event) != 27){return false;}"; - } - }); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/DateFormatROModel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/DateFormatROModel.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/DateFormatROModel.java deleted file mode 100644 index e72b7d0..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/DateFormatROModel.java +++ /dev/null @@ -1,50 +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.console.commons; - -import java.util.Date; -import org.apache.syncope.client.console.SyncopeSession; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.PropertyModel; - -public class DateFormatROModel implements IModel<String> { - - private static final long serialVersionUID = 6677274580927636121L; - - private final PropertyModel model; - - public DateFormatROModel(final PropertyModel model) { - this.model = model; - } - - @Override - public String getObject() { - return model.getObject() == null - ? "" - : SyncopeSession.get().getDateFormat().format((Date) model.getObject()); - } - - @Override - public void setObject(final String object) { - } - - @Override - public void detach() { - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/GroupTreeBuilder.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/GroupTreeBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/GroupTreeBuilder.java deleted file mode 100644 index bc7d21b..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/GroupTreeBuilder.java +++ /dev/null @@ -1,128 +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.console.commons; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreeModel; -import org.apache.syncope.client.console.rest.GroupRestClient; -import org.apache.syncope.common.lib.to.GroupTO; -import org.springframework.beans.factory.annotation.Autowired; - -public class GroupTreeBuilder { - - @Autowired - private GroupRestClient restClient; - - private final GroupTOComparator comparator = new GroupTOComparator(); - - private List<GroupTO> allGroups; - - private List<GroupTO> getChildGroups(final long parentGroupId, final List<GroupTO> groups) { - List<GroupTO> result = new ArrayList<>(); - for (GroupTO group : groups) { - if (group.getParent() == parentGroupId) { - result.add(group); - } - } - - Collections.sort(result, comparator); - return result; - } - - private void populateSubtree(final DefaultMutableTreeNode subRoot, final List<GroupTO> groups) { - GroupTO group = (GroupTO) subRoot.getUserObject(); - - DefaultMutableTreeNode child; - for (GroupTO subGroupTO : getChildGroups(group.getKey(), groups)) { - child = new DefaultMutableTreeNode(subGroupTO); - subRoot.add(child); - populateSubtree(child, groups); - } - } - - public List<GroupTO> getAllGroups() { - return this.allGroups; - } - - public TreeModel build() { - this.allGroups = this.restClient.list(); - return build(this.allGroups); - } - - public TreeModel build(final List<GroupTO> groups) { - DefaultMutableTreeNode fakeroot = new DefaultMutableTreeNode(new FakeRootGroupTO()); - - populateSubtree(fakeroot, groups); - - return new DefaultTreeModel(fakeroot); - } - - public GroupTO findGroup(final long groupKey) { - GroupTO found = null; - if (getAllGroups() != null) { - for (GroupTO groupTO : getAllGroups()) { - if (groupTO.getKey() == groupKey) { - found = groupTO; - } - } - } - return found; - } - - private static class GroupTOComparator implements Comparator<GroupTO>, Serializable { - - private static final long serialVersionUID = 7085057398406518811L; - - @Override - public int compare(final GroupTO r1, final GroupTO r2) { - if (r1.getKey() < r2.getKey()) { - return -1; - } - if (r1.getKey() == r2.getKey()) { - return 0; - } - - return 1; - } - } - - private static class FakeRootGroupTO extends GroupTO { - - private static final long serialVersionUID = 4839183625773925488L; - - public FakeRootGroupTO() { - super(); - - setKey(0); - setName(""); - setParent(-1); - } - - @Override - public String getDisplayName() { - return ""; - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/JexlHelpUtils.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/JexlHelpUtils.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/JexlHelpUtils.java deleted file mode 100644 index b29d180..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/JexlHelpUtils.java +++ /dev/null @@ -1,61 +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.console.commons; - -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.link.ExternalLink; - -public final class JexlHelpUtils { - - private static final String JEXL_SYNTAX_URL = "http://commons.apache.org/jexl/reference/syntax.html"; - - private JexlHelpUtils() { - // private constructor for static utility class - } - - public static WebMarkupContainer getJexlHelpWebContainer(final String wicketId) { - final WebMarkupContainer jexlHelp = new WebMarkupContainer(wicketId); - jexlHelp.setVisible(false); - jexlHelp.setOutputMarkupPlaceholderTag(true); - jexlHelp.setOutputMarkupId(true); - jexlHelp.add(new ExternalLink("jexlLink", JEXL_SYNTAX_URL)); - return jexlHelp; - } - - public static AjaxLink<Void> getAjaxLink(final WebMarkupContainer wmc, final String wicketId) { - AjaxLink<Void> questionMarkJexlHelp = new AjaxLink<Void>(wicketId) { - - private static final long serialVersionUID = -1838017408000591382L; - - private boolean toogle = false; - - @Override - public void onClick(final AjaxRequestTarget target) { - // using bitwise inversion as suggested by - // http://pmd.sourceforge.net/pmd-4.2.5/rules/controversial.html#BooleanInversion - toogle ^= true; - wmc.setVisible(toogle); - target.add(wmc); - } - }; - return questionMarkJexlHelp; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/MapChoiceRenderer.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/MapChoiceRenderer.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/MapChoiceRenderer.java deleted file mode 100644 index 118db6d..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/MapChoiceRenderer.java +++ /dev/null @@ -1,43 +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.console.commons; - -import java.util.Map; -import org.apache.wicket.markup.html.form.IChoiceRenderer; - -public class MapChoiceRenderer<T, K> implements IChoiceRenderer<T> { - - private static final long serialVersionUID = -7452881117778186644L; - - private final Map<T, K> map; - - public MapChoiceRenderer(final Map<T, K> map) { - this.map = map; - } - - @Override - public Object getDisplayValue(final T key) { - return map.get(key); - } - - @Override - public String getIdValue(final T key, final int index) { - return key.toString(); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/PreferenceManager.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/PreferenceManager.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/PreferenceManager.java deleted file mode 100644 index a4e246e..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/PreferenceManager.java +++ /dev/null @@ -1,176 +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.console.commons; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.core.type.TypeReference; -import java.io.IOException; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.math.NumberUtils; -import org.apache.wicket.request.Request; -import org.apache.wicket.request.Response; -import org.apache.wicket.util.cookies.CookieDefaults; -import org.apache.wicket.util.cookies.CookieUtils; -import org.apache.wicket.util.crypt.Base64; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.util.StringUtils; - -public class PreferenceManager { - - /** - * Logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(PreferenceManager.class); - - private static final String PREFMAN_KEY = "prefMan"; - - private static final int ONE_YEAR_TIME = 60 * 60 * 24 * 365; - - private static final TypeReference<Map<String, String>> MAP_TYPE_REF = new TypeReference<Map<String, String>>() { - }; - - private static final List<Integer> PAGINATOR_CHOICES = Arrays.asList(new Integer[] { 10, 25, 50 }); - - private final ObjectMapper mapper; - - private final CookieUtils cookieUtils; - - public PreferenceManager() { - this.mapper = new ObjectMapper(); - - CookieDefaults cookieDefaults = new CookieDefaults(); - cookieDefaults.setMaxAge(ONE_YEAR_TIME); - this.cookieUtils = new CookieUtils(cookieDefaults); - } - - public List<Integer> getPaginatorChoices() { - return PAGINATOR_CHOICES; - } - - private Map<String, String> getPrefs(final String value) { - Map<String, String> prefs; - try { - if (StringUtils.hasText(value)) { - prefs = mapper.readValue(value, MAP_TYPE_REF); - } else { - throw new Exception("Invalid cookie value '" + value + "'"); - } - } catch (Exception e) { - LOG.debug("No preferences found", e); - prefs = new HashMap<String, String>(); - } - - return prefs; - } - - private String setPrefs(final Map<String, String> prefs) throws IOException { - StringWriter writer = new StringWriter(); - mapper.writeValue(writer, prefs); - - return writer.toString(); - } - - public String get(final Request request, final String key) { - String result = null; - - String prefString = cookieUtils.load(PREFMAN_KEY); - if (prefString != null) { - final Map<String, String> prefs = getPrefs(new String(Base64.decodeBase64(prefString.getBytes()))); - result = prefs.get(key); - } - - return result; - } - - public Integer getPaginatorRows(final Request request, final String key) { - Integer result = getPaginatorChoices().get(0); - - String value = get(request, key); - if (value != null) { - result = NumberUtils.toInt(value, 10); - } - - return result; - } - - public List<String> getList(final Request request, final String key) { - final List<String> result = new ArrayList<String>(); - - final String compound = get(request, key); - - if (StringUtils.hasText(compound)) { - String[] items = compound.split(";"); - result.addAll(Arrays.asList(items)); - } - - return result; - } - - public void set(final Request request, final Response response, final Map<String, List<String>> prefs) { - Map<String, String> current = new HashMap<>(); - - String prefString = cookieUtils.load(PREFMAN_KEY); - if (prefString != null) { - current.putAll(getPrefs(new String(Base64.decodeBase64(prefString.getBytes())))); - } - - // after retrieved previous setting in order to overwrite the key ... - for (Map.Entry<String, List<String>> entry : prefs.entrySet()) { - current.put(entry.getKey(), StringUtils.collectionToDelimitedString(entry.getValue(), ";")); - } - - try { - cookieUtils.save(PREFMAN_KEY, new String(Base64.encodeBase64(setPrefs(current).getBytes()))); - } catch (IOException e) { - LOG.error("Could not save {} info: {}", getClass().getSimpleName(), current, e); - } - } - - public void set(final Request request, final Response response, final String key, final String value) { - String prefString = cookieUtils.load(PREFMAN_KEY); - - final Map<String, String> current = new HashMap<>(); - if (prefString != null) { - current.putAll(getPrefs(new String(Base64.decodeBase64(prefString.getBytes())))); - } - - // after retrieved previous setting in order to overwrite the key ... - current.put(key, value); - - try { - cookieUtils.save(PREFMAN_KEY, new String(Base64.encodeBase64(setPrefs(current).getBytes()))); - } catch (IOException e) { - LOG.error("Could not save {} info: {}", getClass().getSimpleName(), current, e); - } - } - - public void setList(final Request request, final Response response, final String key, final List<String> values) { - set(request, response, key, StringUtils.collectionToDelimitedString(values, ";")); - } - - public void setList(final Request request, final Response response, final Map<String, List<String>> prefs) { - set(request, response, prefs); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/SchemaModalPageFactory.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/SchemaModalPageFactory.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/SchemaModalPageFactory.java deleted file mode 100644 index 38a60fa..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/SchemaModalPageFactory.java +++ /dev/null @@ -1,58 +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.console.commons; - -import org.apache.syncope.client.console.pages.AbstractSchemaModalPage; -import org.apache.syncope.client.console.pages.DerSchemaModalPage; -import org.apache.syncope.client.console.pages.PlainSchemaModalPage; -import org.apache.syncope.client.console.pages.VirSchemaModalPage; -import org.apache.syncope.common.lib.types.AttributableType; -import org.apache.syncope.common.lib.types.SchemaType; - -public final class SchemaModalPageFactory { - - private static final long serialVersionUID = -3533177688264693505L; - - private SchemaModalPageFactory() { - // empty constructor for static utility class - } - - @SuppressWarnings("unchecked") - public static <T extends AbstractSchemaModalPage> T getSchemaModalPage( - final AttributableType entity, final SchemaType schemaType) { - - T page; - - switch (schemaType) { - case DERIVED: - page = (T) new DerSchemaModalPage(entity); - break; - - case VIRTUAL: - page = (T) new VirSchemaModalPage(entity); - break; - - default: - page = (T) new PlainSchemaModalPage(entity); - break; - } - - return page; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/SelectChoiceRenderer.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/SelectChoiceRenderer.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/SelectChoiceRenderer.java deleted file mode 100644 index 7b9164d..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/SelectChoiceRenderer.java +++ /dev/null @@ -1,40 +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.console.commons; - -import org.apache.wicket.markup.html.form.IChoiceRenderer; - -public class SelectChoiceRenderer<T> implements IChoiceRenderer<T> { - - private static final long serialVersionUID = -3242441544405909243L; - - @Override - public Object getDisplayValue(T obj) { - if (obj instanceof SelectOption) { - return ((SelectOption) obj).getDisplayValue(); - } else { - return obj.toString(); - } - } - - @Override - public String getIdValue(T obj, int i) { - return obj.toString(); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/SelectOption.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/SelectOption.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/SelectOption.java deleted file mode 100644 index 839df70..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/SelectOption.java +++ /dev/null @@ -1,72 +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.console.commons; - -import java.io.Serializable; -import org.apache.commons.lang3.builder.HashCodeBuilder; - -public class SelectOption implements Serializable { - - private static final long serialVersionUID = 2961127533930849828L; - - private String displayValue; - - private String keyValue; - - public SelectOption(final String displayValue, final String keyValue) { - this.displayValue = displayValue; - this.keyValue = keyValue; - } - - public String getDisplayValue() { - return displayValue; - } - - public void setDisplayValue(final String displayValue) { - this.displayValue = displayValue; - } - - public String getKeyValue() { - return keyValue; - } - - public void setKeyValue(final String keyValue) { - this.keyValue = keyValue; - } - - @Override - public boolean equals(final Object obj) { - if (obj == null || !(obj instanceof SelectOption)) { - return false; - } - - return (keyValue == null && ((SelectOption) obj).keyValue == null) || keyValue != null - && keyValue.equals(((SelectOption) obj).keyValue); - } - - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public String toString() { - return keyValue; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/XMLRolesReader.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/XMLRolesReader.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/XMLRolesReader.java deleted file mode 100644 index 3a0b446..0000000 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/XMLRolesReader.java +++ /dev/null @@ -1,118 +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.console.commons; - -import java.util.HashMap; -import java.util.Map; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * XMLRolesReader singleton class. - */ -public class XMLRolesReader { - - /** - * Logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(XMLRolesReader.class); - - private String authorizations; - - private Map<Pair<String, String>, String> authMap; - - public void setAuthorizations(final String authorizations) { - this.authorizations = authorizations; - } - - private void init() { - authMap = new HashMap<Pair<String, String>, String>(); - - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware(true); - try { - DocumentBuilder db = dbf.newDocumentBuilder(); - Document doc = db.parse(getClass().getResource("/" + authorizations).openStream()); - doc.getDocumentElement().normalize(); - - Node authNode = null; - NodeList root = doc.getChildNodes(); - for (int i = 0; i < root.getLength() && authNode == null; i++) { - if ("auth".equals(root.item(i).getNodeName())) { - authNode = root.item(i); - } - } - if (authNode == null) { - throw new IllegalArgumentException("Could not find root <auth> node"); - } - - NodeList pages = authNode.getChildNodes(); - for (int i = 0; i < pages.getLength(); i++) { - if ("page".equals(pages.item(i).getNodeName())) { - String page = pages.item(i).getAttributes().getNamedItem("id").getTextContent(); - - NodeList actions = pages.item(i).getChildNodes(); - for (int j = 0; j < actions.getLength(); j++) { - if ("action".equals(actions.item(j).getNodeName())) { - String action = actions.item(j).getAttributes().getNamedItem("id").getTextContent(); - - NodeList entitlements = actions.item(j).getChildNodes(); - for (int k = 0; k < entitlements.getLength(); k++) { - if ("entitlement".equals(entitlements.item(k).getNodeName())) { - String entitlement = entitlements.item(k).getTextContent(); - authMap.put(new ImmutablePair<String, String>(page, action), entitlement); - } - } - } - } - } - } - } catch (Exception e) { - LOG.error("While initializing parsing of {}", authorizations, e); - } - } - - /** - * Get entitlement required for page / action. - * - * @param pageId page - * @param actionId action - * @return entitlement required - */ - public String getEntitlement(final String pageId, final String actionId) { - synchronized (this) { - if (authMap == null) { - init(); - } - } - - Pair<String, String> key = new ImmutablePair<String, String>(pageId, actionId); - return authMap.containsKey(key) - ? authMap.get(key) - : StringUtils.EMPTY; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/status/AbstractStatusBeanProvider.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/AbstractStatusBeanProvider.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/AbstractStatusBeanProvider.java index c10f55c..799b243 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/AbstractStatusBeanProvider.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/AbstractStatusBeanProvider.java @@ -36,7 +36,7 @@ public abstract class AbstractStatusBeanProvider extends SortableDataProvider<St public AbstractStatusBeanProvider(final String sort) { //Default sorting setSort(sort, SortOrder.ASCENDING); - comparator = new SortableDataProviderComparator<StatusBean>(this); + comparator = new SortableDataProviderComparator<>(this); } @Override http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusBean.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusBean.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusBean.java index 47d0086..1e92898 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusBean.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusBean.java @@ -43,7 +43,7 @@ public class StatusBean implements Serializable { private boolean linked = true; - public StatusBean(final AbstractAttributableTO attributable, String resourceName) { + public StatusBean(final AbstractAttributableTO attributable, final String resourceName) { this.attributableKey = attributable.getKey(); this.attributableName = attributable instanceof UserTO ? ((UserTO) attributable).getUsername() : ((GroupTO) attributable).getName(); http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java index 391d202..7a4a157 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java @@ -22,13 +22,11 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.syncope.client.console.commons.ConnIdSpecialAttributeName; import org.apache.syncope.client.console.commons.Constants; import org.apache.syncope.client.console.panels.ImagePanel; -import org.apache.syncope.client.console.panels.StatusPanel; import org.apache.syncope.client.console.rest.AbstractSubjectRestClient; import org.apache.syncope.common.lib.mod.StatusMod; import org.apache.syncope.common.lib.to.AbstractAttributableTO; @@ -36,7 +34,6 @@ import org.apache.syncope.common.lib.to.AbstractSubjectTO; import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.common.lib.to.ConnObjectTO; import org.apache.wicket.Component; -import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.behavior.Behavior; import org.apache.wicket.markup.ComponentTag; import org.apache.wicket.markup.html.image.Image; @@ -48,9 +45,6 @@ public class StatusUtils implements Serializable { private static final long serialVersionUID = 7238009174387184309L; - /** - * Logger. - */ private static final Logger LOG = LoggerFactory.getLogger(StatusUtils.class); private static final String IMG_PREFIX = "/img/statuses/"; @@ -170,42 +164,6 @@ public class StatusUtils implements Serializable { return statusMod; } - public static void update( - final AbstractAttributableTO attributable, - final StatusPanel statusPanel, - final AjaxRequestTarget target, - final Collection<String> resourcesToAdd, - final Collection<String> resourcesToRemove) { - - if (statusPanel != null) { - Map<String, StatusBean> statusMap = new LinkedHashMap<>(); - for (StatusBean statusBean : statusPanel.getStatusBeans()) { - statusMap.put(statusBean.getResourceName(), statusBean); - } - - for (String resourceName : resourcesToAdd) { - if (!statusMap.keySet().contains(resourceName)) { - StatusBean statusBean; - if (statusPanel.getInitialStatusBeanMap().containsKey(resourceName)) { - statusBean = statusPanel.getInitialStatusBeanMap().get(resourceName); - } else { - statusBean = new StatusBean(attributable, resourceName); - statusBean.setStatus(Status.NOT_YET_SUBMITTED); - } - - statusMap.put(statusBean.getResourceName(), statusBean); - } - } - - for (String resource : resourcesToRemove) { - statusMap.remove(resource); - } - - statusPanel.updateStatusBeans(new ArrayList<>(statusMap.values())); - target.add(statusPanel); - } - } - public ConnObjectTO getConnObjectTO( final Long attributableId, final String resourceName, final List<ConnObjectWrapper> objects) { http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/init/ImplementationClassNamesLoader.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/init/ImplementationClassNamesLoader.java b/client/console/src/main/java/org/apache/syncope/client/console/init/ImplementationClassNamesLoader.java index 0ff7282..6b0666e 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/init/ImplementationClassNamesLoader.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/init/ImplementationClassNamesLoader.java @@ -25,7 +25,7 @@ import java.util.List; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.syncope.client.console.panels.AbstractExtensionPanel; -import org.apache.syncope.client.console.BinaryPreview; +import org.apache.syncope.client.console.annotations.BinaryPreview; import org.apache.syncope.client.console.wicket.markup.html.form.preview.AbstractBinaryPreviewer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/syncope/blob/39f8a069/client/console/src/main/java/org/apache/syncope/client/console/pages/AbstractBasePage.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/AbstractBasePage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/AbstractBasePage.java index 830f369..38408f9 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/pages/AbstractBasePage.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/pages/AbstractBasePage.java @@ -19,7 +19,6 @@ package org.apache.syncope.client.console.pages; import org.apache.syncope.client.console.commons.Constants; -import org.apache.syncope.client.console.commons.XMLRolesReader; import org.apache.syncope.client.console.init.MIMETypesLoader; import org.apache.syncope.client.console.panels.NotificationPanel; import org.apache.syncope.client.console.rest.ConfigurationRestClient; @@ -44,9 +43,6 @@ public class AbstractBasePage extends WebPage { private static final long serialVersionUID = 8611724965544132636L; - /** - * Logger. - */ protected static final Logger LOG = LoggerFactory.getLogger(AbstractBasePage.class); protected static final String TASKS = "Tasks"; @@ -62,9 +58,6 @@ public class AbstractBasePage extends WebPage { protected final HeaderItem meta = new MetaHeaderItem("X-UA-Compatible", "IE=edge"); @SpringBean - protected XMLRolesReader xmlRolesReader; - - @SpringBean protected UserRestClient userRestClient; @SpringBean @@ -118,8 +111,8 @@ public class AbstractBasePage extends WebPage { return modalResult; } - public void setModalResult(final boolean operationResult) { - this.modalResult = operationResult; + public void setModalResult(final boolean modalResult) { + this.modalResult = modalResult; } @Override
