Skip to content

Commit

Permalink
new version 0.0.12:
Browse files Browse the repository at this point in the history
* self signed SSL certificate (issue #1): throw error with self signed
certificates to suggest to use trust option
  • Loading branch information
mhelleboid committed Nov 29, 2015
1 parent c06e97a commit 43aa1c3
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion remotesync-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<parent>
<groupId>piwigo</groupId>
<artifactId>remotesync</artifactId>
<version>0.0.11</version>
<version>0.0.12</version>
<relativePath>../remotesync</relativePath>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.List;
import java.util.Map.Entry;

import javax.net.ssl.SSLException;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.NotImplementedException;
import org.apache.http.HttpHost;
Expand All @@ -35,6 +37,7 @@
import org.piwigo.remotesync.api.IClient;
import org.piwigo.remotesync.api.IClientConfiguration;
import org.piwigo.remotesync.api.exception.ClientException;
import org.piwigo.remotesync.api.exception.ClientSSLException;
import org.piwigo.remotesync.api.exception.ClientServerException;
import org.piwigo.remotesync.api.exception.ServerException;
import org.piwigo.remotesync.api.request.AbstractRequest;
Expand Down Expand Up @@ -105,7 +108,7 @@ protected <T extends BasicResponse> T doSendRequest(AbstractRequest<T> request)
}
}

protected <T extends BasicResponse> String getXmlResponse(AbstractRequest<T> request) throws ClientException, ServerException {
protected <T extends BasicResponse> String getXmlResponse(AbstractRequest<T> request) throws ClientServerException {
CloseableHttpResponse httpResponse = null;

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

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

return getHttpClient().execute(method);
} catch (SSLException e) {
throw new ClientSSLException("SSL certificate exception (Please use option 'Trust SSL certificates')", e);
} catch (Exception e) {
throw new ClientException("Unable to send request", e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*******************************************************************************
* Copyright (c) 2014 Matthieu Helleboid.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v2.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* Matthieu Helleboid - initial API and implementation
******************************************************************************/
package org.piwigo.remotesync.api.exception;

import javax.net.ssl.SSLException;


public class ClientSSLException extends ClientException {

private static final long serialVersionUID = -2534675861595722310L;

public ClientSSLException(String message, SSLException exception) {
super(message, exception);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import org.piwigo.remotesync.api.ISyncConfiguration;
import org.piwigo.remotesync.api.client.AuthenticatedWSClient;
import org.piwigo.remotesync.api.client.WSClient;
import org.piwigo.remotesync.api.exception.ClientServerException;
import org.piwigo.remotesync.api.request.PwgCategoriesAddRequest;
import org.piwigo.remotesync.api.request.PwgImagesAddSimpleRequest;
Expand All @@ -43,7 +42,7 @@ protected void connect() throws IOException {
logger.info("Connect successful");
} catch (ClientServerException e) {
client = null;
logger.error("Unable to connect : " + e.getMessage());
logger.error("Unable to connect : " + e.getMessage(), e);
throw new CancelException("Unable to connect", startDirectory, 0);
}
}
Expand All @@ -58,7 +57,7 @@ protected void disconnect() {
client = null;
logger.info("Disconnect successful");
} catch (ClientServerException e) {
logger.error("Unable to disconnect : " + e.getMessage());
logger.error("Unable to disconnect : " + e.getMessage(), e);
}
}

Expand Down
4 changes: 2 additions & 2 deletions remotesync-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<dependency>
<groupId>piwigo</groupId>
<artifactId>remotesync-api</artifactId>
<version>0.0.11</version>
<version>0.0.12</version>
</dependency>
<dependency>
<groupId>org.apache.pivot</groupId>
Expand Down Expand Up @@ -73,7 +73,7 @@
<parent>
<groupId>piwigo</groupId>
<artifactId>remotesync</artifactId>
<version>0.0.11</version>
<version>0.0.12</version>
<relativePath>../remotesync</relativePath>
</parent>
</project>
2 changes: 1 addition & 1 deletion remotesync/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<groupId>piwigo</groupId>
<artifactId>remotesync</artifactId>
<name>Piwigo Remote Sync</name>
<version>0.0.11</version>
<version>0.0.12</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down

0 comments on commit 43aa1c3

Please sign in to comment.