Skip to content

Commit a793f7a

Browse files
committed
new version 0.0.10:
* add ignore self signed SSL certificate (issue #1) * fix readme and build with maven 3
1 parent 34f6e7c commit a793f7a

10 files changed

Lines changed: 59 additions & 22 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.9</version>
146+
<version>0.0.10</version>
147147
<relativePath>../remotesync</relativePath>
148148
</parent>
149149
</project>

remotesync-api/src/main/java/org/piwigo/remotesync/api/IClientConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@ public interface IClientConfiguration {
2222
public String getProxyUsername();
2323
public String getProxyPassword();
2424

25+
public boolean getIgnoreSelfSignedSSLCertificate();
26+
2527
public int getChunkSize();
2628
}

remotesync-api/src/main/java/org/piwigo/remotesync/api/Tasks.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class Tasks {
2020

2121
//TODO return float/boolean/int instead of types
2222

23+
//TODO implement debug option from UI
2324
//TODO implement progressmonitor
2425
//TODO implement estimated time
2526
//TODO implement allpaging

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import org.apache.http.client.config.RequestConfig;
2626
import org.apache.http.client.methods.CloseableHttpResponse;
2727
import org.apache.http.client.methods.HttpPost;
28+
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
29+
import org.apache.http.conn.ssl.SSLContextBuilder;
30+
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
2831
import org.apache.http.entity.mime.MultipartEntityBuilder;
2932
import org.apache.http.impl.client.BasicCredentialsProvider;
3033
import org.apache.http.impl.client.CloseableHttpClient;
@@ -156,7 +159,7 @@ else if (value instanceof List) {
156159
}
157160
}
158161

159-
protected CloseableHttpClient getHttpClient() {
162+
protected CloseableHttpClient getHttpClient() throws Exception {
160163
if (httpClient == null) {
161164
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
162165

@@ -176,6 +179,13 @@ protected CloseableHttpClient getHttpClient() {
176179
HttpHost proxy = new HttpHost(proxyUrl, proxyPort);
177180
requestConfig = RequestConfig.custom().setProxy(proxy).build();
178181
}
182+
183+
if (clientConfiguration.getIgnoreSelfSignedSSLCertificate()) {
184+
SSLContextBuilder sslContextBuilder = new SSLContextBuilder();
185+
sslContextBuilder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
186+
httpClientBuilder.setSSLSocketFactory(new SSLConnectionSocketFactory(sslContextBuilder.build()));
187+
}
188+
179189
httpClient = httpClientBuilder.build();
180190
}
181191

remotesync-api/src/main/java/org/piwigo/remotesync/api/conf/SyncConfiguration.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public class SyncConfiguration implements ISyncConfiguration {
7070
@Validator(type = ValidatorType.string)
7171
protected String proxyPassword;
7272

73+
@Element(required = false)
74+
@Option(name = "-isssc", usage = "ignore self signed ssl certificates")
75+
protected String ignoreSelfSignedSSLCertificates = Boolean.FALSE.toString();
76+
7377
@Element(required = false)
7478
@Option(name = "-cs", usage = "chunk size (in Kbytes)")
7579
@Validator(type = ValidatorType.integer)
@@ -128,7 +132,7 @@ public void setDirectory(String directory) {
128132
public boolean getUsesProxy() {
129133
try {
130134
return Boolean.parseBoolean(usesProxy);
131-
} catch (NumberFormatException e) {
135+
} catch (Exception e) {
132136
return false;
133137
}
134138
}
@@ -173,6 +177,18 @@ public void setProxyPassword(String proxyPassword) {
173177
this.proxyPassword = proxyPassword;
174178
}
175179

180+
public boolean getIgnoreSelfSignedSSLCertificate() {
181+
try {
182+
return Boolean.parseBoolean(ignoreSelfSignedSSLCertificates);
183+
} catch (Exception e) {
184+
return false;
185+
}
186+
}
187+
188+
public void setIgnoreSelfSignedSSLCertificate(String string) {
189+
this.ignoreSelfSignedSSLCertificates = string;
190+
}
191+
176192
public int getChunkSize() {
177193
try {
178194
return Integer.parseInt(chunkSize);

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.9</version>
20+
<version>0.0.10</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.9</version>
76+
<version>0.0.10</version>
7777
<relativePath>../remotesync</relativePath>
7878
</parent>
7979
</project>

remotesync-ui/src/main/java/org/piwigo/remotesync/ui/swing/ProxyUI.java renamed to remotesync-ui/src/main/java/org/piwigo/remotesync/ui/swing/OptionsUI.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import org.piwigo.remotesync.api.conf.SyncConfiguration;
2828

29-
public class ProxyUI extends JFrame {
29+
public class OptionsUI extends JFrame {
3030

3131
private static final long serialVersionUID = -7945236553585527567L;
3232

@@ -36,12 +36,13 @@ public class ProxyUI extends JFrame {
3636
private JTextField proxyLogintextField;
3737
private JTextField proxyPasswordtextField;
3838
private JCheckBox chckbxUseProxy;
39+
private JCheckBox chckbxISSSC;
3940

4041
public static void run(final SyncConfiguration syncConfiguration) {
4142
EventQueue.invokeLater(new Runnable() {
4243
public void run() {
4344
try {
44-
ProxyUI frame = new ProxyUI(syncConfiguration);
45+
OptionsUI frame = new OptionsUI(syncConfiguration);
4546
frame.chckbxUseProxy.setSelected(false);
4647
frame.disableTextFields();
4748
frame.setVisible(true);
@@ -57,7 +58,7 @@ public void run() {
5758
*
5859
* @param syncConfiguration
5960
*/
60-
public ProxyUI(final SyncConfiguration syncConfiguration) {
61+
public OptionsUI(final SyncConfiguration syncConfiguration) {
6162
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
6263
setBounds(100, 100, 450, 300);
6364
contentPane = new JPanel();
@@ -110,6 +111,10 @@ public void stateChanged(ChangeEvent e) {
110111
contentPane.add(proxyPasswordtextField);
111112
proxyPasswordtextField.setColumns(10);
112113

114+
chckbxISSSC = new JCheckBox("Ignore self signed SSL certificates");
115+
chckbxISSSC.setBounds(8, 170, 300, 23);
116+
contentPane.add(chckbxISSSC);
117+
113118
addWindowListener(new WindowAdapter() {
114119
@Override
115120
public void windowClosing(WindowEvent e) {
@@ -119,6 +124,7 @@ public void windowClosing(WindowEvent e) {
119124
syncConfiguration.setProxyPort(proxyPorttextField.getText());
120125
syncConfiguration.setProxyUsername(proxyLogintextField.getText());
121126
syncConfiguration.setProxyPassword(proxyPasswordtextField.getText());
127+
syncConfiguration.setIgnoreSelfSignedSSLCertificate(Boolean.toString(chckbxISSSC.isSelected()));
122128
}
123129

124130
@Override
@@ -129,6 +135,7 @@ public void windowOpened(WindowEvent e) {
129135
proxyPorttextField.setText(syncConfiguration.getProxyPort() + "");
130136
proxyLogintextField.setText(syncConfiguration.getProxyUsername());
131137
proxyPasswordtextField.setText(syncConfiguration.getProxyPassword());
138+
chckbxISSSC.setSelected(syncConfiguration.getIgnoreSelfSignedSSLCertificate());
132139
}
133140

134141
});

remotesync-ui/src/main/java/org/piwigo/remotesync/ui/swing/RemotesyncUI.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class RemotesyncUI {
5050
private JButton syncButton;
5151
private JButton directoryButton;
5252
private JTextArea textArea;
53-
private JButton proxyButton;
53+
private JButton optionsButton;
5454

5555
private SyncConfiguration syncConfiguration = ConfigurationUtil.INSTANCE.getUserConfiguration().getCurrentSyncConfiguration();
5656
private JScrollPane scrollPane;
@@ -167,14 +167,14 @@ public void actionPerformed(ActionEvent e) {
167167
frame.getContentPane().add(directoryText);
168168
directoryText.setColumns(10);
169169

170-
proxyButton = new JButton("Proxy");
171-
proxyButton.addActionListener(new ActionListener() {
170+
optionsButton = new JButton("Options");
171+
optionsButton.addActionListener(new ActionListener() {
172172
public void actionPerformed(ActionEvent e) {
173173
proxy();
174174
}
175175
});
176-
proxyButton.setBounds(25, 257, 94, 36);
177-
frame.getContentPane().add(proxyButton);
176+
optionsButton.setBounds(25, 257, 94, 36);
177+
frame.getContentPane().add(optionsButton);
178178

179179
syncButton = new JButton("Sync");
180180
syncButton.addActionListener(new ActionListener() {
@@ -198,7 +198,7 @@ public void actionPerformed(ActionEvent e) {
198198

199199
protected void proxy() {
200200
logger.debug("RemotesyncUI proxy button pressed");
201-
ProxyUI.run(syncConfiguration);
201+
OptionsUI.run(syncConfiguration);
202202
}
203203

204204
protected void selectDirectory() {

remotesync/README.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
# Matthieu Helleboid - initial API and implementation
1010
#-------------------------------------------------------------------------------
1111

12-
#checkout remote sync
13-
svn checkout http://piwigo.org/svn/extensions/piwigo-remote-sync
14-
cd piwigo-remote-sync
12+
#install tools
13+
apt-get install git maven
1514

16-
#install build system
17-
apt-get install maven2
15+
#clone remote sync
16+
git clone https://github.com/Piwigo/Piwigo-Java.git
17+
cd Piwigo-Java
1818

1919
#build remote sync without tests
2020
cd remotesync

remotesync/pom.xml

Lines changed: 4 additions & 3 deletions
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.9</version>
17+
<version>0.0.10</version>
1818
<packaging>pom</packaging>
1919
<properties>
2020
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -34,16 +34,17 @@
3434
</license>
3535
</licenses>
3636
<scm>
37-
<url>http://piwigo.org/svn/extensions/piwigo-remote-sync</url>
37+
<url>https://github.com/Piwigo/Piwigo-Java.git</url>
3838
</scm>
3939
<issueManagement>
40-
<url>http://piwigo.org/bugs</url>
40+
<url>https://github.com/Piwigo/Piwigo-Java/issues</url>
4141
</issueManagement>
4242
<build>
4343
<plugins>
4444
<plugin>
4545
<groupId>org.apache.maven.plugins</groupId>
4646
<artifactId>maven-compiler-plugin</artifactId>
47+
<version>3.2</version>
4748
<configuration>
4849
<source>1.6</source>
4950
<target>1.6</target>

0 commit comments

Comments
 (0)