aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/client/szrgw/CreateMandateRequest.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/client/szrgw/CreateMandateRequest.java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/client/szrgw/CreateMandateRequest.java281
1 files changed, 0 insertions, 281 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/client/szrgw/CreateMandateRequest.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/client/szrgw/CreateMandateRequest.java
deleted file mode 100644
index 53f786eb3..000000000
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/validator/parep/client/szrgw/CreateMandateRequest.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright 2003 Federal Chancellery Austria
- * MOA-ID has been developed in a cooperation between BRZ, the Federal
- * Chancellery Austria - ICT staff unit, and Graz University of Technology.
- *
- * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
- * the European Commission - subsequent versions of the EUPL (the "Licence");
- * You may not use this work except in compliance with the Licence.
- * You may obtain a copy of the Licence at:
- * http://www.osor.eu/eupl/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the Licence is distributed on an "AS IS" basis,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the Licence for the specific language governing permissions and
- * limitations under the Licence.
- *
- * This product combines work with different licenses. See the "NOTICE" text
- * file for details on the various modules and licenses.
- * The "NOTICE" text file is part of the distribution. Any derivative works
- * that you distribute must include a readable copy of the "NOTICE" text file.
- */
-
-
-package at.gv.egovernment.moa.id.auth.validator.parep.client.szrgw;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.xpath.XPathAPI;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import at.gv.egovernment.moa.id.auth.data.InfoboxValidatorParams;
-import at.gv.egovernment.moa.id.auth.validator.parep.ParepUtils;
-import at.gv.egovernment.moa.util.Constants;
-
-/**
- * This class implements a detailed CreateMandateRequest that
- * will be sent to SZR-gateway.
- *
- * @author <a href="mailto:peter.danner@egiz.gv.at">Peter Danner</a>
- */
-public class CreateMandateRequest {
-
- /**
- * The Request.
- */
- private Document document;
-
- /**
- * List of mandate representatives as XML element.
- */
- private List representatives;
-
- /**
- * The mandator.
- */
- private Element mandator;
-
- /**
- * The representative.
- */
- private Element representative;
-
- /**
- * The signature to verify by the SZR-gateway
- */
- private Element signature;
-
-
-
- /**
- * Creates the CreateMandateRequest element that will
- * be sent to SZR-gateway
- *
- * @return the CreateMandateRequest element.
- */
- public Element toElement() throws SZRGWClientException{
-
- this.document = ParepUtils.createEmptyDocument();
- Element root = this.document.createElement(SZRGWConstants.SZRGW_PREFIX + SZRGWConstants.CREATE_MANDATE_REQUEST);
- root.setAttribute("xmlns" + SZRGWConstants.SZRGW_POSTFIX, SZRGWConstants.SZRGW_REQUEST_NS);
- root.setAttribute("xmlns" + SZRGWConstants.PD_POSTFIX, Constants.PD_NS_URI);
- if (this.representative!=null) root.appendChild(this.document.importNode(this.representative, true));
- if (this.mandator!=null) root.appendChild(this.document.importNode(this.mandator, true));
- if (this.signature!=null) root.appendChild(this.document.importNode(this.signature, true));
-
- return root;
- }
-
- /**
- * Adds a representative.
- *
- * @param representative an XML representative to add.
- */
- public void addRepresentative(Element representative) {
- if (representatives == null) {
- representatives = new ArrayList();
- }
- representatives.add(representative);
- }
-
- /**
- * Gets the representative.
- *
- * @return the representative.
- */
- public Element getRepresentative() {
- return representative;
- }
-
- /**
- * Gets the mandator.
- *
- * @return the mandator.
- */
- public Element getMandator() {
- return mandator;
- }
-
- /**
- * Sets the mandator.
- *
- * @param mandator the mandator.
- */
- public void setMandator(Element mandator) {
- this.mandator = mandator;
- }
-
- /**
- * Sets the Mandator.
- *
- * @param familyName the family name of the mandator.
- */
- public void setMandator(String familyName, String givenName, String dateOfBirth,
- String postalCode, String municipality, String streetName, String buildingNumber, String unit,
- boolean physical, String cbFullName, String cbIdentificationType, String cbIdentificationValue) throws SZRGWClientException {
-
- Document mandatorDocument = ParepUtils.createEmptyDocument();
-
- Element mandatorElem = mandatorDocument.createElementNS(SZRGWConstants.SZRGW_REQUEST_NS, SZRGWConstants.SZRGW_PREFIX + SZRGWConstants.MANDATOR);
-// mandatorElem.setAttribute("xmlns" + SZRGWConstants.PD_POSTFIX, Constants.PD_NS_URI);
-/// mandatorElem.setAttribute("xmlns" + SZRGWConstants.SZRGW_POSTFIX, SZRGWConstants.SZRGW_REQUEST_NS);
-
- if (physical) {
- Element physicalPersonElem = mandatorDocument.createElementNS(Constants.PD_NS_URI, SZRGWConstants.PD_PREFIX + SZRGWConstants.PHYSICALPERSON);
- physicalPersonElem.appendChild(createNameElem(mandatorDocument, givenName, familyName));
- physicalPersonElem.appendChild(createPersonDataElem(mandatorDocument, SZRGWConstants.DATEOFBIRTH, dateOfBirth));
- mandatorElem.appendChild(physicalPersonElem);
- Element postalAddressElement = createPostalAddressElem(mandatorDocument, postalCode, municipality, streetName, buildingNumber, unit);
- if (null!=postalAddressElement) mandatorElem.appendChild(postalAddressElement);
- } else {
- Element corporateBodyElem = mandatorDocument.createElementNS(Constants.PD_NS_URI, SZRGWConstants.PD_PREFIX + SZRGWConstants.CORPORATEBODY);
- corporateBodyElem.appendChild(createIdentificationElem(mandatorDocument, cbIdentificationType, cbIdentificationValue));
- corporateBodyElem.appendChild(createPersonDataElem(mandatorDocument, SZRGWConstants.FULLNAME, cbFullName));
- mandatorElem.appendChild(corporateBodyElem);
- }
-
-
- this.mandator = mandatorElem;
- }
-
- private Element createPersonDataElem(Document document, String elementName, String elementValue) {
- Element elem = document.createElementNS(Constants.PD_NS_URI, SZRGWConstants.PD_PREFIX + elementName);
- Node value = document.createTextNode(elementValue);
- elem.appendChild(value);
- return elem;
- }
-
- private Element createIdentificationElem(Document document, String identificationType, String identificationValue) {
- Element identificationElem = document.createElementNS(Constants.PD_NS_URI, SZRGWConstants.PD_PREFIX + SZRGWConstants.IDENTIFICATION);
- identificationElem.appendChild(createPersonDataElem(document, SZRGWConstants.VALUE, identificationValue));
- identificationElem.appendChild(createPersonDataElem(document, SZRGWConstants.TYPE, identificationType));
- return identificationElem;
- }
- private Element createNameElem(Document document, String givenName, String familyName) {
- Element nameElem = document.createElementNS(Constants.PD_NS_URI, SZRGWConstants.PD_PREFIX + SZRGWConstants.NAME);
- nameElem.appendChild(createPersonDataElem(document, SZRGWConstants.GIVENNAME, givenName));
- nameElem.appendChild(createPersonDataElem(document, SZRGWConstants.FAMILYNAME, familyName));
- return nameElem;
- }
- private Element createPostalAddressElem(Document document, String postalCode, String municipality, String streetName, String buildingNumber, String unit) {
-
- if (ParepUtils.isEmpty(postalCode) && ParepUtils.isEmpty(municipality) && ParepUtils.isEmpty(streetName)
- && ParepUtils.isEmpty(buildingNumber) && ParepUtils.isEmpty(unit)) return null;
- Element postalAddressElem = document.createElementNS(Constants.PD_NS_URI, SZRGWConstants.PD_PREFIX + SZRGWConstants.POSTALADDRESS);
-
- if (!ParepUtils.isEmpty(postalCode)) {
- postalAddressElem.appendChild(createPersonDataElem(document, SZRGWConstants.POSTALCODE, postalCode));
- }
- if (!ParepUtils.isEmpty(municipality)) {
- postalAddressElem.appendChild(createPersonDataElem(document, SZRGWConstants.MUNICIPALITY, municipality));
- }
- if (!ParepUtils.isEmpty(streetName) || !ParepUtils.isEmpty(buildingNumber) || !ParepUtils.isEmpty(unit)) {
- Element deliveryAddressElem = document.createElementNS(Constants.PD_NS_URI, SZRGWConstants.PD_PREFIX + SZRGWConstants.DELIVERYADDRESS);
-
- if (!ParepUtils.isEmpty(streetName)) {
- deliveryAddressElem.appendChild(createPersonDataElem(document, SZRGWConstants.STREETNAME, streetName));
- }
- if (!ParepUtils.isEmpty(buildingNumber)) {
- deliveryAddressElem.appendChild(createPersonDataElem(document, SZRGWConstants.BUILDINGNUMBER, buildingNumber));
- }
- if (!ParepUtils.isEmpty(unit)) {
- deliveryAddressElem.appendChild(createPersonDataElem(document, SZRGWConstants.UNIT, unit));
- }
- postalAddressElem.appendChild(deliveryAddressElem);
- }
- return postalAddressElem;
- }
-
-
-
- /**
- * Sets the Representative.
- *
- * @param params InfoboxValidatorParams contain the data of the representative.
- * @param identificationType the type of the identification of the representative (has to be urn:publicid:gv.at:cdid).
- * @param identificationValue the identification value (bPK).
- */
- public void setRepresentative(InfoboxValidatorParams params, String identificationType, String identificationValue) throws SZRGWClientException {
-
- Document representativeDocument = ParepUtils.createEmptyDocument();
-
- Element representativeElem = representativeDocument.createElementNS(SZRGWConstants.SZRGW_REQUEST_NS, SZRGWConstants.SZRGW_PREFIX + SZRGWConstants.REPRESENTATIVE);
-// representativeElem.setAttribute("xmlns" + SZRGWConstants.PD_POSTFIX, Constants.PD_NS_URI);
-// representativeElem.setAttribute("xmlns" + SZRGWConstants.SZRGW_POSTFIX, SZRGWConstants.SZRGW_REQUEST_NS);
-
- //Old Version 0.0.1 of SZR-Gateway
-// representativeElem.appendChild(createIdentificationElem(representativeDocument, identificationType, identificationValue));
-// representativeElem.appendChild(createNameElem(representativeDocument, params.getGivenName(), params.getFamilyName()));
-// representativeElem.appendChild(createPersonDataElem(representativeDocument, SZRGWConstants.DATEOFBIRTH, params.getDateOfBirth()));
-
- //New since version 0.0.2 of SZR-Gateway:
- // we need to send an identity link and must replace its identification value
- representativeElem.appendChild(representativeElem.getOwnerDocument().importNode(params.getIdentityLink(), true));
- try {
- Element nameSpaceNode = representativeElem.getOwnerDocument().createElement("NameSpaceNode");
- nameSpaceNode.setAttribute("xmlns" + SZRGWConstants.PD_POSTFIX, Constants.PD_NS_URI);
- nameSpaceNode.setAttribute("xmlns" + SZRGWConstants.SAML_POSTFIX, Constants.SAML_NS_URI);
- nameSpaceNode.setAttribute("xmlns" + SZRGWConstants.SZRGW_POSTFIX, SZRGWConstants.SZRGW_REQUEST_NS);
- Node identificationValueNode = XPathAPI.selectSingleNode(representativeElem, "descendant-or-self::" + SZRGWConstants.SZRGW_PREFIX + SZRGWConstants.REPRESENTATIVE + "/" +SZRGWConstants.SAML_PREFIX + "Assertion/saml:AttributeStatement/saml:Subject/saml:SubjectConfirmation/saml:SubjectConfirmationData/pr:Person/pr:Identification/pr:Value/text()", nameSpaceNode);
- if (identificationValueNode != null) {
- identificationValueNode.setNodeValue(identificationValue);
- } else {
- throw new SZRGWClientException("validator.63", null);
- }
- Node identificationTypeNode = XPathAPI.selectSingleNode(representativeElem, "descendant-or-self::" + SZRGWConstants.SZRGW_PREFIX + SZRGWConstants.REPRESENTATIVE + "/" +SZRGWConstants.SAML_PREFIX + "Assertion/saml:AttributeStatement/saml:Subject/saml:SubjectConfirmation/saml:SubjectConfirmationData/pr:Person/pr:Identification/pr:Type/text()", nameSpaceNode);
- if (identificationTypeNode != null) {
- identificationTypeNode.setNodeValue(identificationType);
- } else {
- throw new SZRGWClientException("validator.63", null);
- }
- } catch (Exception e) {
- throw new SZRGWClientException("validator.63", null);
- }
- this.representative = representativeElem;
- }
-
- /**
- * @return the signature
- */
- public Element getSignature() {
- return signature;
- }
-
- /**
- * @param signature the signature to set
- */
- public void setSignature(Element signature) throws SZRGWClientException{
- Document signatureDocument = ParepUtils.createEmptyDocument();
- Element signatureElem = signatureDocument.createElementNS(SZRGWConstants.SZRGW_REQUEST_NS, SZRGWConstants.SZRGW_PREFIX + "Signature");
- //SZR-gateway takes the first Signature
- //signatureElem.setAttribute("SignatureLocation", "//saml:Assertion/dsig:Signature");
- signatureElem.appendChild(signatureDocument.importNode(signature, true));
- this.signature = signatureElem;
- }
-
-
-}