Search in sources :

Example 6 with WSMarshaller

use of org.openecard.ws.marshal.WSMarshaller in project open-ecard by ecsec.

the class AndroidMarshallerTest method testSOAP.

@Test
public void testSOAP() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    StartPAOS sp = new StartPAOS();
    sp.setSessionIdentifier("5ec5ebb1dd254f392e6ca33cf5bf");
    ConnectionHandleType connectionHandleType = new ConnectionHandleType();
    connectionHandleType.setContextHandle(new BigInteger("94D7439CE657561E7AE3D491FD71AC21F8BCBB5608BA61F5A0EA52269BC01250", 16).toByteArray());
    connectionHandleType.setSlotHandle(new BigInteger("EEB49368C1152BEC379DA59356D59039CA7757AC3EAF9430285F2CBB3DD6EDDD", 16).toByteArray());
    sp.getConnectionHandle().add(connectionHandleType);
    Document contentDoc = m.marshal(sp);
    SOAPMessage msg = m.add2soap(contentDoc);
    SOAPHeader header = msg.getSOAPHeader();
    // fill header with paos stuff
    Element paos = header.addHeaderElement(new QName(ECardConstants.PAOS_VERSION_20, "PAOS"));
    paos.setAttributeNS(ECardConstants.SOAP_ENVELOPE, "actor", ECardConstants.ACTOR_NEXT);
    paos.setAttributeNS(ECardConstants.SOAP_ENVELOPE, "mustUnderstand", "1");
    Element version = header.addChildElement(paos, new QName(ECardConstants.PAOS_VERSION_20, "Version"));
    version.setTextContent(ECardConstants.PAOS_VERSION_20);
    Element endpointReference = header.addChildElement(paos, new QName(ECardConstants.PAOS_VERSION_20, "EndpointReference"));
    Element address = header.addChildElement(endpointReference, new QName(ECardConstants.PAOS_VERSION_20, "Address"));
    address.setTextContent("http://www.projectliberty.org/2006/01/role/paos");
    Element metaData = header.addChildElement(endpointReference, new QName(ECardConstants.PAOS_VERSION_20, "MetaData"));
    Element serviceType = header.addChildElement(metaData, new QName(ECardConstants.PAOS_VERSION_20, "ServiceType"));
    serviceType.setTextContent("http://www.bsi.bund.de/ecard/api/1.0/PAOS/GetNextCommand");
    // add message ids
    SOAPHeader h = msg.getSOAPHeader();
    Element elem = h.addHeaderElement(new QName(ECardConstants.WS_ADDRESSING, "RelatesTo"));
    elem.setTextContent("relatesto");
    elem = h.addHeaderElement(new QName(ECardConstants.WS_ADDRESSING, "MessageID"));
    elem.setTextContent("messageid");
    String responseStr = m.doc2str(msg.getDocument());
    LOG.debug(responseStr);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) StartPAOS(iso.std.iso_iec._24727.tech.schema.StartPAOS) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) BigInteger(java.math.BigInteger) Document(org.w3c.dom.Document) SOAPMessage(org.openecard.ws.soap.SOAPMessage) SOAPHeader(org.openecard.ws.soap.SOAPHeader) Test(org.testng.annotations.Test)

Example 7 with WSMarshaller

use of org.openecard.ws.marshal.WSMarshaller in project open-ecard by ecsec.

the class AndroidMarshallerTest method testConversionOfAddonBundleDescription.

@Test
public void testConversionOfAddonBundleDescription() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    Object o = m.unmarshal(m.str2doc(TEST_ADDON_BUNDDLE_DESCRIPTION));
    if (!(o instanceof AddonSpecification)) {
        throw new Exception("Object should be an instace of AddonSpecification");
    }
    marshalLog(o);
}
Also used : WSMarshaller(org.openecard.ws.marshal.WSMarshaller) AddonSpecification(org.openecard.addon.manifest.AddonSpecification) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 8 with WSMarshaller

use of org.openecard.ws.marshal.WSMarshaller in project open-ecard by ecsec.

the class AndroidMarshallerTest method testConversionOfEstablishContext.

@Test
public void testConversionOfEstablishContext() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    EstablishContext establishContext = new EstablishContext();
    Document d = m.marshal(establishContext);
    String s = m.doc2str(d);
    assertEquals(s.trim(), ESTABLISH_CONTEXT_XML.trim());
    Object o = m.unmarshal(d);
    if (!(o instanceof EstablishContext)) {
        throw new Exception("Object should be an instace of EstablishContext");
    }
}
Also used : WSMarshaller(org.openecard.ws.marshal.WSMarshaller) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) Document(org.w3c.dom.Document) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 9 with WSMarshaller

use of org.openecard.ws.marshal.WSMarshaller in project open-ecard by ecsec.

the class AndroidMarshallerTest method testConversionOfDestroyChannel.

@Test
public void testConversionOfDestroyChannel() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    DestroyChannel destroy = new DestroyChannel();
    destroy.setSlotHandle(new byte[] { 0x0, 0x1, 0x2, 0x3, 0x4, 0x5 });
    Document d = m.marshal(destroy);
    assertEquals(m.doc2str(d), DESTROY_CHANNEL);
}
Also used : DestroyChannel(iso.std.iso_iec._24727.tech.schema.DestroyChannel) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) Document(org.w3c.dom.Document) Test(org.testng.annotations.Test)

Example 10 with WSMarshaller

