Author: ilgrosso
Date: Mon Jul 22 11:18:39 2013
New Revision: 1505658
URL: http://svn.apache.org/r1505658
Log:
[SYNCOPE-286] Removing Spring MVC from admin console
Added:
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientExceptionMapper.java
- copied, changed from r1505625,
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/utils/RestClientExceptionMapper.java
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientFactoryBean.java
(with props)
Removed:
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/utils/
Modified:
syncope/trunk/common/pom.xml
syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
syncope/trunk/console/pom.xml
syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/PreferenceManager.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/XMLRolesReader.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ConnectorModalPage.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Logout.java
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Todo.java
syncope/trunk/console/src/main/resources/applicationContext.xml
syncope/trunk/console/src/main/resources/configuration.properties
syncope/trunk/console/src/main/resources/logback.xml
syncope/trunk/console/src/test/resources/configuration.properties
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
syncope/trunk/core/src/test/resources/restClientContext.xml
Copied:
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientExceptionMapper.java
(from r1505625,
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/utils/RestClientExceptionMapper.java)
URL:
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientExceptionMapper.java?p2=syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientExceptionMapper.java&p1=syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/utils/RestClientExceptionMapper.java&r1=1505625&r2=1505658&rev=1505658&view=diff
==============================================================================
---
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/utils/RestClientExceptionMapper.java
(original)
+++
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientExceptionMapper.java
Mon Jul 22 11:18:39 2013
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.syncope.client.rest.utils;
+package org.apache.syncope.client.rest;
import java.security.AccessControlException;
import java.util.ArrayList;
Added:
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientFactoryBean.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientFactoryBean.java?rev=1505658&view=auto
==============================================================================
---
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientFactoryBean.java
(added)
+++
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientFactoryBean.java
Mon Jul 22 11:18:39 2013
@@ -0,0 +1,48 @@
+/*
+ * 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.rest;
+
+import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.jaxrs.client.WebClient;
+
+public class RestClientFactoryBean extends JAXRSClientFactoryBean {
+
+ private String contentType;
+
+ public RestClientFactoryBean() {
+ super();
+ }
+
+ public void setContentType(final String contentType) {
+ this.contentType = contentType;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public <T> T createServiceInstance(final Class<T> serviceClass, final
String username, final String password) {
+ setUsername(username);
+ setPassword(password);
+ setServiceClass(serviceClass);
+ final T serviceInstance = create(serviceClass);
+
WebClient.client(serviceInstance).type(getContentType()).accept(getContentType());
+ return serviceInstance;
+ }
+}
Propchange:
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientFactoryBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientFactoryBean.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange:
syncope/trunk/client/src/main/java/org/apache/syncope/client/rest/RestClientFactoryBean.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: syncope/trunk/common/pom.xml
URL:
http://svn.apache.org/viewvc/syncope/trunk/common/pom.xml?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
--- syncope/trunk/common/pom.xml (original)
+++ syncope/trunk/common/pom.xml Mon Jul 22 11:18:39 2013
@@ -54,21 +54,13 @@ under the License.
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
-
+
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.module</groupId>
- <artifactId>jackson-module-jaxb-annotations</artifactId>
- </dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
Modified:
syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
(original)
+++
syncope/trunk/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java
Mon Jul 22 11:18:39 2013
@@ -33,7 +33,6 @@ import org.apache.syncope.common.to.Sync
import org.apache.syncope.common.to.ValidatorTO;
import org.apache.syncope.common.types.AuditLoggerName;
import org.apache.syncope.common.types.SyncopeLoggerLevel;
-import org.springframework.web.servlet.ModelAndView;
public final class CollectionWrapper {
@@ -41,11 +40,6 @@ public final class CollectionWrapper {
// empty constructor for static utility class
}
- @SuppressWarnings("unchecked")
- public static List<String> wrapStrings(final ModelAndView modelAndView) {
- return (List<String>)
modelAndView.getModel().values().iterator().next();
- }
-
public static Set<EntitlementTO> wrap(final Collection<String> collection)
{
Set<EntitlementTO> respons = new HashSet<EntitlementTO>();
for (String e : collection) {
Modified: syncope/trunk/console/pom.xml
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/pom.xml?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
--- syncope/trunk/console/pom.xml (original)
+++ syncope/trunk/console/pom.xml Mon Jul 22 11:18:39 2013
@@ -113,12 +113,12 @@ under the License.
</dependency>
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
+ <artifactId>spring-web</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
<!-- TEST -->
Modified:
syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java
(original)
+++
syncope/trunk/console/src/main/java/org/apache/syncope/console/SyncopeSession.java
Mon Jul 22 11:18:39 2013
@@ -20,48 +20,15 @@ package org.apache.syncope.console;
import java.text.DateFormat;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import java.util.Locale;
-import java.util.Map;
-import org.apache.syncope.client.services.proxy.ConfigurationServiceProxy;
-import org.apache.syncope.client.services.proxy.ConnectorServiceProxy;
-import org.apache.syncope.client.services.proxy.EntitlementServiceProxy;
-import org.apache.syncope.client.services.proxy.LoggerServiceProxy;
-import org.apache.syncope.client.services.proxy.NotificationServiceProxy;
-import org.apache.syncope.client.services.proxy.PolicyServiceProxy;
-import org.apache.syncope.client.services.proxy.ReportServiceProxy;
-import org.apache.syncope.client.services.proxy.ResourceServiceProxy;
-import org.apache.syncope.client.services.proxy.RoleServiceProxy;
-import org.apache.syncope.client.services.proxy.SchemaServiceProxy;
-import org.apache.syncope.client.services.proxy.SpringServiceProxy;
-import org.apache.syncope.client.services.proxy.TaskServiceProxy;
-import org.apache.syncope.client.services.proxy.UserRequestServiceProxy;
-import org.apache.syncope.client.services.proxy.UserServiceProxy;
-import org.apache.syncope.client.services.proxy.UserWorkflowServiceProxy;
-import org.apache.syncope.client.services.proxy.WorkflowServiceProxy;
-import org.apache.syncope.common.services.ConfigurationService;
-import org.apache.syncope.common.services.ConnectorService;
-import org.apache.syncope.common.services.EntitlementService;
-import org.apache.syncope.common.services.LoggerService;
-import org.apache.syncope.common.services.NotificationService;
-import org.apache.syncope.common.services.PolicyService;
-import org.apache.syncope.common.services.ReportService;
-import org.apache.syncope.common.services.ResourceService;
-import org.apache.syncope.common.services.RoleService;
-import org.apache.syncope.common.services.SchemaService;
-import org.apache.syncope.common.services.TaskService;
-import org.apache.syncope.common.services.UserRequestService;
-import org.apache.syncope.common.services.UserService;
-import org.apache.syncope.common.services.UserWorkflowService;
-import org.apache.syncope.common.services.WorkflowService;
+import org.apache.syncope.client.rest.RestClientFactoryBean;
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.client.RestTemplate;
import org.springframework.web.context.support.WebApplicationContextUtils;
/**
@@ -71,20 +38,18 @@ public class SyncopeSession extends WebS
private static final long serialVersionUID = 7743446298924805872L;
- public static final List<Locale> SUPPORTED_LOCALES = Arrays.asList(new
Locale[]{
+ public static final List<Locale> SUPPORTED_LOCALES = Arrays.asList(new
Locale[] {
Locale.ENGLISH, Locale.ITALIAN, new Locale("pt", "BR")});
- private String userId;
+ private String username;
+
+ private String password;
private String version;
private Roles roles = new Roles();
- protected String baseURL;
-
- private final RestTemplate restTemplate;
-
- private final Map<Class<?>, SpringServiceProxy> services = new
HashMap<Class<?>, SpringServiceProxy>();
+ private final RestClientFactoryBean restClientFactory;
public static SyncopeSession get() {
return (SyncopeSession) Session.get();
@@ -96,45 +61,27 @@ public class SyncopeSession extends WebS
final ApplicationContext applicationContext =
WebApplicationContextUtils.getWebApplicationContext(WebApplication.get().getServletContext());
- restTemplate = applicationContext.getBean(RestTemplate.class);
- baseURL = applicationContext.getBean("baseURL", String.class);
-
- setupRESTClients();
+ restClientFactory =
applicationContext.getBean(RestClientFactoryBean.class);
}
- private void setupRESTClients() {
- services.put(ConfigurationService.class, new
ConfigurationServiceProxy(baseURL, restTemplate));
- services.put(ConnectorService.class, new
ConnectorServiceProxy(baseURL, restTemplate));
- services.put(EntitlementService.class, new
EntitlementServiceProxy(baseURL, restTemplate));
- services.put(LoggerService.class, new LoggerServiceProxy(baseURL,
restTemplate));
- services.put(NotificationService.class, new
NotificationServiceProxy(baseURL, restTemplate));
- services.put(PolicyService.class, new PolicyServiceProxy(baseURL,
restTemplate));
- services.put(ReportService.class, new ReportServiceProxy(baseURL,
restTemplate));
- services.put(ResourceService.class, new ResourceServiceProxy(baseURL,
restTemplate));
- services.put(RoleService.class, new RoleServiceProxy(baseURL,
restTemplate));
- services.put(SchemaService.class, new SchemaServiceProxy(baseURL,
restTemplate));
- services.put(TaskService.class, new TaskServiceProxy(baseURL,
restTemplate));
- services.put(UserRequestService.class, new
UserRequestServiceProxy(baseURL, restTemplate));
- services.put(UserService.class, new UserServiceProxy(baseURL,
restTemplate));
- services.put(UserWorkflowService.class, new
UserWorkflowServiceProxy(baseURL, restTemplate));
- services.put(WorkflowService.class, new WorkflowServiceProxy(baseURL,
restTemplate));
+ public <T> T getService(final Class<T> service) {
+ return restClientFactory.createServiceInstance(service, username,
password);
}
- @SuppressWarnings("unchecked")
- public <T> T getService(final Class<T> service) {
- return (T) services.get(service);
+ public <T> T getService(final Class<T> service, final String username,
final String password) {
+ return restClientFactory.createServiceInstance(service, username,
password);
}
- public RestTemplate getRestTemplate() {
- return restTemplate;
+ public String getUsername() {
+ return username;
}
- public String getUserId() {
- return userId;
+ public void setUsername(final String username) {
+ this.username = username;
}
- public void setUserId(final String userId) {
- this.userId = userId;
+ public void setPassword(final String password) {
+ this.password = password;
}
public String getVersion() {
@@ -155,7 +102,7 @@ public class SyncopeSession extends WebS
}
public boolean isAuthenticated() {
- return getUserId() != null;
+ return getUsername() != null;
}
public boolean hasAnyRole(final Roles roles) {
Modified:
syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/PreferenceManager.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/PreferenceManager.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/PreferenceManager.java
(original)
+++
syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/PreferenceManager.java
Mon Jul 22 11:18:39 2013
@@ -54,15 +54,16 @@ public class PreferenceManager {
private static final List<Integer> PAGINATOR_CHOICES = Arrays.asList(new
Integer[]{10, 25, 50});
- @Autowired
- private ObjectMapper mapper;
+ private final ObjectMapper mapper;
private final CookieUtils cookieUtils;
public PreferenceManager() {
+ this.mapper = new ObjectMapper();
+
CookieDefaults cookieDefaults = new CookieDefaults();
cookieDefaults.setMaxAge(ONE_YEAR_TIME);
- cookieUtils = new CookieUtils(cookieDefaults);
+ this.cookieUtils = new CookieUtils(cookieDefaults);
}
public List<Integer> getPaginatorChoices() {
Modified:
syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/XMLRolesReader.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/XMLRolesReader.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/XMLRolesReader.java
(original)
+++
syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/XMLRolesReader.java
Mon Jul 22 11:18:39 2013
@@ -25,9 +25,9 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
@@ -41,12 +41,9 @@ public class XMLRolesReader {
*/
private static final Logger LOG =
LoggerFactory.getLogger(XMLRolesReader.class);
- @Autowired
- private String authorizations;
-
private Document doc;
- public void init() {
+ public void setAuthorizations(final String authorizations) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
try {
@@ -67,12 +64,8 @@ public class XMLRolesReader {
* @return roles list comma separated
*/
public String getAllAllowedRoles(final String pageId, final String
actionId) {
-
- if (doc == null) {
- init();
- }
if (doc == null) {
- return "";
+ return StringUtils.EMPTY;
}
final StringBuilder roles = new StringBuilder();
Modified:
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java
(original)
+++
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/BasePage.java
Mon Jul 22 11:18:39 2013
@@ -125,9 +125,9 @@ public class BasePage extends AbstractBa
}
};
- editProfileLink.add(new Label("username",
SyncopeSession.get().getUserId()));
+ editProfileLink.add(new Label("username",
SyncopeSession.get().getUsername()));
- if ("admin".equals(SyncopeSession.get().getUserId())) {
+ if ("admin".equals(SyncopeSession.get().getUsername())) {
editProfileLink.setEnabled(false);
}
Modified:
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ConnectorModalPage.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ConnectorModalPage.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ConnectorModalPage.java
(original)
+++
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/ConnectorModalPage.java
Mon Jul 22 11:18:39 2013
@@ -18,7 +18,6 @@
*/
package org.apache.syncope.console.pages;
-import static org.apache.wicket.Component.ENABLE;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Modified:
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java
(original)
+++
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Login.java
Mon Jul 22 11:18:39 2013
@@ -22,16 +22,15 @@ import java.security.AccessControlExcept
import java.util.Locale;
import java.util.Set;
import org.apache.http.HttpResponse;
-import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
-import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
import org.apache.syncope.common.services.EntitlementService;
import org.apache.syncope.common.services.UserRequestService;
import org.apache.syncope.common.to.EntitlementTO;
import org.apache.syncope.common.to.UserTO;
import org.apache.syncope.common.util.CollectionWrapper;
+import
org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
import org.apache.syncope.console.SyncopeSession;
import org.apache.syncope.console.commons.Constants;
import
org.apache.syncope.console.wicket.ajax.markup.html.ClearIndicatingAjaxLink;
@@ -58,8 +57,6 @@ import org.apache.wicket.request.mapper.
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.web.client.HttpClientErrorException;
-import org.springframework.web.client.RestTemplate;
/**
* Syncope Login page.
@@ -114,19 +111,14 @@ public class Login extends WebPage {
try {
String[] entitlements =
authenticate(userIdField.getRawInput(), passwordField.getRawInput());
- SyncopeSession.get().setUserId(userIdField.getRawInput());
+
SyncopeSession.get().setUsername(userIdField.getRawInput());
+
SyncopeSession.get().setPassword(passwordField.getRawInput());
SyncopeSession.get().setEntitlements(entitlements);
SyncopeSession.get().setVersion(getSyncopeVersion());
setResponsePage(WelcomePage.class, parameters);
} catch (AccessControlException e) {
error(getString("login-error"));
-
- PreemptiveAuthHttpRequestFactory requestFactory =
- ((PreemptiveAuthHttpRequestFactory) SyncopeSession.
- get().getRestTemplate().getRequestFactory());
-
- ((DefaultHttpClient)
requestFactory.getHttpClient()).getCredentialsProvider().clear();
}
}
};
@@ -180,18 +172,9 @@ public class Login extends WebPage {
add(selfRegFrag);
}
- private String[] authenticate(final String userId, final String password) {
- final RestTemplate restTemplate =
SyncopeSession.get().getRestTemplate();
-
- // 1. Set provided credentials to check
- PreemptiveAuthHttpRequestFactory requestFactory =
- ((PreemptiveAuthHttpRequestFactory)
restTemplate.getRequestFactory());
-
- ((DefaultHttpClient)
requestFactory.getHttpClient()).getCredentialsProvider().setCredentials(
- requestFactory.getAuthScope(), new
UsernamePasswordCredentials(userId, password));
-
- // 2. Search authorizations for user specified by credentials
- Set<EntitlementTO> entitlements =
SyncopeSession.get().getService(EntitlementService.class).getMyEntitlements();
+ private String[] authenticate(final String username, final String
password) {
+ Set<EntitlementTO> entitlements = SyncopeSession.get().
+ getService(EntitlementService.class, username,
password).getMyEntitlements();
return CollectionWrapper.unwrap(entitlements).toArray(new String[0]);
}
@@ -199,7 +182,7 @@ public class Login extends WebPage {
Boolean result = null;
try {
result =
SyncopeSession.get().getService(UserRequestService.class).isCreateAllowed();
- } catch (HttpClientErrorException e) {
+ } catch (SyncopeClientCompositeErrorException e) {
LOG.error("While seeking if self registration is allowed", e);
}
@@ -209,15 +192,10 @@ public class Login extends WebPage {
}
private String getSyncopeVersion() {
- final RestTemplate restTemplate =
SyncopeSession.get().getRestTemplate();
-
- PreemptiveAuthHttpRequestFactory requestFactory =
((PreemptiveAuthHttpRequestFactory) restTemplate.
- getRequestFactory());
-
String version = "";
try {
HttpGet get = new HttpGet(baseURL + "../version.jsp");
- HttpResponse response =
requestFactory.getHttpClient().execute(get);
+ HttpResponse response = new DefaultHttpClient().execute(get);
version = EntityUtils.toString(response.getEntity()).trim();
} catch (Exception e) {
LOG.error("While fetching version from core", e);
Modified:
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Logout.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Logout.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Logout.java
(original)
+++
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Logout.java
Mon Jul 22 11:18:39 2013
@@ -18,8 +18,6 @@
*/
package org.apache.syncope.console.pages;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
import org.apache.syncope.console.SyncopeSession;
import org.apache.wicket.request.mapper.parameter.PageParameters;
@@ -35,14 +33,6 @@ public class Logout extends BasePage {
SyncopeSession.get().invalidate();
- // TODO: check that this is indeed not necessary anymore.
- // getRequestCycle().setRedirect(true);
-
setResponsePage(getApplication().getHomePage());
-
- PreemptiveAuthHttpRequestFactory requestFactory =
- ((PreemptiveAuthHttpRequestFactory)
SyncopeSession.get().getRestTemplate().getRequestFactory());
-
- ((DefaultHttpClient)
requestFactory.getHttpClient()).getCredentialsProvider().clear();
}
}
Modified:
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Todo.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Todo.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Todo.java
(original)
+++
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Todo.java
Mon Jul 22 11:18:39 2013
@@ -170,7 +170,7 @@ public class Todo extends BasePage {
editApprovalWin.show(target);
}
}, ActionLink.ActionType.EDIT, "Approval",
-
SyncopeSession.get().getUserId().equals(formTO.getOwner()));
+
SyncopeSession.get().getUsername().equals(formTO.getOwner()));
cellItem.add(panel);
}
Modified: syncope/trunk/console/src/main/resources/applicationContext.xml
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/applicationContext.xml?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/applicationContext.xml (original)
+++ syncope/trunk/console/src/main/resources/applicationContext.xml Mon Jul 22
11:18:39 2013
@@ -19,21 +19,14 @@ under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
- xmlns:oxm="http://www.springframework.org/schema/oxm"
- xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/oxm
-
http://www.springframework.org/schema/oxm/spring-oxm.xsd
- http://www.springframework.org/schema/tx
-
http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/aop
-
http://www.springframework.org/schema/aop/spring-aop.xsd">
+ http://cxf.apache.org/core
+ http://cxf.apache.org/schemas/core.xsd">
<context:component-scan base-package="org.apache.syncope.console.rest"/>
@@ -63,78 +56,62 @@ under the License.
<constructor-arg value="${licenseUrl}"/>
</bean>
- <bean id="authorizations" class="java.lang.String">
- <constructor-arg value="authorizations.xml"/>
- </bean>
-
<bean id="syncopeApplication"
class="org.apache.syncope.console.SyncopeApplication"/>
- <bean id="jacksonObjectMapper"
class="org.codehaus.jackson.map.ObjectMapper"/>
+ <bean id="preferenceManager"
class="org.apache.syncope.console.commons.PreferenceManager"/>
- <bean id="mappingJacksonHttpMessageConverter"
-
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
- <property name="objectMapper" ref="jacksonObjectMapper"/>
+ <bean id="xmlRolesReader"
class="org.apache.syncope.console.commons.XMLRolesReader">
+ <property name="authorizations" value="authorizations.xml"/>
</bean>
- <bean id="httpClientConnManager"
class="org.apache.http.impl.conn.PoolingClientConnectionManager"/>
+ <bean id="roleTreeBuilder"
class="org.apache.syncope.console.commons.RoleTreeBuilder"/>
- <bean id="httpHostHeader" class="org.apache.http.message.BasicHeader">
- <constructor-arg value="Host"/>
- <constructor-arg value="${host}"/>
- </bean>
-
- <bean id="httpClientParams"
class="org.apache.syncope.client.http.HttpClientParams">
- <property name="parameterMap">
- <map key-type="java.lang.String">
- <entry>
- <key>
- <value>http.protocol.handle-authentication</value>
- </key>
- <value type="java.lang.Boolean">false</value>
- </entry>
- <entry>
- <key>
- <value>http.auth.credential-charset</value>
- </key>
- <value type="java.lang.String">UTF-8</value>
+ <bean id="jaxbProvider"
class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
+ <property name="depthProperties">
+ <bean id="depthProperties"
class="org.apache.cxf.staxutils.DocumentDepthProperties">
+ <property name="innerElementCountThreshold" value="500"/>
+ </bean>
+ </property>
+ <property name="marshallerProperties">
+ <map>
+ <entry key="jaxb.formatted.output">
+ <value type="java.lang.Boolean">true</value>
</entry>
+ </map>
+ </property>
+ <property name="collectionWrapperMap">
+ <map>
<entry>
<key>
- <value>http.default-headers</value>
+ <value>org.apache.syncope.common.to.PolicyTO</value>
</key>
- <list>
- <ref bean="httpHostHeader"/>
- </list>
+ <value>policies</value>
</entry>
</map>
</property>
</bean>
- <bean id="httpClientFactory"
class="org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory"
- scope="prototype">
- <constructor-arg value="${host}"/>
- <constructor-arg value="${port}"/>
- <constructor-arg value="${scheme}"/>
- <constructor-arg ref="httpClientConnManager"/>
- <constructor-arg ref="httpClientParams"/>
- </bean>
+ <bean id="jsonProvider"
class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/>
+
+ <bean id="exceptionMapper"
class="org.apache.syncope.client.rest.RestClientExceptionMapper"/>
- <bean id="restTemplate" class="org.springframework.web.client.RestTemplate"
scope="prototype">
- <constructor-arg ref="httpClientFactory"/>
- <property name="messageConverters">
+ <bean id="restClientFactory"
class="org.apache.syncope.client.rest.RestClientFactoryBean" scope="prototype">
+ <property name="address" value="${scheme}://${host}:${port}/${rootPath}"/>
+ <property name="threadSafe" value="true"/>
+ <property name="inheritHeaders" value="true"/>
+ <property name="contentType" value="application/xml"/>
+ <property name="features">
<list>
- <ref bean="mappingJacksonHttpMessageConverter"/>
+ <cxf:logging/>
</list>
</property>
- <property name="errorHandler">
- <bean id="syncopeClientErrorHandler"
class="org.apache.syncope.common.validation.SyncopeClientErrorHandler"/>
+ <property name="providers">
+ <list>
+ <ref bean="jaxbProvider"/>
+ <ref bean="jsonProvider"/>
+ <ref bean="exceptionMapper"/>
+ </list>
</property>
</bean>
- <bean id="preferenceManager"
class="org.apache.syncope.console.commons.PreferenceManager"/>
-
- <bean id="xmlRolesReader"
class="org.apache.syncope.console.commons.XMLRolesReader"/>
-
- <bean id="roleTreeBuilder"
class="org.apache.syncope.console.commons.RoleTreeBuilder"/>
-
</beans>
Modified: syncope/trunk/console/src/main/resources/configuration.properties
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/configuration.properties?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/configuration.properties (original)
+++ syncope/trunk/console/src/main/resources/configuration.properties Mon Jul
22 11:18:39 2013
@@ -17,4 +17,4 @@
scheme=http
host=localhost
port=8080
-rootPath=/syncope/rest/
+rootPath=/syncope/cxf/
Modified: syncope/trunk/console/src/main/resources/logback.xml
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/logback.xml?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/logback.xml (original)
+++ syncope/trunk/console/src/main/resources/logback.xml Mon Jul 22 11:18:39
2013
@@ -55,6 +55,11 @@ under the License.
<appender-ref ref="main"/>
</logger>
+ <logger name="org.apache.cxf" additivity="false">
+ <level value="INFO"/>
+ <appender-ref ref="main"/>
+ </logger>
+
<root>
<level value="INFO"/>
<appender-ref ref="main"/>
Modified: syncope/trunk/console/src/test/resources/configuration.properties
URL:
http://svn.apache.org/viewvc/syncope/trunk/console/src/test/resources/configuration.properties?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
--- syncope/trunk/console/src/test/resources/configuration.properties (original)
+++ syncope/trunk/console/src/test/resources/configuration.properties Mon Jul
22 11:18:39 2013
@@ -17,4 +17,4 @@
scheme=http
host=localhost
port=9080
-rootPath=/syncope/rest/
+rootPath=/syncope/cxf/
Modified:
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java
(original)
+++
syncope/trunk/core/src/main/java/org/apache/syncope/core/services/WorkflowServiceImpl.java
Mon Jul 22 11:18:39 2013
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.services;
+import java.util.List;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.core.UriInfo;
@@ -25,7 +26,6 @@ import org.apache.syncope.common.service
import org.apache.syncope.common.services.WorkflowTasks;
import org.apache.syncope.common.to.WorkflowDefinitionTO;
import org.apache.syncope.common.types.AttributableType;
-import org.apache.syncope.common.util.CollectionWrapper;
import org.apache.syncope.core.rest.controller.WorkflowController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -63,12 +63,17 @@ public class WorkflowServiceImpl impleme
}
@Override
+ @SuppressWarnings("unchecked")
public WorkflowTasks getDefinedTasks(final AttributableType kind) {
switch (kind) {
case USER:
- return new
WorkflowTasks(CollectionWrapper.wrapStrings(workflowController.getDefinedUserTasks()));
+ return new WorkflowTasks((List<String>)
workflowController.getDefinedUserTasks().
+ getModel().values().iterator().next());
+
case ROLE:
- return new
WorkflowTasks(CollectionWrapper.wrapStrings(workflowController.getDefinedUserTasks()));
+ return new WorkflowTasks((List<String>)
workflowController.getDefinedRoleTasks().
+ getModel().values().iterator().next());
+
default:
throw new BadRequestException();
}
Modified:
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL:
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
---
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
(original)
+++
syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
Mon Jul 22 11:18:39 2013
@@ -30,14 +30,13 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
-import org.apache.cxf.jaxrs.client.Client;
-import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.http.HttpStatus;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
-import org.apache.syncope.client.rest.utils.RestClientExceptionMapper;
+import org.apache.syncope.client.rest.RestClientExceptionMapper;
+import org.apache.syncope.client.rest.RestClientFactoryBean;
import org.apache.syncope.client.services.proxy.ConfigurationServiceProxy;
import org.apache.syncope.client.services.proxy.ConnectorServiceProxy;
import org.apache.syncope.client.services.proxy.EntitlementServiceProxy;
@@ -121,7 +120,7 @@ public abstract class AbstractTest {
private PreemptiveAuthHttpRequestFactory httpClientFactory;
@Autowired
- protected JAXRSClientFactoryBean restClientFactory;
+ protected RestClientFactoryBean restClientFactory;
@Autowired
protected DataSource testDataSource;
@@ -166,6 +165,11 @@ public abstract class AbstractTest {
@Before
public void setup() throws Exception {
if (enabledCXF) {
+ String envContentType = System.getProperty(ENV_KEY_CONTENT_TYPE);
+ contentType = (envContentType == null || envContentType.isEmpty())
+ ? DEFAULT_CONTENT_TYPE
+ : envContentType;
+
setupCXFServices();
} else {
resetRestTemplate();
@@ -208,8 +212,8 @@ public abstract class AbstractTest {
schemaService = new SchemaServiceProxy(BASE_URL, restTemplate);
userRequestService = new UserRequestServiceProxy(BASE_URL,
restTemplate);
}
-
// END Spring MVC Initialization
+
// BEGIN CXF Initialization
protected void setupCXFServices() throws Exception {
userService = createServiceInstance(UserService.class);
@@ -230,38 +234,14 @@ public abstract class AbstractTest {
}
protected <T> T createServiceInstance(final Class<T> serviceClass) {
- return createServiceInstance(serviceClass, ADMIN_UNAME);
+ return restClientFactory.createServiceInstance(serviceClass,
ADMIN_UNAME, ADMIN_PWD);
}
-
- protected <T> T createServiceInstance(final Class<T> serviceClass, final
String username) {
- return createServiceInstance(serviceClass, username, ADMIN_PWD);
- }
-
- protected <T> T createServiceInstance(final Class<T> serviceClass, final
String username, final String password) {
- restClientFactory.setUsername(username);
- restClientFactory.setPassword(password);
- restClientFactory.setServiceClass(serviceClass);
- T serviceProxy = restClientFactory.create(serviceClass);
- setupContentType(WebClient.client(serviceProxy));
- return serviceProxy;
- }
-
- protected void setupContentType(final Client restClient) {
- if (contentType == null) {
- String envContentType = System.getProperty(ENV_KEY_CONTENT_TYPE);
- if (envContentType == null || envContentType.isEmpty()) {
- contentType = DEFAULT_CONTENT_TYPE;
- } else {
- contentType = envContentType;
- }
- }
- restClient.type(contentType).accept(contentType);
- }
-
// END CXF Initialization
+
@SuppressWarnings("unchecked")
protected <T> T setupCredentials(final T proxy, final Class<?>
serviceInterface, final String username,
final String password) {
+
if (proxy instanceof SpringServiceProxy) {
SpringServiceProxy service = (SpringServiceProxy) proxy;
if (username == null && password == null) {
@@ -271,12 +251,7 @@ public abstract class AbstractTest {
}
return proxy;
} else {
- restClientFactory.setUsername(username);
- restClientFactory.setPassword(password);
- restClientFactory.setServiceClass(serviceInterface);
- T serviceProxy = (T) restClientFactory.create(serviceInterface);
- setupContentType(WebClient.client(serviceProxy));
- return serviceProxy;
+ return (T)
restClientFactory.createServiceInstance(serviceInterface, username, password);
}
}
Modified: syncope/trunk/core/src/test/resources/restClientContext.xml
URL:
http://svn.apache.org/viewvc/syncope/trunk/core/src/test/resources/restClientContext.xml?rev=1505658&r1=1505657&r2=1505658&view=diff
==============================================================================
--- syncope/trunk/core/src/test/resources/restClientContext.xml (original)
+++ syncope/trunk/core/src/test/resources/restClientContext.xml Mon Jul 22
11:18:39 2013
@@ -19,17 +19,11 @@ under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:jaxrs="http://cxf.apache.org/jaxrs"
- xmlns:util="http://www.springframework.org/schema/util"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://cxf.apache.org/jaxrs
- http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/core
- http://cxf.apache.org/schemas/core.xsd
- http://www.springframework.org/schema/util
-
http://www.springframework.org/schema/util/spring-util.xsd">
+ http://cxf.apache.org/schemas/core.xsd">
<bean id="httpClientConnManager"
class="org.apache.http.impl.conn.PoolingClientConnectionManager"/>
@@ -108,14 +102,13 @@ under the License.
<property name="mapper" ref="jacksonObjectMapper"/>
</bean>
- <bean id="exceptionMapper"
class="org.apache.syncope.client.rest.utils.RestClientExceptionMapper"/>
+ <bean id="exceptionMapper"
class="org.apache.syncope.client.rest.RestClientExceptionMapper"/>
- <bean id="restClientFactory"
class="org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean">
+ <bean id="restClientFactory"
class="org.apache.syncope.client.rest.RestClientFactoryBean">
<property name="address" value="http://localhost:9080/syncope/cxf"/>
<property name="threadSafe" value="true"/>
- <property name="username" value="admin"/>
- <property name="password" value="password"/>
<property name="inheritHeaders" value="true"/>
+ <property name="contentType" value="application/xml"/>
<property name="features">
<list>
<cxf:logging/>