/******************************************************************************* * 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.util; import java.util.Iterator; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import org.w3c.dom.Element; import org.w3._2000._09.xmldsig_.*; import at.gv.e_government.reference.namespace.*; import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; import at.gv.e_government.reference.namespace.persondata._20020228_.AbstractPersonType; import at.gv.e_government.reference.namespace.persondata._20020228_.IdentificationType; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.spss.MOAException; import at.gv.egovernment.moa.util.Constants; @SuppressWarnings("unused") public class MandateBuilder { public static final String MANDATE_DATE_OF_BIRTH_FORMAT = "yyyy-MM-dd"; public static Mandate buildMandate(Element mandate) { try { JAXBContext jc = JAXBContext.newInstance("at.gv.e_government.reference.namespace.mandates._20040701_"); Unmarshaller u = jc.createUnmarshaller(); Mandate mand = (Mandate) u.unmarshal(mandate); return mand; } catch (JAXBException e) { Logger.error("Failed to parse Mandate", e); } return null; } public static IdentificationType getWBPKIdentification(AbstractPersonType person) { Iterator typesIt = person.getIdentification().iterator(); while(typesIt.hasNext()) { IdentificationType id = typesIt.next(); if(id.getType().startsWith(Constants.URN_PREFIX_WBPK)) { return id; } } return null; } public static IdentificationType getBPKIdentification(AbstractPersonType person) { Iterator typesIt = person.getIdentification().iterator(); while(typesIt.hasNext()) { IdentificationType id = typesIt.next(); if(id.getType().startsWith(Constants.URN_PREFIX_BPK)) { return id; } } return null; } }