diff options
Diffstat (limited to 'id/server/idserverlib/src/main')
3 files changed, 136 insertions, 111 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 eb0f2975c..b358436ae 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 @@ -97,7 +97,7 @@ public class CorporateBodyMandateContainer extends MandateContainer { } public void setCorpMandatorIdentificationValue(String corpMandatorIdentificationValue) { - this.corpMandatorIdentificationValue = corpMandatorIdentificationValue; + this.corpMandatorIdentificationValue = "AT/" + corpMandatorIdentificationValue; } public String getCorpMandatorIdentificationType() { 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 249378ffb..139c438f9 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 @@ -82,142 +82,134 @@ public class MandateRetrievalRequest implements IAction { if ((req instanceof MOASTORKRequest)) { this.moaStorkRequest = (MOASTORKRequest) req; - } else { - return null; // TODO + Logger.error("Internal error - did not receive MOASTORKRequest as expected"); + throw new MOAIDException("stork.16", new Object[]{}); // TODO } - if (moaStorkRequest.isAttrRequest() && moaStorkRequest.getStorkAttrQueryRequest() != null) { - MandateContainer mandateContainer = null; - - try { - mandateContainer = new CorporateBodyMandateContainer(new String(authData.getMISMandate().getMandate(), "UTF-8")); - } catch (Exception ex) { - try { - mandateContainer = new PhyPersonMandateContainer(new String(authData.getMISMandate().getMandate(), "UTF-8")); - } catch (Exception ex2) { - Logger.error("Could not extract data and create mandate container."); - throw new MOAIDException("stork.16", new Object[]{}); // TODO - } - } - - if (mandateContainer instanceof CorporateBodyMandateContainer) { + if (!(moaStorkRequest.isAttrRequest() || moaStorkRequest.getStorkAttrQueryRequest() == null)) { + Logger.error("Did not receive attribute request as expected"); + throw new MOAIDException("stork.16", new Object[]{}); // TODO + } - } else if (mandateContainer instanceof PhyPersonMandateContainer) { + MandateContainer mandateContainer = null; + try { + mandateContainer = new CorporateBodyMandateContainer(new String(authData.getMISMandate().getMandate(), "UTF-8")); + } catch (Exception ex) { + try { + mandateContainer = new PhyPersonMandateContainer(new String(authData.getMISMandate().getMandate(), "UTF-8")); + } catch (Exception ex2) { + Logger.error("Could not extract data and create mandate container."); + throw new MOAIDException("stork.16", new Object[]{}); // TODO } + } - -// moaStorkResponse.setPersonalAttributeList(populateAttributes()); - - //moaStorkResponse.setCountry(moaStorkRequest.getSpCountry()); - - IPersonalAttributeList sourceAttributeList = moaStorkRequest.getStorkAttrQueryRequest().getPersonalAttributeList(); - - IPersonalAttributeList attributeList = new PersonalAttributeList(); - - for (PersonalAttribute currentAttribute : sourceAttributeList) { - Logger.debug("Evaluating currentattribute " + currentAttribute.getName()); - if (currentAttribute.getName().equals("mandateContent")) { - MandateContentType mandateContent = getMandateContent(mandateContainer, currentAttribute); - attributeList.add(marshallComplexAttribute(currentAttribute, mandateContent)); - } else if (currentAttribute.getName().equals("representative")) { // TODO CHECK IN DETAIL - RepresentationPersonType representative = getRepresentative(mandateContainer, currentAttribute); - attributeList.add(marshallComplexAttribute(currentAttribute, representative)); - - //attributeList.add(getRepresentative(mandateContainer, currentAttribute)); - } else if (currentAttribute.getName().equals("represented")) { - //attributeList.add(getRepresented(mandateContainer, currentAttribute)); - RepresentationPersonType represented = getRepresented(mandateContainer, currentAttribute); - attributeList.add(marshallComplexAttribute(currentAttribute, represented)); - - } else if (currentAttribute.getName().equals("mandate")) { - //attributeList.add(getMandateType(mandateContainer, currentAttribute)); - MandateType mandateType = getMandateType(mandateContainer, currentAttribute); - attributeList.add(marshallComplexAttribute(currentAttribute, mandateType)); - - } else if (currentAttribute.getName().equals("legalName")) { - String legalName = getLegalName(mandateContainer, currentAttribute); - if (legalName.length() > 0) { - attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(legalName), AttributeStatusType.AVAILABLE.value())); - } else { - attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(legalName), AttributeStatusType.NOT_AVAILABLE.value())); - } - } else if (currentAttribute.getName().equals("eLPIdentifier")) { - String eLPIdentifier = geteLPIdentifier(mandateContainer, currentAttribute); - if (eLPIdentifier.length() > 0) { - attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(eLPIdentifier), AttributeStatusType.AVAILABLE.value())); - } else { - attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(eLPIdentifier), AttributeStatusType.NOT_AVAILABLE.value())); - } - } else if (currentAttribute.getName().equals("type")) { - String type = getCompanyType(mandateContainer, currentAttribute); - if (type.length() > 0) { - attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(type), AttributeStatusType.AVAILABLE.value())); - } else { - attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(type), AttributeStatusType.NOT_AVAILABLE.value())); - } - } else if (currentAttribute.getName().equals("status")) { - String status = getCompanyStatus(mandateContainer, currentAttribute); - if (status.length() > 0) { - attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(status), AttributeStatusType.AVAILABLE.value())); - } else { - attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(status), AttributeStatusType.NOT_AVAILABLE.value())); - } - } else if (currentAttribute.getName().equals("translatableType")) { - String translatableType = getCompanyTranslatableType(mandateContainer, currentAttribute); - if (translatableType.length() > 0) { - attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(translatableType), AttributeStatusType.AVAILABLE.value())); - } else { - attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(translatableType), AttributeStatusType.NOT_AVAILABLE.value())); - } + IPersonalAttributeList sourceAttributeList = moaStorkRequest.getStorkAttrQueryRequest().getPersonalAttributeList(); + + IPersonalAttributeList attributeList = new PersonalAttributeList(); + + for (PersonalAttribute currentAttribute : sourceAttributeList) { + Logger.debug("Evaluating currentattribute " + currentAttribute.getName()); + if (currentAttribute.getName().equals("mandateContent")) { + MandateContentType mandateContent = getMandateContent(mandateContainer, currentAttribute); + attributeList.add(marshallComplexAttribute(currentAttribute, mandateContent)); + } else if (currentAttribute.getName().equals("representative")) { // TODO CHECK IN DETAIL + RepresentationPersonType representative = getRepresentative(mandateContainer, currentAttribute); + attributeList.add(marshallComplexAttribute(currentAttribute, representative)); + + //attributeList.add(getRepresentative(mandateContainer, currentAttribute)); + } else if (currentAttribute.getName().equals("represented")) { + //attributeList.add(getRepresented(mandateContainer, currentAttribute)); + RepresentationPersonType represented = getRepresented(mandateContainer, currentAttribute); + attributeList.add(marshallComplexAttribute(currentAttribute, represented)); + + } else if (currentAttribute.getName().equals("mandate")) { + //attributeList.add(getMandateType(mandateContainer, currentAttribute)); + MandateType mandateType = getMandateType(mandateContainer, currentAttribute); + attributeList.add(marshallComplexAttribute(currentAttribute, mandateType)); + + } else if (currentAttribute.getName().equals("legalName")) { + String legalName = getLegalName(mandateContainer, currentAttribute); + if (legalName.length() > 0) { + attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(legalName), AttributeStatusType.AVAILABLE.value())); + } else { + attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(legalName), AttributeStatusType.NOT_AVAILABLE.value())); + } + } else if (currentAttribute.getName().equals("eLPIdentifier")) { + String eLPIdentifier = geteLPIdentifier(mandateContainer, currentAttribute); + if (eLPIdentifier.length() > 0) { + attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(eLPIdentifier), AttributeStatusType.AVAILABLE.value())); + } else { + attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(eLPIdentifier), AttributeStatusType.NOT_AVAILABLE.value())); + } + } else if (currentAttribute.getName().equals("type")) { + String type = getCompanyType(mandateContainer, currentAttribute); + if (type.length() > 0) { + attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(type), AttributeStatusType.AVAILABLE.value())); + } else { + attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(type), AttributeStatusType.NOT_AVAILABLE.value())); + } + } else if (currentAttribute.getName().equals("status")) { + String status = getCompanyStatus(mandateContainer, currentAttribute); + if (status.length() > 0) { + attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(status), AttributeStatusType.AVAILABLE.value())); + } else { + attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(status), AttributeStatusType.NOT_AVAILABLE.value())); + } + } else if (currentAttribute.getName().equals("translatableType")) { + String translatableType = getCompanyTranslatableType(mandateContainer, currentAttribute); + if (translatableType.length() > 0) { + attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(translatableType), AttributeStatusType.AVAILABLE.value())); + } else { + attributeList.add(new PersonalAttribute(currentAttribute.getName(), currentAttribute.isRequired(), Arrays.asList(translatableType), AttributeStatusType.NOT_AVAILABLE.value())); } - } + } + // if (attrResponse.getPersonalAttributeList().size() == 0) { // Logger.error("AttributeList empty - could not retrieve attributes"); // throw new MOAIDException("stork.16", new Object[]{}); // TODO MESSAGE // } - attrResponse.setPersonalAttributeList(attributeList); - moaStorkResponse.setSTORKAttrResponse(attrResponse); + attrResponse.setPersonalAttributeList(attributeList); + moaStorkResponse.setSTORKAttrResponse(attrResponse); - Logger.debug("Attributes retrieved: " + moaStorkResponse.getStorkAttrQueryResponse().getPersonalAttributeList().size()); + Logger.debug("Attributes retrieved: " + moaStorkResponse.getStorkAttrQueryResponse().getPersonalAttributeList().size() + " for SP country " + attrResponse.getCountry()); - // Prepare extended attributes - Logger.debug("Preparing data container"); + // Prepare extended attributes + Logger.debug("Preparing data container"); - // create fresh container - DataContainer container = new DataContainer(); + // create fresh container + DataContainer container = new DataContainer(); - // - fill in the request we extracted above - container.setRequest(moaStorkRequest); + // - fill in the request we extracted above + container.setRequest(moaStorkRequest); - // - fill in the partial response created above - container.setResponse(moaStorkResponse); + // - fill in the partial response created above + container.setResponse(moaStorkResponse); - container.setRemoteAddress(httpReq.getRemoteAddr()); + container.setRemoteAddress(httpReq.getRemoteAddr()); - Logger.debug("Data container prepared"); + Logger.debug("Data container prepared"); - // ask for consent if necessary - if (oaParam.isRequireConsentForStorkAttributes()) - new ConsentEvaluator().requestConsent(container, httpResp, oaParam); - else - new ConsentEvaluator().generateSTORKResponse(httpResp, container); - } + // ask for consent if necessary + if (oaParam.isRequireConsentForStorkAttributes()) + new ConsentEvaluator().requestConsent(container, httpResp, oaParam); + else + new ConsentEvaluator().generateSTORKResponse(httpResp, container); - - return null; // + return null; } + private String geteLPIdentifier(MandateContainer mandateContainer, PersonalAttribute currentAttribute) throws MOAIDException { RepresentationPersonType represented = getRepresented(mandateContainer, currentAttribute); if (mandateContainer instanceof CorporateBodyMandateContainer) { - return "AT/".concat(represented.getELPIdentifier()); + return represented.getELPIdentifier(); } else if (currentAttribute.isRequired()) { Logger.error("Cannot provide eLPIdentifier for natural person."); throw new MOAIDException("stork.19", new Object[]{currentAttribute.getName()}); @@ -406,8 +398,38 @@ public class MandateRetrievalRequest implements IAction { } - private String getRepresentedStorkeIdentifier(String identificationType, String identificationValue) { + private String getRepresentedStorkeIdentifier(MandateContainer mandateContainer) throws MOAIDException { + + //String identificationType, String identificationValue + if (!(mandateContainer instanceof PhyPersonMandateContainer)) { + Logger.error("Physical person mandate container missing"); + throw new MOAIDException("stork.20", new Object[]{}); // TODO + } + PhyPersonMandateContainer phyPersonMandateContainer = (PhyPersonMandateContainer) mandateContainer; + + if (!phyPersonMandateContainer.getPhyPersMandatorIdentificationType().equals(Constants.URN_PREFIX_BASEID)) { + Logger.error("Identification type of represented person from MIS is not correct"); + throw new MOAIDException("stork.20", new Object[]{}); // TODO + } + + if (phyPersonMandateContainer.getPhyPersMandatorIdentificationValue().length() != 24) { + Logger.error("Identification value of represented person from MIS is not correct"); + throw new MOAIDException("stork.20", new Object[]{}); // TODO + } + + if ((this.moaStorkRequest.getStorkAttrQueryRequest().getSpCountry() == null) || (this.moaStorkRequest.getStorkAttrQueryRequest().getSpCountry().length() == 0)) { + Logger.error("Error accessing SP country code"); + throw new MOAIDException("stork.20", new Object[]{}); // TODO + } + + BPKBuilder bpkBuilder = new BPKBuilder(); + try { + return bpkBuilder.buildStorkeIdentifier(phyPersonMandateContainer.getPhyPersMandatorIdentificationType(), phyPersonMandateContainer.getPhyPersMandatorIdentificationValue(), this.moaStorkRequest.getStorkAttrQueryRequest().getSpCountry()); + } catch (BuildException be) { + Logger.error("Could not build STORK eIdentifier while generating mandate assertion."); + throw new MOAIDException("stork.20", new Object[]{}); // TODO + } } private String getRepresentingStorkeIdentifier(MandateContainer mandateContainer) throws MOAIDException { @@ -462,14 +484,14 @@ public class MandateRetrievalRequest implements IAction { if (mandateContainer instanceof CorporateBodyMandateContainer) { CorporateBodyMandateContainer corporateBodyMandateContainer = (CorporateBodyMandateContainer) mandateContainer; - represented.setELPIdentifier("AT/" + corporateBodyMandateContainer.getCorpMandatorIdentificationValue()); + represented.setELPIdentifier(corporateBodyMandateContainer.getCorpMandatorIdentificationValue()); represented.setName(corporateBodyMandateContainer.getCorpMandatorFullName()); represented.setAddress(""); represented.setCanonicalAddress(new CanonicalAddressType()); represented.setType(getCompanyType(corporateBodyMandateContainer.corpMandatorFullName, corporateBodyMandateContainer.corpMandatorIdentificationType, sourceAttribute)); } else if (mandateContainer instanceof PhyPersonMandateContainer) { PhyPersonMandateContainer phyPersonMandateContainer = (PhyPersonMandateContainer) mandateContainer; - represented.setEIdentifier(""); // TODO CALCULATE + represented.setEIdentifier(getRepresentedStorkeIdentifier(mandateContainer)); // TODO CALCULATE represented.setGivenName(phyPersonMandateContainer.getPhyPersMandatorGivenName()); represented.setSurname(phyPersonMandateContainer.getPhyPersMandatorFamilyName()); represented.setDateOfBirth(phyPersonMandateContainer.getPhyPersMandatorBirthDate()); @@ -495,7 +517,7 @@ public class MandateRetrievalRequest implements IAction { mandateContent.setTransactionLimit(BigInteger.valueOf(0)); // TODO mandateContent.setTransactionLimitCurrency("");// TODO - mandateContent.setIsJoint(""); + mandateContent.setIsJoint("0"); mandateContent.setIschained(false); mandateContent.setTypePower(mapPowersType(mandateContainer)); Logger.debug("Complex attribute extracted: " + sourceAttribute.getName()); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/attributeproviders/MandateAttributeRequestProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/attributeproviders/MandateAttributeRequestProvider.java index 6b3cff444..cd9042342 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/attributeproviders/MandateAttributeRequestProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/attributeproviders/MandateAttributeRequestProvider.java @@ -141,8 +141,11 @@ public class MandateAttributeRequestProvider extends AttributeProvider { attributeRequest.setPersonalAttributeList(requestedAttributes); attributeRequest.setCitizenCountryCode("AT"); - attributeRequest.setQaa(4); + attributeRequest.setQaa(oaParam.getQaaLevel()); + if (attributeRequest.getQaa() == 0 ) { + attributeRequest.setQaa(4); // workaround + } |