summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku
diff options
context:
space:
mode:
authorBianca Schnalzer <bianca.schnalzer@egiz.gv.at>2017-10-30 10:30:19 +0100
committerBianca Schnalzer <bianca.schnalzer@egiz.gv.at>2017-10-30 10:30:19 +0100
commit02e562d514c339618bbd304a3685f12eaae29fcb (patch)
tree2eead76eb0e587df14e5a5a186cc59f907d9d77b /pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku
parentf37aa6afcbf59116ba59d3cac9122ae8348614a1 (diff)
downloadpdf-over-02e562d514c339618bbd304a3685f12eaae29fcb.tar.gz
pdf-over-02e562d514c339618bbd304a3685f12eaae29fcb.tar.bz2
pdf-over-02e562d514c339618bbd304a3685f12eaae29fcb.zip
using PDF-AS 4.1.1., updated error handling for connection and MobileBKU
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java21
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java2
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/SimpleXMLTrustManager.java144
3 files changed, 90 insertions, 77 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java
index c4b7e6b9..de34796c 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/IAIKHandler.java
@@ -163,6 +163,19 @@ public class IAIKHandler extends MobileBKUHandler {
new SLResponse(responseData, status.getServer(), null, null));
return;
}
+
+ if (responseData.contains("tanCodeLogon"))
+ {
+ refVal = MobileBKUHelper.extractContentFromTagWithParam(responseData,
+ "span", "id", "tanCodeLogon:refValue"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ else
+ {
+ refVal = MobileBKUHelper.extractContentFromTagWithParam(responseData,
+ "span", "id", "j_idt5:refValue"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+
if (responseData.contains("/error")) { //$NON-NLS-1$
// Error response - try again
@@ -177,9 +190,9 @@ public class IAIKHandler extends MobileBKUHandler {
return;
}
- refVal = MobileBKUHelper.extractContentFromTagWithParam(responseData,
- "span", "id", "j_idt5:refValue"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
+
+
+
String viewState = MobileBKUHelper.extractValueFromTagWithParam(
responseData, "input", "name", "javax.faces.ViewState", "value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
status.setViewState(viewState);
@@ -187,6 +200,8 @@ public class IAIKHandler extends MobileBKUHandler {
if (!responseData.contains("tanCodeLogon.jsf")) { //$NON-NLS-1$
// Assume that we need to confirm reference value dialog
log.debug("viewState: " + viewState); //$NON-NLS-1$
+
+
PostMethod post = new PostMethod(redirectURL);
post.getParams().setContentCharset("utf-8"); //$NON-NLS-1$
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java
index 1e4431a4..52444ad1 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/bku/mobile/MobileBKUHelper.java
@@ -99,7 +99,7 @@ public class MobileBKUHelper {
public static String extractTagWithParam(String data, String tag,
String param, String value) throws Exception {
String start = '<' + tag;
- int startidx, endidx = 0;
+ int startidx, endidx = 0;
while ((startidx = data.indexOf(start, endidx)) != -1) {
endidx = data.indexOf('>', startidx);
if (endidx == -1) {
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 46a4dcfc..9e166e89 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
@@ -83,102 +83,103 @@ public class SimpleXMLTrustManager implements X509TrustManager {
}
/*
- *Certificates
+ * Certificates
*/
- KeyStore myKeyStore = KeyStore.getInstance(KeyStore
- .getDefaultType());
+ KeyStore myKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
myKeyStore.load(null);
- Document doc = DocumentBuilderFactory.newInstance()
- .newDocumentBuilder()
+ Document doc = DocumentBuilderFactory.newInstance().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();
+ NodeList certificateList = certificates.getChildNodes();
- 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$
- }
+ try {
+ if (!certificates.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++) {
- try {
+ //add trusted certificates to certStore//
+ for (int i = 0; i < certificateList.getLength(); i++) {
+ try {
- Node certificateNode = certificateList.item(i);
+ Node certificateNode = certificateList.item(i);
- if (certificateNode.getNodeName().equals("#text")) { //$NON-NLS-1$
- continue; // Ignore dummy text node ..
- }
+ if (certificateNode.getNodeName().equals("#text")) { //$NON-NLS-1$
+ continue; // Ignore dummy text node ..
+ }
- if (!certificateNode.getNodeName().equals("certificate")) { //$NON-NLS-1$
- log.warn("Ignoring XML node: " + certificateNode.getNodeName()); //$NON-NLS-1$
- continue;
- }
+ if (!certificateNode.getNodeName().equals("certificate")) { //$NON-NLS-1$
+ log.warn("Ignoring XML node: " + certificateNode.getNodeName()); //$NON-NLS-1$
+ continue;
+ }
- String certResource = Constants.RES_CERT_PATH+ certificateNode.getTextContent();
+ String certResource = Constants.RES_CERT_PATH + certificateNode.getTextContent();
- X509Certificate cert = (X509Certificate) CertificateFactory
- .getInstance("X509"). //$NON-NLS-1$
- generateCertificate(
- this.getClass().getResourceAsStream(
- certResource));
+ X509Certificate cert = (X509Certificate) CertificateFactory.getInstance("X509"). //$NON-NLS-1$
+ generateCertificate(this.getClass().getResourceAsStream(certResource));
- myKeyStore.setCertificateEntry(certificateNode.getTextContent(), cert);
+ myKeyStore.setCertificateEntry(certificateNode.getTextContent(), cert);
- log.debug("Loaded certificate : " + certResource); //$NON-NLS-1$
+ log.debug("Loaded certificate : " + certResource); //$NON-NLS-1$
- } catch (Exception ex) {
- log.error("Failed to load certificate [" + "]", ex); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (Exception ex) {
+ log.error("Failed to load certificate [" + "]", ex); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
+
}
+
+ catch (Exception e) {
+ e.toString();
+ }
+
+ File added_cert = new File(Constants.RES_CERT_LIST_ADDED);
-
- for (int i = 0; i < certificates_added_list.getLength(); i++) {
- try {
+ //check if the additional certificates.xml file exists//
- Node certificateNode = certificates_added_list.item(i);
+ if (added_cert.exists()) {
+ Node certificates_added = null;
- if (certificateNode.getNodeName().equals("#text")) { //$NON-NLS-1$
- continue; // Ignore dummy text node ..
- }
+ Document doc_added = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(added_cert);
- if (!certificateNode.getNodeName().equals("certificate")) { //$NON-NLS-1$
- log.warn("Ignoring XML node: " + certificateNode.getNodeName()); //$NON-NLS-1$
- continue;
- }
-
- if (!certificateNode.getTextContent().equals(""))
- {
- String certResource = Constants.RES_CERT_PATH_ADDED + certificateNode.getTextContent();
+ certificates_added = doc_added.getFirstChild();
+
+ NodeList certificates_added_list = certificates_added.getChildNodes();
- FileInputStream addedNode = new FileInputStream(certResource);
-
- X509Certificate cert = (X509Certificate) CertificateFactory
- .getInstance("X509"). //$NON-NLS-1$
- generateCertificate(
- addedNode);
+ //if exists, add trusted certificates to cert-Store
+ for (int i = 0; i < certificates_added_list.getLength(); i++) {
+ try {
- myKeyStore.setCertificateEntry(certificateNode.getTextContent(), cert);
+ Node certificateNode = certificates_added_list.item(i);
- log.debug("Loaded certificate : " + certResource); //$NON-NLS-1$
+ if (certificateNode.getNodeName().equals("#text")) { //$NON-NLS-1$
+ continue; // Ignore dummy text node ..
+ }
+
+ if (!certificateNode.getNodeName().equals("certificate")) { //$NON-NLS-1$
+ log.warn("Ignoring XML node: " + certificateNode.getNodeName()); //$NON-NLS-1$
+ continue;
+ }
+
+ if (!certificateNode.getTextContent().equals("")) {
+ String certResource = Constants.RES_CERT_PATH_ADDED + certificateNode.getTextContent();
+
+ FileInputStream addedNode = new FileInputStream(certResource);
+
+ X509Certificate cert = (X509Certificate) CertificateFactory.getInstance("X509"). //$NON-NLS-1$
+ generateCertificate(addedNode);
+
+ myKeyStore.setCertificateEntry(certificateNode.getTextContent(), cert);
+
+ log.debug("Loaded certificate : " + certResource); //$NON-NLS-1$
+ }
+ } catch (Exception ex) {
+ log.error("Failed to load certificate [" + "]", ex); //$NON-NLS-1$ //$NON-NLS-2$
}
- } catch (Exception ex) {
- log.error("Failed to load certificate [" + "]", ex); //$NON-NLS-1$ //$NON-NLS-2$
}
}
-
tmf.init(myKeyStore);
@@ -195,8 +196,7 @@ public class SimpleXMLTrustManager implements X509TrustManager {
}
}
- if (this.sunJSSEX509TrustManager != null
- && this.atrustTrustManager != null) {
+ if (this.sunJSSEX509TrustManager != null && this.atrustTrustManager != null) {
return;
}
@@ -215,8 +215,7 @@ public class SimpleXMLTrustManager implements X509TrustManager {
* X509Certificate[], java.lang.String)
*/
@Override
- public void checkClientTrusted(X509Certificate[] arg0, String arg1)
- throws CertificateException {
+ public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
try {
this.atrustTrustManager.checkServerTrusted(arg0, arg1);
} catch (CertificateException ex) {
@@ -237,8 +236,7 @@ public class SimpleXMLTrustManager implements X509TrustManager {
* X509Certificate[], java.lang.String)
*/
@Override
- public void checkServerTrusted(X509Certificate[] arg0, String arg1)
- throws CertificateException {
+ public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
try {
this.atrustTrustManager.checkServerTrusted(arg0, arg1);
} catch (CertificateException ex) {