summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java
diff options
context:
space:
mode:
authorBianca Schnalzer <bianca.schnalzer@egiz.gv.at>2017-08-23 14:33:46 +0200
committerBianca Schnalzer <bianca.schnalzer@egiz.gv.at>2017-08-23 14:33:46 +0200
commit0e59a64b983d7d6872794887d1d8dec51b4c8cd6 (patch)
treec82e4e73d14fc1bcec7a26453c0e8b1a957eb514 /pdf-over-gui/src/main/java
parent69cec3514fd58f1ca044a689a3540d4b4724fb3a (diff)
downloadpdf-over-0e59a64b983d7d6872794887d1d8dec51b4c8cd6.tar.gz
pdf-over-0e59a64b983d7d6872794887d1d8dec51b4c8cd6.tar.bz2
pdf-over-0e59a64b983d7d6872794887d1d8dec51b4c8cd6.zip
Internet Connection Tracking
Diffstat (limited to 'pdf-over-gui/src/main/java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java36
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java19
2 files changed, 17 insertions, 38 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java
index adbd05ad..ee2448f5 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java
@@ -95,13 +95,22 @@ public class SimpleXMLTrustManager implements X509TrustManager {
.newDocumentBuilder()
.parse(this.getClass().getResourceAsStream(Constants.RES_CERT_LIST));
+
+ File added_cert = new File(Constants.RES_CERT_LIST_ADDED);
+
+ Document doc_added = DocumentBuilderFactory.newInstance()
+ .newDocumentBuilder()
+ .parse(added_cert);
+
+ Node certificates_added = doc_added.getFirstChild();
Node certificates = doc.getFirstChild();
- if (!certificates.getNodeName().equals("certificates")) { //$NON-NLS-1$
+ if (!certificates.getNodeName().equals("certificates") && !certificates_added.getNodeName().equals("certificates")) { //$NON-NLS-1$
throw new Exception(
"Used certificates xml is invalid! no certificates node"); //$NON-NLS-1$
}
+ NodeList certificates_added_list = certificates_added.getChildNodes();
NodeList certificateList = certificates.getChildNodes();
for (int i = 0; i < certificateList.getLength(); i++) {
@@ -135,29 +144,6 @@ public class SimpleXMLTrustManager implements X509TrustManager {
}
}
-
- File added_cert = new File(Constants.RES_CERT_LIST_ADDED);
-
- if (added_cert.exists())
- {
- Document doc_added = DocumentBuilderFactory.newInstance()
- .newDocumentBuilder()
- .parse(added_cert);
-
- Node certificates_added = doc_added.getFirstChild();
-
- if (!certificates_added.getNodeName().equals("certificates")) { //$NON-NLS-1$
- throw new Exception(
- "Used certificates xml is invalid! no certificates node"); //$NON-NLS-1$
- }
-
-
- if (certificates_added.hasChildNodes())
- {
-
- NodeList certificates_added_list = certificates_added.getChildNodes();
-
-
for (int i = 0; i < certificates_added_list.getLength(); i++) {
try {
@@ -189,7 +175,7 @@ public class SimpleXMLTrustManager implements X509TrustManager {
log.error("Failed to load certificate [" + "]", ex); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- }}
+
tmf.init(myKeyStore);
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java
index 955097fc..f6c1eb29 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/CertificateDownloadSource.java
@@ -60,14 +60,7 @@ public class CertificateDownloadSource {
URL url = new URL(Constants.CERTIFICATE_DOWNLOAD_XML_URL+Constants.CERTIFICATE_XML_FILE);
URLConnection connection = url.openConnection();
InputStream is = connection.getInputStream();
-
- int b = is.read();
- if (b==-1)
- {
- log.info("Cannot read file");
- }
- else
- {
+
BufferedInputStream bis = new BufferedInputStream(is);
FileOutputStream fis2 = new FileOutputStream(new File(Constants.RES_CERT_LIST_ADDED));
@@ -80,7 +73,7 @@ public class CertificateDownloadSource {
fis2.close();
bis.close();
downloadCertificatesFromServer();
- }
+
} catch (IOException e) {
log.debug("File not found");}
@@ -110,9 +103,7 @@ public class CertificateDownloadSource {
Node certificates_added = doc_added.getFirstChild();
NodeList certificates_added_list = certificates_added.getChildNodes();
-
- if (doc_added.hasChildNodes())
- {
+
//identify the certificate that has to be downloaded
for (int i = 0; i < certificates_added_list.getLength(); i++) {
try {
@@ -152,7 +143,9 @@ public class CertificateDownloadSource {
}
}
- }}
+ }
+
+
} catch (IOException e) {
e.printStackTrace();