/******************************************************************************* * Copyright 2014 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.protocols.stork2; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.logging.Logger; 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 prefMap = new HashMap() {{ 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; } }