Skip to content

Commit 43aa1c3

Browse files
committed
new version 0.0.12:
* self signed SSL certificate (issue #1): throw error with self signed certificates to suggest to use trust option
1 parent c06e97a commit 43aa1c3

6 files changed

Lines changed: 37 additions & 8 deletions

File tree

remotesync-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
<parent>
144144
<groupId>piwigo</groupId>
145145
<artifactId>remotesync</artifactId>
146-
<version>0.0.11</version>
146+
<version>0.0.12</version>
147147
<relativePath>../remotesync</relativePath>
148148
</parent>
149149
</project>

remotesync-api/src/main/java/org/piwigo/remotesync/api/client/WSClient.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import java.util.List;
1616
import java.util.Map.Entry;
1717

18+
import javax.net.ssl.SSLException;
19+
1820
import org.apache.commons.io.IOUtils;
1921
import org.apache.commons.lang.NotImplementedException;
2022
import org.apache.http.HttpHost;
@@ -35,6 +37,7 @@
3537
import org.piwigo.remotesync.api.IClient;
3638
import org.piwigo.remotesync.api.IClientConfiguration;
3739
import org.piwigo.remotesync.api.exception.ClientException;
40+
import org.piwigo.remotesync.api.exception.ClientSSLException;
3841
import org.piwigo.remotesync.api.exception.ClientServerException;
3942
import org.piwigo.remotesync.api.exception.ServerException;
4043
import org.piwigo.remotesync.api.request.AbstractRequest;
@@ -105,7 +108,7 @@ protected <T extends BasicResponse> T doSendRequest(AbstractRequest<T> request)
105108
}
106109
}
107110

108-
protected <T extends BasicResponse> String getXmlResponse(AbstractRequest<T> request) throws ClientException, ServerException {
111+
protected <T extends BasicResponse> String getXmlResponse(AbstractRequest<T> request) throws ClientServerException {
109112
CloseableHttpResponse httpResponse = null;
110113

111114
try {
@@ -115,6 +118,8 @@ protected <T extends BasicResponse> String getXmlResponse(AbstractRequest<T> req
115118
throw new ServerException(httpResponse.getStatusLine().getReasonPhrase() + " (code " + httpResponse.getStatusLine().getStatusCode() + ")");
116119

117120
return IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8");
121+
} catch (ClientServerException e) {
122+
throw e;
118123
} catch (Exception e) {
119124
throw new ClientException("Unable to read response content", e);
120125
} finally {
@@ -154,6 +159,8 @@ else if (value instanceof List) {
154159
method.setEntity(multipartEntityBuilder.build());
155160

156161
return getHttpClient().execute(method);
162+
} catch (SSLException e) {
163+
throw new ClientSSLException("SSL certificate exception (Please use option 'Trust SSL certificates')", e);
157164
} catch (Exception e) {
158165
throw new ClientException("Unable to send request", e);
159166
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2014 Matthieu Helleboid.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the GNU Public License v2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
7+
*
8+
* Contributors:
9+
* Matthieu Helleboid - initial API and implementation
10+
******************************************************************************/
11+
package org.piwigo.remotesync.api.exception;
12+
13+
import javax.net.ssl.SSLException;
14+
15+
16+
public class ClientSSLException extends ClientException {
17+
18+
private static final long serialVersionUID = -2534675861595722310L;
19+
20+
public ClientSSLException(String message, SSLException exception) {
21+
super(message, exception);
22+
}
23+
}

remotesync-api/src/main/java/org/piwigo/remotesync/api/sync/ConnectedWalker.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import org.piwigo.remotesync.api.ISyncConfiguration;
1818
import org.piwigo.remotesync.api.client.AuthenticatedWSClient;
19-
import org.piwigo.remotesync.api.client.WSClient;
2019
import org.piwigo.remotesync.api.exception.ClientServerException;
2120
import org.piwigo.remotesync.api.request.PwgCategoriesAddRequest;
2221
import org.piwigo.remotesync.api.request.PwgImagesAddSimpleRequest;
@@ -43,7 +42,7 @@ protected void connect() throws IOException {
4342
logger.info("Connect successful");
4443
} catch (ClientServerException e) {
4544
client = null;
46-
logger.error("Unable to connect : " + e.getMessage());
45+
logger.error("Unable to connect : " + e.getMessage(), e);
4746
throw new CancelException("Unable to connect", startDirectory, 0);
4847
}
4948
}
@@ -58,7 +57,7 @@ protected void disconnect() {
5857
client = null;
5958
logger.info("Disconnect successful");
6059
} catch (ClientServerException e) {
61-
logger.error("Unable to disconnect : " + e.getMessage());
60+
logger.error("Unable to disconnect : " + e.getMessage(), e);
6261
}
6362
}
6463

remotesync-ui/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<dependency>
1818
<groupId>piwigo</groupId>
1919
<artifactId>remotesync-api</artifactId>
20-
<version>0.0.11</version>
20+
<version>0.0.12</version>
2121
</dependency>
2222
<dependency>
2323
<groupId>org.apache.pivot</groupId>
@@ -73,7 +73,7 @@
7373
<parent>
7474
<groupId>piwigo</groupId>
7575
<artifactId>remotesync</artifactId>
76-
<version>0.0.11</version>
76+
<version>0.0.12</version>
7777
<relativePath>../remotesync</relativePath>
7878
</parent>
7979
</project>

remotesync/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<groupId>piwigo</groupId>
1515
<artifactId>remotesync</artifactId>
1616
<name>Piwigo Remote Sync</name>
17-
<version>0.0.11</version>
17+
<version>0.0.12</version>
1818
<packaging>pom</packaging>
1919
<properties>
2020
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

0 commit comments

Comments
 (0)