package test.tlenz; import java.io.FileInputStream; import java.util.HashMap; import java.util.List; import org.apache.commons.io.IOUtils; import org.w3c.dom.NodeList; import at.gv.egovernment.moa.spss.api.SPSSFactory; import at.gv.egovernment.moa.spss.api.SignatureVerificationService; import at.gv.egovernment.moa.spss.api.common.Content; import at.gv.egovernment.moa.spss.api.common.ContentBinary; import at.gv.egovernment.moa.spss.api.common.ContentXML; import at.gv.egovernment.moa.spss.api.common.InputData; import at.gv.egovernment.moa.spss.api.common.SignerInfo; import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureInfo; import at.gv.egovernment.moa.spss.api.xmlverify.VerifySignatureLocation; import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureRequest; import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse; /******************************************************************************* * 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 test.tlenz; // //import java.io.File; //import java.io.FileInputStream; //import java.io.FileNotFoundException; //import java.io.IOException; //import java.util.Date; //import java.util.Properties; // //import org.hibernate.cfg.Configuration; // //import at.gv.egovernment.moa.id.commons.db.HibernateUtil; //import at.gv.egovernment.moa.id.commons.db.dao.session.AssertionStore; //import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; //import at.gv.egovernment.moa.id.data.AuthenticationData; //import at.gv.egovernment.moa.id.storage.AssertionStorage; //import at.gv.egovernment.moa.util.MiscUtil; // public class simpletest { // public static void main(String[] args) { try { FileInputStream sigDocFIS = null; sigDocFIS = new FileInputStream("D:/idl_test/identity_link.xml"); SPSSFactory spssFac = SPSSFactory.getInstance(); SignatureVerificationService sigVerifyService = SignatureVerificationService.getInstance(); Content sigDocContent = spssFac.createContent(sigDocFIS, null); // Position der zu pruefenden Signatur HashMap nSMap = new HashMap(); nSMap.put("dsig", "http://www.w3.org/2000/09/xmldsig#"); VerifySignatureLocation sigLocation = spssFac.createVerifySignatureLocation("//dsig:Signature", nSMap); // Pruefrequest zusammenstellen VerifySignatureInfo sigInfo = spssFac.createVerifySignatureInfo(sigDocContent, sigLocation); VerifyXMLSignatureRequest verifyRequest = spssFac.createVerifyXMLSignatureRequest( null, // Verwende aktuelle Zeit als Pruefzeit sigInfo, null, // Keine Ergaenzungsobjekte null, // Signaturmanifest-Pruefung soll nicht durchgefuehrt werden true, // Hash-Inputdaten, d.h. tatsaechlich signierte Daten werden nicht zurueckgeliefert "MOAIDBuergerkarteAuthentisierungsDaten"); VerifyXMLSignatureResponse verifyResponse = null; verifyResponse = sigVerifyService.verifyXMLSignature(verifyRequest); SignerInfo signerInfo = verifyResponse.getSignerInfo(); String signerCertificateEncoded = null; List hashInputDatas = verifyResponse.getHashInputDatas(); if (hashInputDatas != null && !hashInputDatas.isEmpty()) { for (Object el : hashInputDatas) { InputData inputData = (InputData) el; switch (inputData.getContentType()) { case Content.XML_CONTENT : ContentXML contentXml = (ContentXML) inputData; NodeList input_XML = contentXml.getXMLContent(); break; case Content.BINARY_CONTENT : ContentBinary contentBinary = (ContentBinary) inputData; String input_Binary = IOUtils.toString(contentBinary.getBinaryContent()); } } } } catch (Exception e) { } // URI fileURI = null; // try { // fileURI = new URI("file:c:/moa3/tomcat8/conf/moa-id/moa-id.properties"); // File propertiesFile = new File(fileURI); // // InputStream in = new FileInputStream(propertiesFile); // ObjectInputStream testOIS = new ObjectInputStream(in); // // Object test = testOIS.readObject(); // // // } catch (Exception e1) { // e1.printStackTrace(); // } // // try { // fileURI = new URI("file:/c:/moa3/tomcat8/conf/moa-id/moa-id.properties"); // File propertiesFile = new File(fileURI); // } catch (Exception e1) { // e1.printStackTrace(); // } // // try { // fileURI = new URI("file://c:/moa3/tomcat8/conf/moa-id/moa-id.properties"); // File propertiesFile = new File(fileURI); // } catch (Exception e1) { // e1.printStackTrace(); // } // // try { // fileURI = new URI("file:///c:/moa3/tomcat8/conf/moa-id/moa-id.properties"); // File propertiesFile = new File(fileURI); // } catch (Exception e1) { // e1.printStackTrace(); // } // // // // try { // InputStream s = new FileInputStream("D:/idl_test/identity_link.xml"); // Element idlTemplate = DOMUtils.parseXmlValidating(s); // // //resign IDL // IdentityLinkReSigner identitylinkresigner = IdentityLinkReSigner.getInstance(); // Element resignedilAssertion = identitylinkresigner.resignIdentityLink(idlTemplate, "IDLSigning"); // IdentityLink identityLink = new IdentityLinkAssertionParser(resignedilAssertion).parseIdentityLink(); // // } catch (Exception e) { // System.out.println(e.getMessage()); // // } // // String subjectName = "serialNumber=896929130327, givenName=OCSP, SN=Responder 03-1, CN=OCSP Responder 03-1, C=AT"; // // try { // Name test = new RFC2253NameParser(subjectName).parse(); // // System.out.println(test.getRFC2253String()); // // } catch (RFC2253NameParserException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // AuthenticationRole test = AuthenticationRoleFactory.buildFormPVPole("ecas-demo-EUROPEAN_COMMISSION(key=A\\,B)"); // // test = AuthenticationRoleFactory.buildFormPVPole("ecas-demo-EUROPEAN_COMMISSION"); // test = AuthenticationRoleFactory.buildFormPVPole("ecas-demo-EUROPEAN_COMMISSION(key=A)"); // test = AuthenticationRoleFactory.buildFormPVPole("ecas-demo-EUROPEAN_COMMISSION(keyA=A,keyB=B)"); // // System.setProperty("mandates.configuration", "D:/Projekte/svn/moa-id/moa-id.properties"); // String propertiesFileLocation = Systm.getProperty("mandates.configuration"); // // MiscUtil.assertNotNull(propertiesFileLocation, "propertiesFileName"); // File propertiesFile = new File(propertiesFileLocation); // FileInputStream fis; // try { // fis = new FileInputStream(propertiesFile); // } catch (FileNotFoundException e) { // // e.printStackTrace(); // return; // } // // Properties props = new Properties(); // try { // props.load(fis); // } catch (IOException e) { // // e.printStackTrace(); // return; // } // // // initialize hibernate // synchronized (simpletest.class) { // // // Configuration hibernateConfig = new Configuration(); // hibernateConfig.addAnnotatedClass(AssertionStore.class); // hibernateConfig.addProperties(props); // HibernateUtil.initHibernate(hibernateConfig, props); // } // // AssertionStorage store = new AssertionStorage(); //// //// AuthenticationData assertion = new AuthenticationData(); //// assertion.setBPK("bPK_schaut_anders_aus"); //// //// //store.put("test", assertion ); // // // store.clean(new Date().getTime(), 1000); // //// try { //// AuthenticationData test = (AuthenticationData) store.get("test"); //// //// } catch (MOADatabaseException e) { //// // TODO Auto-generated catch block //// e.printStackTrace(); //// } // // // } }