aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/CorporateBodyMandateContainer.java164
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateContainer.java157
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/PhyPersonMandateContainer.java154
3 files changed, 215 insertions, 260 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/CorporateBodyMandateContainer.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/CorporateBodyMandateContainer.java
index a75cdfb80..4bea124cb 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/CorporateBodyMandateContainer.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/CorporateBodyMandateContainer.java
@@ -1,5 +1,7 @@
package at.gv.egovernment.moa.id.protocols.stork2;
+import at.gv.egovernment.moa.id.auth.exception.MOAIDException;
+import at.gv.egovernment.moa.logging.Logger;
import javanet.staxutils.SimpleNamespaceContext;
import org.xml.sax.InputSource;
@@ -7,42 +9,32 @@ import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.StringReader;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.HashMap;
/**
* Physical person representing corporate body
+ *
* @author bsuzic
* Date: 4/29/14, Time: 3:40 PM
*/
-public class CorporateBodyMandateContainer {
-
- private String corpMandatorIdentificationValue = null;
- private String corpMandatorIdentificationType = null;
- private String corpMandatorFullName = null;
- private String mandateIssuePlace = null;
- private String mandateIssueDate = null;
- private String mandateIssueTime = null;
- private String simpleMandateContent = null;
- private String mandateValidFrom = null;
- private String mandateValidTo = null;
- private String annotation = null;
- private String physicalRepresentativeIdentificationValue = null;
- private String physicalRepresentativeIdentificationType = null;
- private String physicalRepresentativeGivenName = null;
- private String physicalRepresentativeFamilyName = null;
- private String physicalRepresentativeBirthDate = null;
-
-
- public CorporateBodyMandateContainer(String mandate) throws XPathExpressionException {
- XPath xPath = XPathFactory.newInstance().newXPath();
- HashMap<String, String> prefMap = new HashMap<String, String>() {{
- put(S2Constants.MANDATE_PREFIX, S2Constants.MANDATE_NS);
- put(S2Constants.PERSONDATA_PREFIX, S2Constants.PERSONDATA_NS);
- put(S2Constants.XMLDSIG_PREFIX, S2Constants.XMLDSIG_NS);
- }};
-
- SimpleNamespaceContext namespace = new SimpleNamespaceContext(prefMap);
- xPath.setNamespaceContext(namespace);
+public class CorporateBodyMandateContainer extends MandateContainer {
+
+ protected String corpMandatorIdentificationValue = null;
+ protected String corpMandatorIdentificationType = null;
+ protected String corpMandatorFullName = null;
+
+
+ String localMethods[] = new String[]{"getCorpMandatorIdentificationValue", "getCorpMandatorIdentificationType", "getCorpMandatorFullName",
+ "getMandateIssuePlace", "getMandateIssueDate", "getMandateIssueTime", "getSimpleMandateContent", "getMandateValidFrom",
+ "getMandateValidTo", "getPhysicalRepresentativeIdentificationValue", "getPhysicalRepresentativeIdentificationType", "getAnnotation",
+ "getPhysicalRepresentativeGivenName", "getPhysicalRepresentativeFamilyName", "getPhysicalRepresentativeBirthDate"
+ };
+
+ public CorporateBodyMandateContainer(String mandate) throws XPathExpressionException, MOAIDException {
+ super(mandate);
+ Logger.debug("Initializing corporate body mandate container.");
setAnnotation(xPath.evaluate(S2Constants.MANDATE_ANNOTATION_QUERY, new InputSource(new StringReader(mandate))));
setCorpMandatorFullName(xPath.evaluate(S2Constants.MANDATE_MANDATOR_CORPBODY_FULLNAME_QUERY, new InputSource(new StringReader(mandate))));
@@ -61,16 +53,23 @@ public class CorporateBodyMandateContainer {
setSimpleMandateContent(xPath.evaluate(S2Constants.MANDATE_SIMPLEMANDATECONTENT_TXTDESC_QUERY, new InputSource(new StringReader(mandate))));
// check if all necessary fields are present
- validateMandateStructure(); // TODO
-
- }
+ Logger.debug("Starting mandate structure validation");
+ try {
+ validateMandateStructure(localMethods); // TODO
+ } catch (Exception e) {
+ if (e instanceof MOAIDException) {
+ Logger.error("Could not validate mandate structure.");
+ throw new MOAIDException("stork.16", new Object[] {e.getMessage()}); // TODO
+ } else {
+ Logger.error("Error during mandate structure validation.");
+ throw new MOAIDException("stork.16", new Object[] {e.getMessage()}); // TODO
+ }
- public void validateMandateStructure() {
+ }
}
-
public String getCorpMandatorIdentificationValue() {
return corpMandatorIdentificationValue;
}
@@ -95,103 +94,6 @@ public class CorporateBodyMandateContainer {
this.corpMandatorFullName = corpMandatorFullName;
}
- public String getMandateIssuePlace() {
- return mandateIssuePlace;
- }
-
- public void setMandateIssuePlace(String mandateIssuePlace) {
- this.mandateIssuePlace = mandateIssuePlace;
- }
-
- public String getMandateIssueDate() {
- return mandateIssueDate;
- }
-
- public void setMandateIssueDate(String mandateIssueDate) {
- this.mandateIssueDate = mandateIssueDate;
- }
-
- public String getMandateIssueTime() {
- return mandateIssueTime;
- }
-
- public void setMandateIssueTime(String mandateIssueTime) {
- this.mandateIssueTime = mandateIssueTime;
- }
-
- public String getSimpleMandateContent() {
- return simpleMandateContent;
- }
-
- public void setSimpleMandateContent(String simpleMandateContent) {
- this.simpleMandateContent = simpleMandateContent;
- }
-
- public String getMandateValidFrom() {
- return mandateValidFrom;
- }
-
- public void setMandateValidFrom(String mandateValidFrom) {
- this.mandateValidFrom = mandateValidFrom;
- }
-
- public String getMandateValidTo() {
- return mandateValidTo;
- }
-
- public void setMandateValidTo(String mandateValidTo) {
- this.mandateValidTo = mandateValidTo;
- }
-
- public String getPhysicalRepresentativeIdentificationValue() {
- return physicalRepresentativeIdentificationValue;
- }
-
- public void setPhysicalRepresentativeIdentificationValue(String physicalRepresentativeIdentificationValue) {
- this.physicalRepresentativeIdentificationValue = physicalRepresentativeIdentificationValue;
- }
-
- public String getPhysicalRepresentativeIdentificationType() {
- return physicalRepresentativeIdentificationType;
- }
-
- public void setPhysicalRepresentativeIdentificationType(String physicalRepresentativeIdentificationType) {
- this.physicalRepresentativeIdentificationType = physicalRepresentativeIdentificationType;
- }
-
- public String getPhysicalRepresentativeGivenName() {
- return physicalRepresentativeGivenName;
- }
-
- public void setPhysicalRepresentativeGivenName(String physicalRepresentativeGivenName) {
- this.physicalRepresentativeGivenName = physicalRepresentativeGivenName;
- }
-
- public String getPhysicalRepresentativeFamilyName() {
- return physicalRepresentativeFamilyName;
- }
-
- public void setPhysicalRepresentativeFamilyName(String physicalRepresentativeFamilyName) {
- this.physicalRepresentativeFamilyName = physicalRepresentativeFamilyName;
- }
-
- public String getPhysicalRepresentativeBirthDate() {
- return physicalRepresentativeBirthDate;
- }
-
- public void setPhysicalRepresentativeBirthDate(String physicalRepresentativeBirthDate) {
- this.physicalRepresentativeBirthDate = physicalRepresentativeBirthDate;
- }
-
-
-
- public String getAnnotation() {
- return annotation;
- }
-
- public void setAnnotation(String annotation) {
- this.annotation = annotation;
- }
}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateContainer.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateContainer.java
new file mode 100644
index 000000000..542776f52
--- /dev/null
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateContainer.java
@@ -0,0 +1,157 @@
+package at.gv.egovernment.moa.id.protocols.stork2;
+
+import at.gv.egovernment.moa.id.auth.exception.MOAIDException;
+import at.gv.egovernment.moa.logging.Logger;
+import javanet.staxutils.SimpleNamespaceContext;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+/**
+ * @author bsuzic
+ * Date: 5/5/14, Time: 2:35 PM
+ */
+public abstract class MandateContainer {
+ protected String mandateIssuePlace = null;
+ protected String mandateIssueDate = null;
+ protected String mandateIssueTime = null;
+ protected String simpleMandateContent = null;
+ protected String mandateValidFrom = null;
+ protected String mandateValidTo = null;
+ protected String annotation = null;
+ protected String physicalRepresentativeIdentificationValue = null;
+ protected String physicalRepresentativeIdentificationType = null;
+ protected String physicalRepresentativeGivenName = null;
+ protected String physicalRepresentativeFamilyName = null;
+ protected String physicalRepresentativeBirthDate = null;
+ protected XPath xPath = null;
+
+
+ public MandateContainer(String mandate) throws XPathExpressionException, MOAIDException {
+ xPath = XPathFactory.newInstance().newXPath();
+ HashMap<String, String> prefMap = new HashMap<String, String>() {{
+ put(S2Constants.MANDATE_PREFIX, S2Constants.MANDATE_NS);
+ put(S2Constants.PERSONDATA_PREFIX, S2Constants.PERSONDATA_NS);
+ put(S2Constants.XMLDSIG_PREFIX, S2Constants.XMLDSIG_NS);
+ }};
+
+ SimpleNamespaceContext namespace = new SimpleNamespaceContext(prefMap);
+ xPath.setNamespaceContext(namespace);
+ }
+
+
+ public void validateMandateStructure(String localMethods[]) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, MOAIDException {
+ for (String localMethod : localMethods) {
+ Method method = this.getClass().getMethod(localMethod);
+ Object x = method.invoke(this);
+ if ((x == null) || x.toString().length() == 0) {
+ throw new MOAIDException("stork.16", new Object[] {localMethod}); // TODO
+ }
+ }
+ Logger.debug("Mandate structure validated");
+ }
+
+
+ public String getMandateIssuePlace() {
+ return mandateIssuePlace;
+ }
+
+ public void setMandateIssuePlace(String mandateIssuePlace) {
+ this.mandateIssuePlace = mandateIssuePlace;
+ }
+
+ public String getMandateIssueDate() {
+ return mandateIssueDate;
+ }
+
+ public void setMandateIssueDate(String mandateIssueDate) {
+ this.mandateIssueDate = mandateIssueDate;
+ }
+
+ public String getMandateIssueTime() {
+ return mandateIssueTime;
+ }
+
+ public void setMandateIssueTime(String mandateIssueTime) {
+ this.mandateIssueTime = mandateIssueTime;
+ }
+
+ public String getSimpleMandateContent() {
+ return simpleMandateContent;
+ }
+
+ public void setSimpleMandateContent(String simpleMandateContent) {
+ this.simpleMandateContent = simpleMandateContent;
+ }
+
+ public String getMandateValidFrom() {
+ return mandateValidFrom;
+ }
+
+ public void setMandateValidFrom(String mandateValidFrom) {
+ this.mandateValidFrom = mandateValidFrom;
+ }
+
+ public String getMandateValidTo() {
+ return mandateValidTo;
+ }
+
+ public void setMandateValidTo(String mandateValidTo) {
+ this.mandateValidTo = mandateValidTo;
+ }
+
+ public String getPhysicalRepresentativeIdentificationValue() {
+ return physicalRepresentativeIdentificationValue;
+ }
+
+ public void setPhysicalRepresentativeIdentificationValue(String physicalRepresentativeIdentificationValue) {
+ this.physicalRepresentativeIdentificationValue = physicalRepresentativeIdentificationValue;
+ }
+
+ public String getPhysicalRepresentativeIdentificationType() {
+ return physicalRepresentativeIdentificationType;
+ }
+
+ public void setPhysicalRepresentativeIdentificationType(String physicalRepresentativeIdentificationType) {
+ this.physicalRepresentativeIdentificationType = physicalRepresentativeIdentificationType;
+ }
+
+ public String getPhysicalRepresentativeGivenName() {
+ return physicalRepresentativeGivenName;
+ }
+
+ public void setPhysicalRepresentativeGivenName(String physicalRepresentativeGivenName) {
+ this.physicalRepresentativeGivenName = physicalRepresentativeGivenName;
+ }
+
+ public String getPhysicalRepresentativeFamilyName() {
+ return physicalRepresentativeFamilyName;
+ }
+
+ public void setPhysicalRepresentativeFamilyName(String physicalRepresentativeFamilyName) {
+ this.physicalRepresentativeFamilyName = physicalRepresentativeFamilyName;
+ }
+
+ public String getPhysicalRepresentativeBirthDate() {
+ return physicalRepresentativeBirthDate;
+ }
+
+ public void setPhysicalRepresentativeBirthDate(String physicalRepresentativeBirthDate) {
+ this.physicalRepresentativeBirthDate = physicalRepresentativeBirthDate;
+ }
+
+ public String getAnnotation() {
+ return annotation;
+ }
+
+ public void setAnnotation(String annotation) {
+ this.annotation = annotation;
+ }
+
+
+
+}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/PhyPersonMandateContainer.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/PhyPersonMandateContainer.java
index 6143d69b4..c4be57bd3 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/PhyPersonMandateContainer.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/PhyPersonMandateContainer.java
@@ -1,5 +1,7 @@
package at.gv.egovernment.moa.id.protocols.stork2;
+import at.gv.egovernment.moa.id.auth.exception.MOAIDException;
+import at.gv.egovernment.moa.logging.Logger;
import javanet.staxutils.SimpleNamespaceContext;
import org.xml.sax.InputSource;
@@ -14,37 +16,23 @@ import java.util.HashMap;
* @author bsuzic
* Date: 4/30/14, Time: 11:29 AM
*/
-public class PhyPersonMandateContainer {
+public class PhyPersonMandateContainer extends MandateContainer {
private String phyPersMandatorIdentificationValue = null;
private String phyPersMandatorIdentificationType = null;
private String phyPersMandatorGivenName = null;
private String phyPersMandatorFamilyName = null;
private String phyPersMandatorBirthDate = null;
- private String mandateIssuePlace = null;
- private String mandateIssueDate = null;
- private String mandateIssueTime = null;
- private String simpleMandateContent = null;
- private String mandateValidFrom = null;
- private String mandateValidTo = null;
- private String annotation = null;
- private String physicalRepresentativeIdentificationValue = null;
- private String physicalRepresentativeIdentificationType = null;
- private String physicalRepresentativeGivenName = null;
- private String physicalRepresentativeFamilyName = null;
- private String physicalRepresentativeBirthDate = null;
-
-
- public PhyPersonMandateContainer(String mandate) throws XPathExpressionException {
- XPath xPath = XPathFactory.newInstance().newXPath();
- HashMap<String, String> prefMap = new HashMap<String, String>() {{
- put(S2Constants.MANDATE_PREFIX, S2Constants.MANDATE_NS);
- put(S2Constants.PERSONDATA_PREFIX, S2Constants.PERSONDATA_NS);
- put(S2Constants.XMLDSIG_PREFIX, S2Constants.XMLDSIG_NS);
- }};
-
- SimpleNamespaceContext namespace = new SimpleNamespaceContext(prefMap);
- xPath.setNamespaceContext(namespace);
+
+ String localMethods[] = new String[]{"getPhyPersMandatorGivenName", "getPhyPersMandatorFamilyName", "getPhyPersMandatorBirthDate", "getPhyPersMandatorIdentificationValue",
+ "getPhyPersMandatorIdentificationType", "getMandateIssuePlace", "getMandateIssueDate", "getMandateIssueTime", "getSimpleMandateContent", "getMandateValidFrom",
+ "getMandateValidTo", "getPhysicalRepresentativeIdentificationValue", "getPhysicalRepresentativeIdentificationType", "getAnnotation",
+ "getPhysicalRepresentativeGivenName", "getPhysicalRepresentativeFamilyName", "getPhysicalRepresentativeBirthDate"
+ };
+
+
+ public PhyPersonMandateContainer(String mandate) throws XPathExpressionException, MOAIDException {
+ super(mandate);
setAnnotation(xPath.evaluate(S2Constants.MANDATE_ANNOTATION_QUERY, new InputSource(new StringReader(mandate))));
setPhyPersMandatorIdentificationType(xPath.evaluate(S2Constants.MANDATE_MANDATOR_PHYPERS_IDTYPE_QUERY, new InputSource(new StringReader(mandate))));
@@ -65,14 +53,22 @@ public class PhyPersonMandateContainer {
setSimpleMandateContent(xPath.evaluate(S2Constants.MANDATE_SIMPLEMANDATECONTENT_TXTDESC_QUERY, new InputSource(new StringReader(mandate))));
// check if all necessary fields are present
- validateMandateStructure(); // TODO
+ Logger.debug("Starting mandate structure validation");
+ try {
+ validateMandateStructure(localMethods); // TODO
+ } catch (Exception e) {
+ if (e instanceof MOAIDException) {
+ Logger.error("Could not validate mandate structure.");
+ throw new MOAIDException("stork.16", new Object[] {e.getMessage()}); // TODO
+ } else {
+ Logger.error("Error during mandate structure validation.");
+ throw new MOAIDException("stork.16", new Object[] {e.getMessage()}); // TODO
+ }
+ }
}
- public void validateMandateStructure() {
-
- }
public String getPhyPersMandatorGivenName() {
return phyPersMandatorGivenName;
@@ -114,104 +110,4 @@ public class PhyPersonMandateContainer {
this.phyPersMandatorIdentificationType = phyPersMandatorIdentificationType;
}
- public String getMandateIssuePlace() {
- return mandateIssuePlace;
- }
-
- public void setMandateIssuePlace(String mandateIssuePlace) {
- this.mandateIssuePlace = mandateIssuePlace;
- }
-
- public String getMandateIssueDate() {
- return mandateIssueDate;
- }
-
- public void setMandateIssueDate(String mandateIssueDate) {
- this.mandateIssueDate = mandateIssueDate;
- }
-
- public String getMandateIssueTime() {
- return mandateIssueTime;
- }
-
- public void setMandateIssueTime(String mandateIssueTime) {
- this.mandateIssueTime = mandateIssueTime;
- }
-
- public String getSimpleMandateContent() {
- return simpleMandateContent;
- }
-
- public void setSimpleMandateContent(String simpleMandateContent) {
- this.simpleMandateContent = simpleMandateContent;
- }
-
- public String getMandateValidFrom() {
- return mandateValidFrom;
- }
-
- public void setMandateValidFrom(String mandateValidFrom) {
- this.mandateValidFrom = mandateValidFrom;
- }
-
- public String getMandateValidTo() {
- return mandateValidTo;
- }
-
- public void setMandateValidTo(String mandateValidTo) {
- this.mandateValidTo = mandateValidTo;
- }
-
- public String getAnnotation() {
- return annotation;
- }
-
- public void setAnnotation(String annotation) {
- this.annotation = annotation;
- }
-
- public String getPhysicalRepresentativeIdentificationValue() {
- return physicalRepresentativeIdentificationValue;
- }
-
- public void setPhysicalRepresentativeIdentificationValue(String physicalRepresentativeIdentificationValue) {
- this.physicalRepresentativeIdentificationValue = physicalRepresentativeIdentificationValue;
- }
-
- public String getPhysicalRepresentativeIdentificationType() {
- return physicalRepresentativeIdentificationType;
- }
-
- public void setPhysicalRepresentativeIdentificationType(String physicalRepresentativeIdentificationType) {
- this.physicalRepresentativeIdentificationType = physicalRepresentativeIdentificationType;
- }
-
- public String getPhysicalRepresentativeGivenName() {
- return physicalRepresentativeGivenName;
- }
-
- public void setPhysicalRepresentativeGivenName(String physicalRepresentativeGivenName) {
- this.physicalRepresentativeGivenName = physicalRepresentativeGivenName;
- }
-
- public String getPhysicalRepresentativeFamilyName() {
- return physicalRepresentativeFamilyName;
- }
-
- public void setPhysicalRepresentativeFamilyName(String physicalRepresentativeFamilyName) {
- this.physicalRepresentativeFamilyName = physicalRepresentativeFamilyName;
- }
-
- public String getPhysicalRepresentativeBirthDate() {
- return physicalRepresentativeBirthDate;
- }
-
- public void setPhysicalRepresentativeBirthDate(String physicalRepresentativeBirthDate) {
- this.physicalRepresentativeBirthDate = physicalRepresentativeBirthDate;
- }
-
-
-
-
-
}