Search in sources :

Example 16 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfTransmit.

@Test
public void testConversionOfTransmit() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    Object o = m.unmarshal(m.str2doc(TRANSMIT));
    if (!(o instanceof Transmit)) {
        throw new Exception("Object should be an instace of Transmit");
    }
    Transmit t = (Transmit) o;
    assertEquals(t.getSlotHandle(), StringUtils.toByteArray("7695F667EE2B53824F77544D861236DD"));
    assertEquals(t.getInputAPDUInfo().size(), 2);
    assertEquals(t.getInputAPDUInfo().get(0).getInputAPDU(), StringUtils.toByteArray("00A4040C06D27600000102"));
    assertEquals(t.getInputAPDUInfo().get(0).getAcceptableStatusCode().size(), 1);
    assertEquals(t.getInputAPDUInfo().get(0).getAcceptableStatusCode().get(0), StringUtils.toByteArray("9000"));
    assertEquals(t.getInputAPDUInfo().get(1).getInputAPDU(), StringUtils.toByteArray("00A4040C06D27600000103"));
    assertEquals(t.getInputAPDUInfo().get(1).getAcceptableStatusCode().size(), 2);
    assertEquals(t.getInputAPDUInfo().get(1).getAcceptableStatusCode().get(0), StringUtils.toByteArray("9000"));
    assertEquals(t.getInputAPDUInfo().get(1).getAcceptableStatusCode().get(1), StringUtils.toByteArray("6666"));
}
Also used : Transmit(iso.std.iso_iec._24727.tech.schema.Transmit) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 17 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfInternationalStringType.

@Test
public void testConversionOfInternationalStringType() throws Exception {
    InternationalStringType internationalStringType = new InternationalStringType();
    internationalStringType.setLang("lang");
    internationalStringType.setValue("value");
    WSMarshaller m = new AndroidMarshaller();
    Document d = m.marshal(internationalStringType);
    String s = m.doc2str(d);
    LOG.debug(s);
}
Also used : WSMarshaller(org.openecard.ws.marshal.WSMarshaller) Document(org.w3c.dom.Document) InternationalStringType(oasis.names.tc.dss._1_0.core.schema.InternationalStringType) Test(org.testng.annotations.Test)

Example 18 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfDIDAuthenticateResponseTA.

@Test
public void testConversionOfDIDAuthenticateResponseTA() 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();
    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", "Challenge");
    e.setTextContent("1331F2B1571E6DC2");
    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)

Example 19 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfDIDAutheticate.

