aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateRetrievalRequest.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateRetrievalRequest.java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateRetrievalRequest.java87
1 files changed, 68 insertions, 19 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 baa91a854..ed8480ccb 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
@@ -33,13 +33,16 @@ import at.gv.egovernment.moa.id.data.IAuthData;
import at.gv.egovernment.moa.id.data.SLOInformationInterface;
import at.gv.egovernment.moa.id.moduls.IAction;
import at.gv.egovernment.moa.id.moduls.IRequest;
+import at.gv.egovernment.moa.id.protocols.pvp2x.PVPConstants;
import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.Constants;
import eu.stork.peps.auth.commons.IPersonalAttributeList;
import eu.stork.peps.auth.commons.PersonalAttribute;
import eu.stork.peps.auth.commons.PersonalAttributeList;
import eu.stork.peps.auth.commons.STORKAttrQueryResponse;
-import eu.stork.peps.complex.attributes.*;
+import eu.stork.peps.complex.attributes.eu.stork.names.tc.stork._1_0.assertion.*;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.binary.StringUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -65,12 +68,21 @@ public class MandateRetrievalRequest implements IAction {
private IAuthData authData;
private MOASTORKRequest moaStorkRequest;
private IdentityLink representingIdentityLink;
+ private Integer QAALevel;
+ private byte[] originalContent;
public SLOInformationInterface processRequest(IRequest req, HttpServletRequest httpReq, HttpServletResponse httpResp, IAuthData authData) throws MOAIDException {
Logger.debug("Entering AttributeRequest for MandateProvider");
httpResp.reset();
this.representingIdentityLink = authData.getIdentityLink();
+ this.QAALevel = translateQAALevel(authData.getQAALevel());
+ // preparing original content and removing sensitive data from it
+ this.originalContent = authData.getMISMandate().getMandate(); // TODO ERROR
+ //Logger.debug("Original content " + StringUtils.newStringUtf8(authData.getMISMandate().getMandate()));
+ String originalMandate = StringUtils.newStringUtf8(authData.getMISMandate().getMandate()).replaceAll("<pd:Value>.*?==</pd:Value><pd:Type>urn:publicid:gv.at:baseid</pd:Type>","<pd:Value></pd:Value><pd:Type></pd:Type>");;
+ Logger.debug("Removing personal identification value and type from original mandate ");
+ originalContent = StringUtils.getBytesUtf8(originalMandate);
OAAuthParameter oaParam = AuthConfigurationProvider.getInstance().getOnlineApplicationParameter(req.getOAURL());
if (oaParam == null)
@@ -206,6 +218,18 @@ public class MandateRetrievalRequest implements IAction {
return null;
}
+ private Integer translateQAALevel(String qaaLevel) throws MOAIDException {
+ if (qaaLevel.equals(PVPConstants.STORK_QAA_1_1))
+ return 1;
+ if (qaaLevel.equals(PVPConstants.STORK_QAA_1_2))
+ return 2;
+ if (qaaLevel.equals(PVPConstants.STORK_QAA_1_3))
+ return 3;
+ if (qaaLevel.equals(PVPConstants.STORK_QAA_1_4))
+ return 4;
+ Logger.error("Wrong QAA Number format");
+ throw new MOAIDException("stork.16", new Object[]{});
+ }
private String geteLPIdentifier(MandateContainer mandateContainer, PersonalAttribute currentAttribute) throws MOAIDException {
RepresentationPersonType represented = getRepresented(mandateContainer, currentAttribute);
@@ -213,7 +237,7 @@ public class MandateRetrievalRequest implements IAction {
return represented.getELPIdentifier();
} else if (currentAttribute.isRequired()) {
Logger.error("Cannot provide eLPIdentifier for natural person.");
- throw new MOAIDException("stork.19", new Object[]{currentAttribute.getName()});
+ throw new MOAIDException("stork.19", new Object[]{currentAttribute.getName()}); // TODO
}
return "";
}
@@ -249,14 +273,35 @@ public class MandateRetrievalRequest implements IAction {
private String mapPowersType(MandateContainer mandateContainer) {
+ // using if for java 6 compatibility if necessary
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
+ } else if (mandateContainer.getAnnotation().equals("ERsBMitPostvollmacht")) {
+ return "0"; // General Powers
+ } else if (mandateContainer.getAnnotation().equals("ZVR")) {
+ return "0"; // General Powers
+ } else if (mandateContainer.getAnnotation().equals("ZVRMitPostvollmacht")) {
+ return "0"; // General Powers
+ } else if (mandateContainer.getAnnotation().equals("EVB")) {
+ return "0"; // General Powers
+ } else if (mandateContainer.getAnnotation().equals("Einzelvertretungsbefugnis")) {
+ return "0"; // General Powers
+ } else if (mandateContainer.getAnnotation().equals("Prokura")) {
+ return "0"; // General Powers
+ } else if (mandateContainer.getAnnotation().equals("Notar")) {
+ return "0"; // General Powers
+ } else if (mandateContainer.getAnnotation().equals("Organwalter")) {
+ return "0"; // General Powers
+ } else if (mandateContainer.getAnnotation().equals("Rechtsanwalt")) {
+ return "0"; // General Powers
+ } else if (mandateContainer.getAnnotation().equals("Ziviltechniker")) {
+ return "0"; // General Powers
}
- return "";
+ return "9";
}
private MandateType getMandateType(MandateContainer mandateContainer, PersonalAttribute sourceAttribute) throws MOAIDException {
@@ -264,10 +309,9 @@ public class MandateRetrievalRequest implements IAction {
RepresentationPersonType representative = getRepresentative(mandateContainer, sourceAttribute);
RepresentationPersonType represented = getRepresented(mandateContainer, sourceAttribute);
MandateContentType mandateContent = getMandateContent(mandateContainer, sourceAttribute);
-
- mandateType.setRepresenting(representative);
+ mandateType.setRepresentative(representative);
mandateType.setRepresented(represented);
- mandateType.setMandateContent(mandateContent);
+ mandateType.getMandateContent().add(mandateContent);
Logger.debug("Complex attribute extracted: " + sourceAttribute.getName());
return mandateType;
}
@@ -275,7 +319,8 @@ public class MandateRetrievalRequest implements IAction {
private String getLegalName(MandateContainer mandateContainer, PersonalAttribute sourceAttribute) throws MOAIDException {
RepresentationPersonType represented = getRepresented(mandateContainer, sourceAttribute);
if (mandateContainer instanceof CorporateBodyMandateContainer) {
- return represented.getName();
+ represented.getLegalName();
+ //return represented.getName();
} else if (sourceAttribute.isRequired()) {
Logger.error("Cannot provide legalName for natural person.");
throw new MOAIDException("stork.19", new Object[]{sourceAttribute.getName()});
@@ -487,10 +532,10 @@ public class MandateRetrievalRequest implements IAction {
if (mandateContainer instanceof CorporateBodyMandateContainer) {
CorporateBodyMandateContainer corporateBodyMandateContainer = (CorporateBodyMandateContainer) mandateContainer;
represented.setELPIdentifier(corporateBodyMandateContainer.getCorpMandatorIdentificationValue());
- represented.setName(corporateBodyMandateContainer.getCorpMandatorFullName());
- represented.setAddress("");
- represented.setCanonicalAddress(new CanonicalAddressType());
- represented.setType(getCompanyType(corporateBodyMandateContainer.corpMandatorFullName, corporateBodyMandateContainer.corpMandatorIdentificationType, sourceAttribute));
+ represented.setLegalName(corporateBodyMandateContainer.getCorpMandatorFullName());
+ represented.setTextRegisteredAddress(null);
+ represented.setCanonicalRegisteredAddress(new CanonicalAddressType());
+ represented.setLegalForm(getCompanyType(corporateBodyMandateContainer.corpMandatorFullName, corporateBodyMandateContainer.corpMandatorIdentificationType, sourceAttribute));
} else if (mandateContainer instanceof PhyPersonMandateContainer) {
PhyPersonMandateContainer phyPersonMandateContainer = (PhyPersonMandateContainer) mandateContainer;
represented.setEIdentifier(getRepresentedStorkeIdentifier(mandateContainer));
@@ -510,18 +555,22 @@ public class MandateRetrievalRequest implements IAction {
try {
XMLGregorianCalendar validFrom = DatatypeFactory.newInstance().newXMLGregorianCalendar(mandateContainer.getMandateValidFrom());
XMLGregorianCalendar validTo = DatatypeFactory.newInstance().newXMLGregorianCalendar(mandateContainer.getMandateValidTo());
- mandateContent.setValidFrom(validFrom);
- mandateContent.setValidTo(validTo);
+ TimeRestrictionType timeRestriction = new TimeRestrictionType();
+ timeRestriction.setValidFrom(validFrom);
+ timeRestriction.setValidTo(validTo);
+ mandateContent.setTimeRestriction(timeRestriction);
} catch (DatatypeConfigurationException dte) {
Logger.error("Error converting date from mandate: " + mandateContainer.getMandateValidFrom() + ", " + mandateContainer.getMandateValidTo());
throw new MOAIDException("stork.20", new Object[]{});
}
-
- mandateContent.setTransactionLimit(BigInteger.valueOf(0)); // TODO
- mandateContent.setTransactionLimitCurrency("");// TODO
- mandateContent.setIsJoint("0");
- mandateContent.setIschained(false);
- mandateContent.setTypePower(mapPowersType(mandateContainer));
+ mandateContent.setAQAA(this.QAALevel);
+ mandateContent.setOriginalMandate(originalContent);
+ mandateContent.setOriginalMandateType("application/xml");
+ TransactionLimitRestrictionType transactionLimit = new TransactionLimitRestrictionType();
+ mandateContent.setTransactionLimit(transactionLimit);
+ mandateContent.setIsJoint("");
+ mandateContent.setIsChained(false);
+ mandateContent.setTypeOfPower(mapPowersType(mandateContainer)); // TODO check
Logger.debug("Complex attribute extracted: " + sourceAttribute.getName());
return mandateContent;
}