aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main
diff options
context:
space:
mode:
authorBojan Suzic <bojan.suzic@iaik.tugraz.at>2014-06-13 18:57:31 +0200
committerBojan Suzic <bojan.suzic@iaik.tugraz.at>2014-06-13 18:57:31 +0200
commit34213284eeb7019f8d15af44d32f1850a0dae290 (patch)
tree336e81c811d0cbc9b20d66eef8cc45ea9adb6a13 /id/server/idserverlib/src/main
parent506a34dbd503fa7afd8c4fea52bbe08e3066f6a9 (diff)
downloadmoa-id-spss-34213284eeb7019f8d15af44d32f1850a0dae290.tar.gz
moa-id-spss-34213284eeb7019f8d15af44d32f1850a0dae290.tar.bz2
moa-id-spss-34213284eeb7019f8d15af44d32f1850a0dae290.zip
refactoring
Diffstat (limited to 'id/server/idserverlib/src/main')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateRetrievalRequest.java48
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/STORKProtocol.java102
-rw-r--r--id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties2
-rw-r--r--id/server/idserverlib/src/main/resources/resources/properties/protocol_response_statuscodes_de.properties2
4 files changed, 85 insertions, 69 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateRetrievalRequest.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateRetrievalRequest.java
index ab189c59d..72dc81b35 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateRetrievalRequest.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateRetrievalRequest.java
@@ -182,11 +182,11 @@ public class MandateRetrievalRequest implements IAction {
RepresentationPersonType represented = getRepresented(mandateContainer, currentAttribute);
if (mandateContainer instanceof CorporateBodyMandateContainer) {
return "AT/".concat(represented.getELPIdentifier());
- } else {
+ } else if (currentAttribute.isRequired()) {
Logger.error("Cannot provide eLPIdentifier for natural person.");
- throw new MOAIDException("stork.16", new Object[]{}); // TODO
+ throw new MOAIDException("stork.19", new Object[]{currentAttribute.getName()});
}
-
+ return "";
}
private PersonalAttribute marshallComplexAttribute(PersonalAttribute currentAttribute, Object obj) { // TODO refactor
@@ -214,16 +214,18 @@ public class MandateRetrievalRequest implements IAction {
value.add(stringWriter.toString());
PersonalAttribute personalAttribute = new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), value, AttributeStatusType.AVAILABLE.value());
-
return personalAttribute;
}
- private String mapPowersType(MandateContainer mandateContainer) { // TODO
- return "";
- }
-
- private String mapCompanyType(MandateContainer mandateContainer) { // TODO
+ private String mapPowersType(MandateContainer mandateContainer) {
+ if (mandateContainer.getAnnotation().equals("ELGABilateral")) {
+ return "6"; // Health Powers
+ } else if (mandateContainer.getAnnotation().equals("ERsB")) {
+ return "0"; // General Powers
+ } else if (mandateContainer.getAnnotation().equals("GeneralvollmachtBilateral")) {
+ return "0"; // General Powers
+ }
return "";
}
@@ -232,6 +234,7 @@ public class MandateRetrievalRequest implements IAction {
RepresentationPersonType representative = getRepresentative(mandateContainer, sourceAttribute);
RepresentationPersonType represented = getRepresented(mandateContainer, sourceAttribute);
MandateContentType mandateContent = getMandateContent(mandateContainer, sourceAttribute);
+
mandateType.setRepresenting(representative);
mandateType.setRepresented(represented);
mandateType.setMandateContent(mandateContent);
@@ -243,21 +246,22 @@ public class MandateRetrievalRequest implements IAction {
RepresentationPersonType represented = getRepresented(mandateContainer, sourceAttribute);
if (mandateContainer instanceof CorporateBodyMandateContainer) {
return represented.getName();
- } else {
+ } else if (sourceAttribute.isRequired()) {
Logger.error("Cannot provide legalName for natural person.");
- throw new MOAIDException("stork.16", new Object[]{}); // TODO
+ throw new MOAIDException("stork.19", new Object[]{sourceAttribute.getName()});
}
+ return "";
}
private String getLegalIdentificationType(MandateContainer mandateContainer, PersonalAttribute sourceAttribute) throws MOAIDException {
- RepresentationPersonType represented = getRepresented(mandateContainer, sourceAttribute);
if (mandateContainer instanceof CorporateBodyMandateContainer) {
return ((CorporateBodyMandateContainer) mandateContainer).getCorpMandatorIdentificationType();
- } else {
+ } else if (sourceAttribute.isRequired()) {
Logger.error("Cannot provide type for natural person.");
- throw new MOAIDException("stork.16", new Object[]{}); // TODO
+ throw new MOAIDException("stork.19", new Object[]{sourceAttribute.getName()}); // TODO
}
+ return "";
}
private String getCompanyType(MandateContainer mandateContainer, PersonalAttribute sourceAttribute) throws MOAIDException {
@@ -366,16 +370,15 @@ public class MandateRetrievalRequest implements IAction {
return representative;
}
- private RepresentationPersonType getRepresented(MandateContainer mandateContainer, PersonalAttribute sourceAttribute) {
+ private RepresentationPersonType getRepresented(MandateContainer mandateContainer, PersonalAttribute sourceAttribute) throws MOAIDException {
RepresentationPersonType represented = new RepresentationPersonType();
if (mandateContainer instanceof CorporateBodyMandateContainer) {
- CorporateBodyMandateContainer corporateBodyMandateContainer = (CorporateBodyMandateContainer) mandateContainer;
- represented.setELPIdentifier(corporateBodyMandateContainer.getCorpMandatorIdentificationValue());
- represented.setName(corporateBodyMandateContainer.getCorpMandatorFullName());
+ represented.setELPIdentifier(geteLPIdentifier(mandateContainer, sourceAttribute));
+ represented.setName(getLegalName(mandateContainer, sourceAttribute));
represented.setAddress("");
represented.setCanonicalAddress(new CanonicalAddressType());
- represented.setType(mapCompanyType(mandateContainer)); // TODO
+ represented.setType(getCompanyType(mandateContainer, sourceAttribute));
} else if (mandateContainer instanceof PhyPersonMandateContainer) {
PhyPersonMandateContainer phyPersonMandateContainer = (PhyPersonMandateContainer) mandateContainer;
represented.setEIdentifier(""); // TODO CALCULATE
@@ -394,13 +397,12 @@ public class MandateRetrievalRequest implements IAction {
MandateContentType mandateContent = new MandateContentType();
try {
XMLGregorianCalendar validFrom = DatatypeFactory.newInstance().newXMLGregorianCalendar(mandateContainer.getMandateValidFrom());
-
XMLGregorianCalendar validTo = DatatypeFactory.newInstance().newXMLGregorianCalendar(mandateContainer.getMandateValidTo());
mandateContent.setValidFrom(validFrom);
mandateContent.setValidTo(validTo);
} catch (DatatypeConfigurationException dte) {
- Logger.error("Error converting data from mandate");
- throw new MOAIDException("stork.16", new Object[]{}); // TODO
+ Logger.error("Error converting date from mandate: " + mandateContainer.getMandateValidFrom() + ", " + mandateContainer.getMandateValidTo());
+ throw new MOAIDException("stork.20", new Object[]{});
}
mandateContent.setTransactionLimit(BigInteger.valueOf(0)); // TODO
@@ -413,7 +415,7 @@ public class MandateRetrievalRequest implements IAction {
}
public boolean needAuthentication(IRequest req, HttpServletRequest httpReq, HttpServletResponse httpResp) {
- return true; //
+ return true;
}
public String getDefaultActionName() {
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/STORKProtocol.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/STORKProtocol.java
index ed9c45126..29148daeb 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/STORKProtocol.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/STORKProtocol.java
@@ -9,6 +9,7 @@ import at.gv.egovernment.moa.logging.Logger;
import eu.stork.peps.auth.commons.*;
import eu.stork.peps.auth.engine.STORKSAMLEngine;
import eu.stork.peps.exceptions.STORKSAMLEngineException;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
@@ -26,7 +27,7 @@ public class STORKProtocol implements IModulInfo, MOAIDAuthConstants {
public static final String AUTHENTICATIONREQUEST = "AuthenticationRequest";
public static final String ATTRIBUTE_COLLECTOR = "AttributeCollector";
public static final String MANDATERETRIEVALREQUEST = "MandateRetrievalRequest";
- public static final String CONSENT_EVALUATOR = "ConsentEvaluator";
+ public static final String CONSENT_EVALUATOR = "ConsentEvaluator";
private static HashMap<String, IAction> actions = new HashMap<String, IAction>();
@@ -68,7 +69,7 @@ public class STORKProtocol implements IModulInfo, MOAIDAuthConstants {
if (AttributeCollector.class.getSimpleName().equals(action) || ConsentEvaluator.class.getSimpleName().equals(action))
- return STORK2Request;
+ return STORK2Request;
if (request.getParameter("SAMLResponse") != null) { // TODO check attribute collector
@@ -102,57 +103,66 @@ public class STORKProtocol implements IModulInfo, MOAIDAuthConstants {
return STORK2Response;
- } else if (request.getParameter("SAMLRequest") != null) {
-
- //extract STORK Response from HTTP Request
- byte[] decSamlToken;
- try {
- decSamlToken = PEPSUtil.decodeSAMLToken(request.getParameter("SAMLRequest"));
- } catch (NullPointerException e) {
- if (request.getRemoteHost().contains("129.27.142")) {
- Logger.warn("Availability check by " + request.getRemoteHost() + " on URI: " + request.getRequestURI());
- } else {
- Logger.error("Unable to retrieve STORK Request for host: " + request.getRemoteHost() + " and URI: " + request.getRequestURI(), e);
+ } else if (request.getParameter("SAMLRequest") != null) {
+
+ //extract STORK Response from HTTP Request
+ byte[] decSamlToken;
+ try {
+ decSamlToken = PEPSUtil.decodeSAMLToken(request.getParameter("SAMLRequest"));
+ } catch (NullPointerException e) {
+ if (request.getRemoteHost().contains("129.27.142")) {
+ Logger.warn("Availability check by " + request.getRemoteHost() + " on URI: " + request.getRequestURI());
+ } else {
+ Logger.error("Unable to retrieve STORK Request for host: " + request.getRemoteHost() + " and URI: " + request.getRequestURI(), e);
+ }
+ throw new MOAIDException("stork.04", null);
}
- throw new MOAIDException("stork.04", null);
- }
- //Get SAMLEngine instance
- STORKSAMLEngine engine = STORKSAMLEngine.getInstance("VIDP");
-
- STORKAuthnRequest authnRequest = null;
- STORKAttrQueryRequest attrRequest = null;
-
-
- // check if valid authn request is contained
- try {
- authnRequest = engine.validateSTORKAuthnRequest(decSamlToken);
- } catch (STORKSAMLEngineException ex) {
- Logger.error("Unable to validate Stork AuthenticationRequest: " + ex.getMessage());
- } catch(ClassCastException e) {
- // we do not have a authnRequest
- // check if a valid attr request is container
- try {
- attrRequest = engine.validateSTORKAttrQueryRequest(decSamlToken);
- } catch (STORKSAMLEngineException ex) {
- Logger.error("Unable to validate Stork AuthenticationRequest: " + ex.getMessage());
- }
- }
+ //Get SAMLEngine instance
+ STORKSAMLEngine engine = STORKSAMLEngine.getInstance("VIDP");
- // if there is no authn or attr request, raise error
- if ((authnRequest == null) && (attrRequest == null)) {
- Logger.error("There is no authentication or attribute request contained.");
- throw new MOAIDException("stork.14", null);
- }
+ STORKAuthnRequest authnRequest = null;
+ STORKAttrQueryRequest attrRequest = null;
- STORK2Request.setSTORKAuthnRequest(authnRequest);
- STORK2Request.setSTORKAttrRequest(attrRequest);
-
- return STORK2Request;
+ // check if valid authn request is contained
+ try {
+ authnRequest = engine.validateSTORKAuthnRequest(decSamlToken);
+ } catch (STORKSAMLEngineException ex) {
+ Logger.error("Unable to validate Stork AuthenticationRequest: " + ex.getMessage());
+ } catch (ClassCastException e) {
+ // we do not have a authnRequest
+ // check if a valid attr request is container
+ try {
+ attrRequest = engine.validateSTORKAttrQueryRequest(decSamlToken);
+ } catch (STORKSAMLEngineException ex) {
+ Logger.error("Unable to validate Stork AuthenticationRequest: " + ex.getMessage());
+ }
+ }
+
+ // if there is no authn or attr request, raise error
+ if ((authnRequest == null) && (attrRequest == null)) {
+ Logger.error("There is no authentication or attribute request contained.");
+ throw new MOAIDException("stork.14", null);
+ }
+ // list attributes in the request
+ try {
+ for (PersonalAttribute personalAttribute : authnRequest.getPersonalAttributeList()) {
+ Logger.debug("Personal attribute found in request: " + personalAttribute.getName() + " isRequired: " + personalAttribute.isRequired());
+ }
+ } catch (Exception e) {
+ Logger.error("Exception, attributes: " + e.getMessage());
+ }
+
+
+ STORK2Request.setSTORKAuthnRequest(authnRequest);
+ STORK2Request.setSTORKAttrRequest(attrRequest);
+
+
+ return STORK2Request;
} else {
throw new MOAIDException("stork.14", null); // TODO Specify message
- }
+ }
}
public IAction canHandleRequest(HttpServletRequest request, HttpServletResponse response) {
diff --git a/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties b/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties
index 0f9792e79..0217f7af3 100644
--- a/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties
+++ b/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties
@@ -223,6 +223,8 @@ stork.15=Unbekannte request.
stork.16=Ein Attribute aus zwei verschiedenen Quellen unterscheidet sich\: {0}
stork.17=Fehler beim Einholen der Zustimmung f\uFFFDr Attribut\u00FCbertragung durch den Benutzer
stork.18=STORK-SAML Engine konnte nicht initialisiert werden.
+stork.19=Das erforderliche Attribut ist für naturliche Personen nicht vorhanden\: {0}
+stork.20=Fehler bei der Datenkonversion - eingegebens Datum fehlerhaft
pvp2.00={0} ist kein gueltiger consumer service index
pvp2.01=Fehler beim kodieren der PVP2 Antwort
diff --git a/id/server/idserverlib/src/main/resources/resources/properties/protocol_response_statuscodes_de.properties b/id/server/idserverlib/src/main/resources/resources/properties/protocol_response_statuscodes_de.properties
index 2a55ea64c..19696ed86 100644
--- a/id/server/idserverlib/src/main/resources/resources/properties/protocol_response_statuscodes_de.properties
+++ b/id/server/idserverlib/src/main/resources/resources/properties/protocol_response_statuscodes_de.properties
@@ -167,6 +167,8 @@ stork.15=6001
stork.16=1203
stork.17=1203
stork.18=9004
+stork.19=1203
+stork.20=1204
pvp2.01=6100
pvp2.06=6100