diff --git a/sni-for-client-2.2.0.patch b/sni-for-client-2.2.0.patch
new file mode 100644
index 0000000..e92bb07
--- /dev/null
+++ b/sni-for-client-2.2.0.patch
@@ -0,0 +1,151 @@
+diff --git zanata-rest-client/pom.xml zanata-rest-client/pom.xml
+index 3fb3b24..d1467df 100644
+--- zanata-rest-client/pom.xml
++++ zanata-rest-client/pom.xml
+@@ -24,6 +24,10 @@
+ org.zanata
+ zanata-common-api
+
++
++ commons-beanutils
++ commons-beanutils
++
+
+
+ junit
+diff --git zanata-rest-client/src/main/java/org/zanata/rest/client/ZanataProxyFactory.java zanata-rest-client/src/main/java/org/zanata/rest/client/ZanataProxyFactory.java
+index 9133412..44c1dae 100644
+--- zanata-rest-client/src/main/java/org/zanata/rest/client/ZanataProxyFactory.java
++++ zanata-rest-client/src/main/java/org/zanata/rest/client/ZanataProxyFactory.java
+@@ -1,14 +1,28 @@
+ package org.zanata.rest.client;
+
++import java.io.IOException;
++import java.net.InetSocketAddress;
+ import java.net.MalformedURLException;
++import java.net.Socket;
+ import java.net.URI;
+ import java.net.URISyntaxException;
+ import java.net.URL;
+-
++import java.net.UnknownHostException;
++import java.security.SecureRandom;
++
++import org.apache.commons.beanutils.PropertyUtils;
++import org.apache.http.client.HttpClient;
++import org.apache.http.conn.ClientConnectionManager;
++import org.apache.http.conn.ConnectTimeoutException;
++import org.apache.http.conn.scheme.Scheme;
++import org.apache.http.conn.ssl.SSLSocketFactory;
++import org.apache.http.impl.client.DefaultHttpClient;
++import org.apache.http.params.HttpParams;
+ import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+ import org.jboss.resteasy.client.ClientExecutor;
+ import org.jboss.resteasy.client.ClientRequestFactory;
+ import org.jboss.resteasy.client.ClientResponse;
++import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor;
+ import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
+ import org.jboss.resteasy.spi.ResteasyProviderFactory;
+ import org.slf4j.Logger;
+@@ -19,6 +33,9 @@ import org.zanata.rest.service.AsynchronousProcessResource;
+ import org.zanata.rest.service.CopyTransResource;
+ import org.zanata.rest.service.StatisticsResource;
+
++import javax.net.ssl.SSLContext;
++import javax.net.ssl.SSLSocket;
++import javax.net.ssl.TrustManager;
+ import javax.ws.rs.core.Response;
+
+ public class ZanataProxyFactory implements ITranslationResourcesFactory
+@@ -45,7 +62,7 @@ public class ZanataProxyFactory implements ITranslationResourcesFactory
+ {
+ this(base, username, apiKey, null, clientApiVersion, false);
+ }
+-
++
+ public ZanataProxyFactory(URI base, String username, String apiKey, VersionInfo clientApiVersion, boolean logHttp)
+ {
+ this(base, username, apiKey, null, clientApiVersion, logHttp);
+@@ -54,10 +71,10 @@ public class ZanataProxyFactory implements ITranslationResourcesFactory
+ public ZanataProxyFactory(URI base, String username, String apiKey, ClientExecutor executor, VersionInfo clientApiVersion,
+ boolean logHttp)
+ {
+- crf = new ClientRequestFactory(executor, null, fixBase(base));
++ crf = new ClientRequestFactory(createClientExecutor(), null, fixBase(base));
+ registerPrefixInterceptor(new TraceDebugInterceptor(logHttp));
+ registerPrefixInterceptor(new ApiKeyHeaderDecorator(username, apiKey, clientApiVersion.getVersionNo()));
+-
++
+ clientVersion = clientApiVersion.getVersionNo();
+ String clientTimestamp = clientApiVersion.getBuildTimeStamp();
+ IVersionResource iversion = createIVersionResource();
+@@ -86,6 +103,50 @@ public class ZanataProxyFactory implements ITranslationResourcesFactory
+ }
+ }
+
++ private static ClientExecutor createClientExecutor() {
++ try {
++ final SSLContext sslContext = SSLContext.getInstance("TLS");
++
++ sslContext.init(null, null, new SecureRandom());
++
++ // NB: This factory is a workaround to enable SNI with
++ // httpcomponents-client 4.2; not needed for 4.3
++ SSLSocketFactory factory = new SSLSocketFactory(sslContext) {
++ @Override
++ public Socket connectSocket(Socket socket,
++ InetSocketAddress remoteAddress,
++ InetSocketAddress localAddress,
++ HttpParams params)
++ throws IOException, UnknownHostException,
++ ConnectTimeoutException {
++ if (socket instanceof SSLSocket) {
++ try {
++ PropertyUtils.setProperty(socket, "host",
++ remoteAddress.getHostName());
++ }
++ catch (Exception ex) {
++ log.warn(
++ "Unable to enable SNI; you may have trouble connecting to some secure hosts. Please ensure that you are running Java 1.7 or later.");
++ }
++ }
++ return super.connectSocket(socket, remoteAddress,
++ localAddress, params);
++ }
++ };
++
++ HttpClient client = new DefaultHttpClient();
++
++ ClientConnectionManager manager = client.getConnectionManager();
++ manager.getSchemeRegistry().register(
++ new Scheme("https", 443, factory));
++ return new ApacheHttpClient4Executor(client);
++
++ } catch (Exception e) {
++ log.warn("error creating SSL client", e);
++ }
++ return null;
++ }
++
+ public T createProxy(Class clazz, URI baseUri)
+ {
+ log.debug("{} proxy uri: {}", clazz.getSimpleName(), baseUri);
+@@ -244,7 +305,8 @@ public class ZanataProxyFactory implements ITranslationResourcesFactory
+
+ public ISourceDocResource getSourceDocResource(String projectSlug, String versionSlug)
+ {
+- return createProxy(ISourceDocResource.class, getResourceURI(projectSlug, versionSlug));
++ return createProxy(ISourceDocResource.class, getResourceURI(projectSlug,
++ versionSlug));
+ }
+
+ public IFileResource getFileResource()
+@@ -317,7 +379,7 @@ public class ZanataProxyFactory implements ITranslationResourcesFactory
+ {
+ crf.getPrefixInterceptors().registerInterceptor(interceptor);
+ }
+-
++
+ protected IVersionResource createIVersionResource()
+ {
+ URL url;
diff --git a/zanata-client.spec b/zanata-client.spec
index 6fdb14a..a4f37e6 100644
--- a/zanata-client.spec
+++ b/zanata-client.spec
@@ -1,9 +1,3 @@
-%if 0%{?fedora} > 18
- %global mvn_exec_plugin exec-maven-plugin
-%else
- %global mvn_exec_plugin maven-plugin-exec
-%endif
-
%global shortname client
%global submodule_rest zanata-rest-%{shortname}
@@ -12,14 +6,14 @@
Name: zanata-%{shortname}
Version: 2.2.0
-Release: 2%{?dist}
+Release: 4%{?dist}
Summary: Zanata client module
Group: Development/Tools
License: LGPLv2+
URL: https://github.com/zanata/%{name}
Source0: https://github.com/zanata/%{name}/archive/%{shortname}-%{version}.zip
-Patch0: slf4j-backward-compatible-fix.patch
+Patch0: sni-for-client-2.2.0.patch
BuildArch: noarch
@@ -36,9 +30,6 @@ BuildRequires: zanata-parent
BuildRequires: zanata-api
BuildRequires: junit
BuildRequires: resteasy
-%if 0%{?fedora} < 19
-BuildRequires: apache-james-project
-%endif
# dependencies in zanata-common-commands
BuildRequires: zanata-common
@@ -57,7 +48,7 @@ BuildRequires: opencsv
BuildRequires: ant
# dependencies in zanata-cli
-BuildRequires: %mvn_exec_plugin
+BuildRequires: exec-maven-plugin
Requires: jpackage-utils
Requires: java
@@ -101,24 +92,13 @@ This includes submodules:
%pom_remove_plugin :appassembler-maven-plugin %{submodule_cli}
%pom_remove_plugin :maven-assembly-plugin %{submodule_cli}
-%if 0%{?fedora} < 18
%patch0
-%endif
-
%build
# -Dmaven.local.debug=true
# we delete all test class under f19 because of hamcrest compatibility issue
-%if 0%{?fedora} > 19
-%mvn_build -- -Dmdep.analyze.skip=true
-%endif
-%if 0%{?fedora} == 19
find . -type f -name "*Test.java" | xargs rm
%mvn_build -- -Dmdep.analyze.skip=true -DskipTests
-%else
-find . -type f -name "*Test.java" | xargs rm
-mvn-rpmbuild package javadoc:aggregate -DskipTests
-%endif
# local offline maven can not resolve each module,
# we have to disable our own module and generate classpath one by one
@@ -137,32 +117,7 @@ mvn-rpmbuild dependency:build-classpath -DincludeScope=compile -Dmdep.outputFile
%install
-%if 0%{?fedora} > 18
%mvn_install
-%else
-mkdir -p %{buildroot}%{_javadir}
-
-cp -p %{submodule_rest}/target/%{submodule_rest}*-%{version}.jar %{buildroot}%{_javadir}/%{submodule_rest}.jar
-cp -p %{submodule_commands}/target/%{submodule_commands}*-%{version}.jar %{buildroot}%{_javadir}/%{submodule_commands}.jar
-cp -p %{submodule_cli}/target/%{submodule_cli}*-%{version}.jar %{buildroot}%{_javadir}/%{submodule_cli}.jar
-
-mkdir -p %{buildroot}%{_javadocdir}/%{name}
-cp -rp target/site/apidocs %{buildroot}%{_javadocdir}/%{name}/%{submodule_rest}
-cp -rp target/site/apidocs %{buildroot}%{_javadocdir}/%{name}/%{submodule_commands}
-cp -rp target/site/apidocs %{buildroot}%{_javadocdir}/%{name}/%{submodule_cli}
-
-install -d -m 755 %{buildroot}%{_mavenpomdir}
-install -pm 644 pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom
-install -pm 644 %{submodule_rest}/pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{submodule_rest}.pom
-install -pm 644 %{submodule_commands}/pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{submodule_commands}.pom
-install -pm 644 %{submodule_cli}/pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{submodule_cli}.pom
-
-%add_maven_depmap JPP-%{name}.pom
-%add_maven_depmap JPP-%{submodule_rest}.pom %{submodule_rest}.jar
-%add_maven_depmap JPP-%{submodule_commands}.pom %{submodule_commands}.jar
-%add_maven_depmap JPP-%{submodule_cli}.pom %{submodule_cli}.jar
-%endif
-
rest_cp=$(cat %{submodule_rest}/target/%{submodule_rest}-classpath.txt)
commands_cp=$(cat %{submodule_commands}/target/%{submodule_commands}-classpath.txt)
@@ -198,7 +153,7 @@ fi
# Configuration
MAIN_CLASS=org.zanata.client.ZanataClient
-BASE_JARS="%{submodule_rest} %{submodule_commands} %{submodule_cli} slf4j/log4j12 opencsv"
+BASE_JARS="%{name}/%{submodule_rest} %{name}/%{submodule_commands} %{name}/%{submodule_cli} slf4j/log4j12 opencsv"
CLASSPATH=%{CLASSPATH}
# Set parameters
@@ -215,22 +170,19 @@ chmod 755 %{buildroot}%{_bindir}/zanata-cli
%files -f .mfiles
-%if 0%{?fedora} > 18
%dir %{_javadir}/%{name}
-%endif
%attr(0755,root,root) %{_bindir}/zanata-cli
%doc README.txt
-%if 0%{?fedora} > 18
%files javadoc -f .mfiles-javadoc
-%else
-%files javadoc
-%{_javadocdir}/%{name}/%{submodule_rest}
-%{_javadocdir}/%{name}/%{submodule_commands}
-%{_javadocdir}/%{name}/%{submodule_cli}
-%endif
%changelog
+* Tue Jul 22 2014 Patrick Huang 2.2.0-4
+- Patch to fix SNI problem
+
+* Fri Nov 01 2013 Ding-Yi Chen 2.2.0-3
+- Fixes Bug 1025112 - zanata-cli: Incorrect BASE_JARS
+
* Thu May 16 2013 Patrick Huang 2.2.0-2
- Change license to LGPLv2+