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);
}
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);
}
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");
}
}
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);
}
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);
}
Aggregations