Skip to content

Commit

Permalink
Added HTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy-LSA committed Nov 13, 2014
1 parent af33f5c commit 51c1465
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
Binary file modified supoxy/Distribution/SuPoxy.jar
Binary file not shown.
Binary file modified supoxy/bin/de/waldmensch/SuPoxyConnect.class
Binary file not shown.
Binary file modified supoxy/bin/de/waldmensch/SuPoxyDataObject.class
Binary file not shown.
29 changes: 25 additions & 4 deletions supoxy/src/de/waldmensch/SuPoxyConnect.java
Expand Up @@ -2,6 +2,11 @@

import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -13,6 +18,9 @@
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContextBuilder;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
Expand All @@ -24,7 +32,7 @@
public class SuPoxyConnect extends Thread {

/** Sunny Portal address */
private static final String HOST = "http://www.sunnyportal.com";
private static final String HOST = "https://www.sunnyportal.com";
/** Login path, used for posting login data */
private static final String LOGIN = HOST + "/Templates/Start.aspx";
/** Path to LiveData JSON */
Expand Down Expand Up @@ -67,7 +75,7 @@ public void run(){

WebConnect();

} catch (IllegalStateException | IOException | InterruptedException e) {
} catch (IllegalStateException | IOException | InterruptedException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {

// TODO Auto-generated catch block
e.printStackTrace();
Expand All @@ -77,16 +85,29 @@ public void run(){
SuPoxyUtils.log("WebConnect Thread ended " + getName());
}

public static void WebConnect() throws IOException, IllegalStateException, InterruptedException {
public static void WebConnect() throws IOException, IllegalStateException, InterruptedException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {

SSLContextBuilder builder = new SSLContextBuilder();

builder.loadTrustMaterial(null, new TrustSelfSignedStrategy(){
public boolean isTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
return true;
}
});

SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

BasicCookieStore cookieStore = new BasicCookieStore();
CloseableHttpClient httpclient = HttpClients.custom()
.setDefaultCookieStore(cookieStore)
.setSSLSocketFactory(sslsf)
.setRedirectStrategy(new LaxRedirectStrategy())
.setUserAgent("Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36")
.build();

SuPoxyUtils.log("SuPoxy try to log in");

login(httpclient);
SuPoxyUtils.log("SuPoxy login done");

Expand Down Expand Up @@ -141,7 +162,7 @@ private static void getLiveData(CloseableHttpClient httpclient) throws FileNotFo
} catch (ClientProtocolException eIO) {
SuPoxyUtils.log("getLiveData ClientProtocolException");
} catch (IOException eIO) {
SuPoxyUtils.log("getLiveData IO Error");
SuPoxyUtils.log("getLiveData IO Error " + eIO.getMessage());
}

}
Expand Down
1 change: 1 addition & 0 deletions supoxy/src/de/waldmensch/SuPoxyDataObject.java
Expand Up @@ -12,6 +12,7 @@ public class SuPoxyDataObject {
public SuPoxyDataObject(String JSONString) throws ParseException {

JSONRaw = JSONString;
//SuPoxyUtils.log(JSONRaw);
JSONObject json;
//SuPoxyUtils.log(JSONString);
json = (JSONObject) new JSONParser().parse(JSONString);
Expand Down

0 comments on commit 51c1465

Please sign in to comment.