use of org.openecard.ws.marshal.WSMarshaller in project open-ecard by ecsec.

the class AndroidMarshallerTest method testConversionOfDIDAuthenticateResponsePACE.

@Test
public void testConversionOfDIDAuthenticateResponsePACE() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    DIDAuthenticateResponse didAuthResponse = new DIDAuthenticateResponse();
    Result r = new Result();
    r.setResultMajor("major");
    r.setResultMinor("minor");
    InternationalStringType internationalStringType = new InternationalStringType();
    internationalStringType.setLang("en");
    internationalStringType.setValue("message");
    r.setResultMessage(internationalStringType);
    didAuthResponse.setResult(r);
    EAC1OutputType didAuthenticationDataType = new EAC1OutputType();
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document d = builder.newDocument();
    Element e = d.createElementNS("urn:iso:std:iso-iec:24727:tech:schema", "RetryCounter");
    e.setTextContent("3");
    didAuthenticationDataType.getAny().add(e);
    e = d.createElementNS("urn:iso:std:iso-iec:24727:tech:schema", "CertificateHolderAuthorizationTemplate");
    e.setTextContent("7F4C12060904007F00070301020253050001009800");
    didAuthenticationDataType.getAny().add(e);
    e = d.createElementNS("urn:iso:std:iso-iec:24727:tech:schema", "CertificationAuthorityReference");
    e.setTextContent("ZZCVCAATA0001");
    didAuthenticationDataType.getAny().add(e);
    e = d.createElementNS("urn:iso:std:iso-iec:24727:tech:schema", "EFCardAccess");
    e.setTextContent("31820264300D060804007F0007020202020102300F060A04007F00070202030202020102300F060A04007F00070202040202020101302F060804007F0007020206162341775420655041202D2042447220476D6248202D20546573746B617274652076312E303081FE060904007F0007020203023081F0060B04007F00070101050202023081E0020101302C06072A8648CE3D0101022100A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E537730440420A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E53740420662C61C430D84EA4FE66A7733D0B76B7BF93EBC4AF2F49256AE58101FEE92B04044104A3E8EB3CC1CFE7B7732213B23A656149AFA142C47AAFBC2B79A191562E1305F42D996C823439C56D7F7B22E14644417E69BCB6DE39D027001DABE8F35B25C9BE022100A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A70201013081FE060904007F0007020204023081F0060B04007F00070101050202023081E0020101302C06072A8648CE3D0101022100A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E537730440420A9FB57DBA1EEA9BC3E660A909D838D726E3BF623D52620282013481D1F6E53740420662C61C430D84EA4FE66A7733D0B76B7BF93EBC4AF2F49256AE58101FEE92B04044104A3E8EB3CC1CFE7B7732213B23A656149AFA142C47AAFBC2B79A191562E1305F42D996C823439C56D7F7B22E14644417E69BCB6DE39D027001DABE8F35B25C9BE022100A9FB57DBA1EEA9BC3E660A909D838D718C397AA3B561A6F7901E0E82974856A7020101");
    didAuthenticationDataType.getAny().add(e);
    e = d.createElementNS("urn:iso:std:iso-iec:24727:tech:schema", "IDPICC");
    e.setTextContent("4F5311EC8F92D60040EA63365E2B06C832856CDE1CE5F8B3C7E7696DAD7628BD");
    didAuthenticationDataType.getAny().add(e);
    didAuthResponse.setAuthenticationProtocolData(didAuthenticationDataType);
    marshalLog(didAuthResponse);
    Document doc = m.marshal(didAuthResponse);
    String s = m.doc2str(doc);
    LOG.debug(s);
    StringReader sr = new StringReader(s);
    DIDAuthenticateResponse didaresp = JAXB.unmarshal(sr, DIDAuthenticateResponse.class);
    marshalLog(didaresp);
}
Also used : EAC1OutputType(iso.std.iso_iec._24727.tech.schema.EAC1OutputType) DIDAuthenticateResponse(iso.std.iso_iec._24727.tech.schema.DIDAuthenticateResponse) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) StringReader(java.io.StringReader) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) Document(org.w3c.dom.Document) InternationalStringType(oasis.names.tc.dss._1_0.core.schema.InternationalStringType) Result(oasis.names.tc.dss._1_0.core.schema.Result) Test(org.testng.annotations.Test)

Aggregations

WSMarshaller (org.openecard.ws.marshal.WSMarshaller)36 Test (org.testng.annotations.Test)28 Document (org.w3c.dom.Document)21 IOException (java.io.IOException)12 InternationalStringType (oasis.names.tc.dss._1_0.core.schema.InternationalStringType)6 WSMarshallerException (org.openecard.ws.marshal.WSMarshallerException)6 Element (org.w3c.dom.Element)6 BigInteger (java.math.BigInteger)5 Result (oasis.names.tc.dss._1_0.core.schema.Result)5 EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)4 StringReader (java.io.StringReader)4 Connect (iso.std.iso_iec._24727.tech.schema.Connect)3 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)3 DIDAuthenticateResponse (iso.std.iso_iec._24727.tech.schema.DIDAuthenticateResponse)3 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)3 EstablishContext (iso.std.iso_iec._24727.tech.schema.EstablishContext)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)3 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)3 ChannelHandleType (iso.std.iso_iec._24727.tech.schema.ChannelHandleType)2 ControlIFD (iso.std.iso_iec._24727.tech.schema.ControlIFD)2