Search in sources :

Example 26 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfStartPAOS.

@Test
public void testConversionOfStartPAOS() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    StartPAOS startP = new StartPAOS();
    startP.setSessionIdentifier("5ec5ebb1dd254f392e6ca33cf5bf");
    ConnectionHandleType connectionHandleType = new ConnectionHandleType();
    connectionHandleType.setContextHandle(new BigInteger("94D7439CE657561E7AE3D491FD71AC21F8BCBB5608BA61F5A0EA52269BC01250", 16).toByteArray());
    connectionHandleType.setSlotHandle(new BigInteger("EEB49368C1152BEC379DA59356D59039CA7757AC3EAF9430285F2CBB3DD6EDDD", 16).toByteArray());
    connectionHandleType.setIFDName("Name of IFD");
    connectionHandleType.setSlotIndex(new BigInteger("0"));
    connectionHandleType.setCardApplication(new byte[] { 0x0, 0x0, 0x0 });
    ChannelHandleType channelHandle = new ChannelHandleType();
    channelHandle.setSessionIdentifier("sessionID");
    connectionHandleType.setChannelHandle(channelHandle);
    RecognitionInfo recognitionInfo = new RecognitionInfo();
    recognitionInfo.setCardType("nPA_1-0-0.xml");
    connectionHandleType.setRecognitionInfo(recognitionInfo);
    startP.getConnectionHandle().add(connectionHandleType);
    Document d = m.marshal(startP);
    assertEquals(m.doc2str(d), START_PAOS);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) StartPAOS(iso.std.iso_iec._24727.tech.schema.StartPAOS) RecognitionInfo(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) BigInteger(java.math.BigInteger) ChannelHandleType(iso.std.iso_iec._24727.tech.schema.ChannelHandleType) Document(org.w3c.dom.Document) Test(org.testng.annotations.Test)

Example 27 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfInitializeFrameworkResponse.

@Test
public void testConversionOfInitializeFrameworkResponse() throws Exception {
    InitializeFrameworkResponse initializeFrameworkResponse = new InitializeFrameworkResponse();
    Version version = new Version();
    version.setMajor(new BigInteger("11"));
    version.setMinor(new BigInteger("22"));
    version.setSubMinor(new BigInteger("33"));
    initializeFrameworkResponse.setVersion(version);
    Result r = new Result();
    r.setResultMajor("major");
    r.setResultMinor("minor");
    InternationalStringType internationalStringType = new InternationalStringType();
    internationalStringType.setLang("lang");
    internationalStringType.setValue("value");
    r.setResultMessage(internationalStringType);
    initializeFrameworkResponse.setResult(r);
    marshalLog(initializeFrameworkResponse);
    WSMarshaller m = new AndroidMarshaller();
    Document d = m.marshal(initializeFrameworkResponse);
    String s = m.doc2str(d);
    LOG.debug(s);
}
Also used : Version(de.bund.bsi.ecard.api._1.InitializeFrameworkResponse.Version) InitializeFrameworkResponse(de.bund.bsi.ecard.api._1.InitializeFrameworkResponse) BigInteger(java.math.BigInteger) 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)

Example 28 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfEstablishChannel.

@Test
public void testConversionOfEstablishChannel() throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document d = builder.newDocument();
    EstablishChannel establishChannel = new EstablishChannel();
    establishChannel.setSlotHandle(new byte[] { 0x0, 0x1, 0x02 });
    DIDAuthenticationDataType establishChannelInput = new DIDAuthenticationDataType();
    establishChannelInput.setProtocol(ECardConstants.Protocol.PACE);
    Element e = d.createElementNS("urn:iso:std:iso-iec:24727:tech:schema", "PinID");
    // Personalausweis-PIN
    e.setTextContent("3");
    establishChannelInput.getAny().add(e);
    e = d.createElementNS("urn:iso:std:iso-iec:24727:tech:schema", "PIN");
    // Personalausweis-PIN
    e.setTextContent("123456");
    establishChannelInput.getAny().add(e);
    establishChannel.setAuthenticationProtocolData(establishChannelInput);
    marshalLog(establishChannel);
    WSMarshaller m = new AndroidMarshaller();
    Document doc = m.marshal(establishChannel);
    String s = m.doc2str(doc);
    LOG.debug(s);
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) Document(org.w3c.dom.Document) Test(org.testng.annotations.Test)

Example 29 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfGetStatusResponse.

@Test
public void testConversionOfGetStatusResponse() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    Object o = m.unmarshal(m.str2doc(GET_STATUS_RESPONSE));
    if (!(o instanceof GetStatusResponse)) {
        throw new Exception("Object should be an instace of GetStatusResponse");
    }
}
Also used : GetStatusResponse(iso.std.iso_iec._24727.tech.schema.GetStatusResponse) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 30 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfDIDAuthenticateResponseCA.

@Test
public void testConversionOfDIDAuthenticateResponseCA() 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);
    EAC2OutputType didAuthenticationDataType = new EAC2OutputType();
    didAuthenticationDataType.setProtocol("urn:....");
    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", "Signature");
    e.setTextContent("7117D7BF95D8D6BD437A0D43DE48F42528273A98F2605758D6A3A2BFC38141E7577CABB4F8FBC8DF152E3A097D1B3A703597331842425FE4A9D0F1C9067AC4A9");
    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 : 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) EAC2OutputType(iso.std.iso_iec._24727.tech.schema.EAC2OutputType) 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