@Test
public void testConversionOfDIDAutheticate() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    Document d = m.str2doc(DID_AUTHENTICATE_PACE);
    Object o = m.unmarshal(d);
    if (!(o instanceof DIDAuthenticate)) {
        throw new Exception("Object should be an instace of DIDAuthenticate");
    }
    DIDAuthenticate didAuthenticate = (DIDAuthenticate) o;
    assertEquals(didAuthenticate.getDIDName(), "PIN");
    assertEquals(didAuthenticate.getConnectionHandle().getSlotHandle(), StringUtils.toByteArray("93F25BA574EF3F94F8AE42796DAF7C05"));
    assertEquals(EAC1InputType.class, didAuthenticate.getAuthenticationProtocolData().getClass());
    for (int i = 0; i < didAuthenticate.getAuthenticationProtocolData().getAny().size(); i++) {
        if (didAuthenticate.getAuthenticationProtocolData().getAny().get(i).getLocalName().equals("Certificate")) {
            assertEquals("7F218201487F4E8201005F2901004210444544566549444454523130313430317F494F060A04007F000702020202038641041994E6E55DD1F021180CC705C001FECB4BF5B7E978E8F148002D2D4FDBC1E57A159592681039A041E0036C007E784C36A372528C89365AAB77402E07EED6D4115F200E44453030303030303330303542387F4C12060904007F0007030102025305000100D8005F25060102000102065F2406010200010207655E732D060904007F0007030103028020B90F0EB18F30BCB878EE68924E413A2F5D5DE2F844030141EDB64383C3958C56732D060904007F00070301030180207B0E75C3F613B50011CCB5CF95704B91A6B4AC6EC100377C60BC312A2CE6BE1E5F3740A9A8B9829D2820F96FDB96D09303B01A61F09BC10C766581CAB2BBD2609EC32217C8FEB73F7CAB52CC3A0D16DC1B02F348A3049A246F3790B9687F1F72ACE722", didAuthenticate.getAuthenticationProtocolData().getAny().get(i).getTextContent());
        } else if (didAuthenticate.getAuthenticationProtocolData().getAny().get(i).getLocalName().equals("CertificateDescription")) {
            assertEquals("3082032D060A04007F00070301030101A10E0C0C442D547275737420476D6248A2181316687474703A2F2F7777772E642D74727573742E6E6574A32F0C2D436F736D6F73204C6562656E73766572736963686572756E677320416B7469656E676573656C6C736368616674A41513137777772E636F736D6F73646972656B742E6465A58202410C82023D4E616D652C20416E7363687269667420756E6420452D4D61696C2D4164726573736520646573204469656E737465616E626965746572733A0D0A436F736D6F73204C6562656E73766572736963686572756E677320416B7469656E676573656C6C7363686166740D0A48616C6265726773747261C39F652035302D36300D0A363631303120536161726272C3BC636B656E0D0A696E666F40636F736D6F73646972656B742E64650D0A0D0A4765736368C3A46674737A7765636B3A0D0A2D2052656769737472696572756E67202F204C6F67696E2066C3BC7220226D65696E436F736D6F73446972656B7422202D0D0A0D0A48696E7765697320617566206469652066C3BC722064656E204469656E737465616E626965746572207A757374C3A46E646967656E205374656C6C656E2C20646965206469652045696E68616C74756E672064657220566F7273636872696674656E207A756D20446174656E73636875747A206B6F6E74726F6C6C696572656E3A0D0A4D696E697374657269756D2066C3BC7220496E6E6572657320756E64204575726F7061616E67656C6567656E68656974656E0D0A4D61696E7A65722053747261C39F65203133360D0A363631323120536161726272C3BC636B656E0D0A303638312035303120E280932030300D0A706F73747374656C6C6540696E6E656E2E736161726C616E642E64650D0A687474703A2F2F7777772E696E6E656E2E736161726C616E642E64650D0A416E737072656368706172746E65723A20526F6C616E64204C6F72656E7AA768316604202E15788858E56A91A459BB7086943A5A3AB879F88F72EEE72D5B8202B035943D04206D26166C2748B08BFC3AC0A37109C406A8D35317140F6C69C27C4AB77FDD21F80420805AD754568E472C4761D52D410FB99128AB4CE2D750FDA3A8DA8FBA67BB14EB", didAuthenticate.getAuthenticationProtocolData().getAny().get(i).getTextContent());
        } else if (didAuthenticate.getAuthenticationProtocolData().getAny().get(i).getLocalName().equals("RequiredCHAT")) {
            assertEquals("7F4C12060904007F00070301020253050001009800", didAuthenticate.getAuthenticationProtocolData().getAny().get(i).getTextContent());
        } else if (didAuthenticate.getAuthenticationProtocolData().getAny().get(i).getLocalName().equals("OptionalCHAT")) {
            assertEquals("7F4C12060904007F00070301020253050000004000", didAuthenticate.getAuthenticationProtocolData().getAny().get(i).getTextContent());
        } else if (didAuthenticate.getAuthenticationProtocolData().getAny().get(i).getLocalName().equals("AuthenticatedAuxiliaryData")) {
            assertEquals("67177315060904007F00070301040253083230313230313236", didAuthenticate.getAuthenticationProtocolData().getAny().get(i).getTextContent());
        }
    }
    d = m.str2doc(DID_AUTHENTICATE_TA);
    o = m.unmarshal(d);
    if (!(o instanceof DIDAuthenticate)) {
        throw new Exception("Object should be an instace of DIDAuthenticate");
    }
    didAuthenticate = (DIDAuthenticate) o;
    assertEquals(didAuthenticate.getDIDName(), "PIN");
    assertEquals(didAuthenticate.getConnectionHandle().getSlotHandle(), StringUtils.toByteArray("05D4F40AEBD9919383C22216055EA3DB15056C51"));
    assertEquals(EAC2InputType.class, didAuthenticate.getAuthenticationProtocolData().getClass());
    AuthDataMap eac2input = new AuthDataMap(didAuthenticate.getAuthenticationProtocolData());
    assertEquals(eac2input.getContentAsString("EphemeralPublicKey"), "8D44E99377DA28436D2F7E8620347D7C08B186B179633E3654842E940AB179B498F974970D990D47C61FE5D4D91EBB10831E824EC6F2600D89D6661CDF47F734");
    // assertEquals(eac2input.getContentAsString("Certificate"),
    // "7F2181E47F4E819D5F290100420D5A5A43564341415441303030317F494F060A04007F0007020202020386410452DD32EAFE1FBBB4000CD9CE75F66636CFCF1EDD44F7B1EDAE25B84193DA04A91C77EE87F5C8F959ED276200DE33AB574CE9801135FF4497A37162B7C8548A0C5F200E5A5A4456434141544130303030357F4C12060904007F0007030102025305700301FFB75F25060100000601015F24060100010003015F37406F13AE9A6F4EDDB7839FF3F04D71E0DC377BC4B08FAD295EED241B524328AD0730EB553497B4FB66E9BB7AB90815F04273F09E751D7FD4B861439B4EE65381C3");
    assertEquals(eac2input.getContentAsString("Certificate"), "7F218201427F4E81FB5F290100420E5A5A4456434141544130303030357F494F060A04007F0007020202020386410470C07FAA329E927D961F490F5430B395EECF3D2A538194D8B637DE0F8ACF60A9031816AC51B594097EB211FB8F55FAA8507D5800EF7B94E024F9630314116C755F200B5A5A444B423230303033557F4C12060904007F0007030102025305000301DF045F25060100000601085F2406010000070001655E732D060904007F00070301030280207C1901932DB75D08539F2D4A27C938F79E69E083C442C068B299D185BC8AFA78732D060904007F0007030103018020BFD2A6A2E4237948D7DCCF7975D71D40F15307AA59F580A48777CBEED093F54B5F3740618F584E4293F75DDE8977311694B69A3ED73BBE43FDAFEC11B7ECF054F84ACB1231615338CE8D6EC332480883E14E0664950F85134290DD716B7C153232BC96");
    marshalLog(didAuthenticate);
    d = m.str2doc(DID_AUTHENTICATE_CA);
    o = m.unmarshal(d);
    if (!(o instanceof DIDAuthenticate)) {
        throw new Exception("Object should be an instace of DIDAuthenticate");
    }
    didAuthenticate = (DIDAuthenticate) o;
    assertEquals(didAuthenticate.getDIDName(), "PIN");
    assertEquals(didAuthenticate.getConnectionHandle().getSlotHandle(), StringUtils.toByteArray("05D4F40AEBD9919383C22216055EA3DB15056C51"));
    assertEquals(EACAdditionalInputType.class, didAuthenticate.getAuthenticationProtocolData().getClass());
    AuthDataMap eacadditionalinput = new AuthDataMap(didAuthenticate.getAuthenticationProtocolData());
    assertEquals(eacadditionalinput.getContentAsString("Signature"), "7117D7BF95D8D6BD437A0D43DE48F42528273A98F2605758D6A3A2BFC38141E7577CABB4F8FBC8DF152E3A097D1B3A703597331842425FE4A9D0F1C9067AC4A9");
    // assertEquals(eac2input.getContentAsString("Certificate"),
    // "7F2181E47F4E819D5F290100420D5A5A43564341415441303030317F494F060A04007F0007020202020386410452DD32EAFE1FBBB4000CD9CE75F66636CFCF1EDD44F7B1EDAE25B84193DA04A91C77EE87F5C8F959ED276200DE33AB574CE9801135FF4497A37162B7C8548A0C5F200E5A5A4456434141544130303030357F4C12060904007F0007030102025305700301FFB75F25060100000601015F24060100010003015F37406F13AE9A6F4EDDB7839FF3F04D71E0DC377BC4B08FAD295EED241B524328AD0730EB553497B4FB66E9BB7AB90815F04273F09E751D7FD4B861439B4EE65381C3");
    marshalLog(didAuthenticate);
}
Also used : DIDAuthenticate(iso.std.iso_iec._24727.tech.schema.DIDAuthenticate) AuthDataMap(org.openecard.common.anytype.AuthDataMap) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) Document(org.w3c.dom.Document) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 20 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfDisconnect.

@Test
public void testConversionOfDisconnect() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    Object o = m.unmarshal(m.str2doc(DISCONNECT));
    if (!(o instanceof Disconnect)) {
        throw new Exception("Object should be an instace of EstablishContext");
    }
    Disconnect d = (Disconnect) o;
    assertEquals(d.getSlotHandle(), StringUtils.toByteArray("1D8EFC10F063FB6FE8A3BBF8D2E0CA5C"));
    assertEquals(d.getAction(), ActionType.EJECT);
}
Also used : Disconnect(iso.std.iso_iec._24727.tech.schema.Disconnect) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) IOException(java.io.IOException) 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