Search in sources :

Example 1 with WSMarshaller

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

the class PINTest method testModifyPin.

@Test(enabled = false)
public void testModifyPin() throws IFDException, WSMarshallerException, SAXException {
    IFD ifd = new IFD();
    ifd.setGUI(new SwingUserConsent(new SwingDialogWrapper()));
    EstablishContext eCtx = new EstablishContext();
    byte[] ctxHandle = ifd.establishContext(eCtx).getContextHandle();
    ListIFDs listIFDs = new ListIFDs();
    listIFDs.setContextHandle(ctxHandle);
    String ifdName = ifd.listIFDs(listIFDs).getIFDName().get(0);
    Connect connect = new Connect();
    connect.setContextHandle(ctxHandle);
    connect.setIFDName(ifdName);
    connect.setSlot(BigInteger.ZERO);
    byte[] slotHandle = ifd.connect(connect).getSlotHandle();
    // prepare pace call
    String xmlCall = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<iso:EstablishChannel xmlns:iso=\"urn:iso:std:iso-iec:24727:tech:schema\">\n" + "  <iso:SlotHandle>" + ByteUtils.toHexString(slotHandle) + "</iso:SlotHandle>\n" + "  <iso:AuthenticationProtocolData Protocol=\"urn:oid:0.4.0.127.0.7.2.2.4\">\n" + "    <iso:PinID>03</iso:PinID>\n" + "  </iso:AuthenticationProtocolData>\n" + "</iso:EstablishChannel>";
    WSMarshaller m = WSMarshallerFactory.createInstance();
    EstablishChannel eCh = (EstablishChannel) m.unmarshal(m.str2doc(xmlCall));
    // send pace call
    EstablishChannelResponse eChR = ifd.establishChannel(eCh);
    assertEquals(eChR.getResult().getResultMajor(), ECardConstants.Major.OK);
    PasswordAttributesType pwdAttr = create(true, ASCII_NUMERIC, 6, 6, 6);
    pwdAttr.setPadChar(new byte[] { (byte) 0x3F });
    PCSCPinModify ctrlStruct = new PCSCPinModify(pwdAttr, StringUtils.toByteArray("002C0203"));
    byte[] structData = ctrlStruct.toBytes();
    String pinStr = "00 2C 02 03 06 3F3F3F3F3F3F";
    String ctrlStr = "15 05 82 06 00 00 00 0606 01 02 02 0407 00 01 02 000000 0B000000";
    // This is the command the 'AusweisApp' sends
    // String ausweisApp = "150582080000000606010202090400010200000005000000002C020300";
    byte[] referenceData = StringUtils.toByteArray(ctrlStr + pinStr, true);
    assertEquals(referenceData, structData);
    ControlIFD controlIFD = new ControlIFD();
    controlIFD.setCommand(ByteUtils.concatenate((byte) PCSCFeatures.MODIFY_PIN_DIRECT, structData));
    controlIFD.setSlotHandle(slotHandle);
    ControlIFDResponse response = ifd.controlIFD(controlIFD);
}
Also used : ListIFDs(iso.std.iso_iec._24727.tech.schema.ListIFDs) PasswordAttributesType(iso.std.iso_iec._24727.tech.schema.PasswordAttributesType) ControlIFD(iso.std.iso_iec._24727.tech.schema.ControlIFD) ControlIFD(iso.std.iso_iec._24727.tech.schema.ControlIFD) PCSCPinModify(org.openecard.ifd.scio.reader.PCSCPinModify) Connect(iso.std.iso_iec._24727.tech.schema.Connect) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) SwingDialogWrapper(org.openecard.gui.swing.SwingDialogWrapper) EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) ControlIFDResponse(iso.std.iso_iec._24727.tech.schema.ControlIFDResponse) SwingUserConsent(org.openecard.gui.swing.SwingUserConsent) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) Test(org.testng.annotations.Test)

Example 2 with WSMarshaller

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

the class PINTest method executePACE_PIN.

@Test(enabled = false)
public void executePACE_PIN() throws UnsupportedDataTypeException, JAXBException, SAXException, WSMarshallerException {
    IFD ifd = new IFD();
    ifd.setGUI(new SwingUserConsent(new SwingDialogWrapper()));
    EstablishContext eCtx = new EstablishContext();
    byte[] ctxHandle = ifd.establishContext(eCtx).getContextHandle();
    ListIFDs listIFDs = new ListIFDs();
    listIFDs.setContextHandle(ctxHandle);
    String ifdName = ifd.listIFDs(listIFDs).getIFDName().get(0);
    Connect connect = new Connect();
    connect.setContextHandle(ctxHandle);
    connect.setIFDName(ifdName);
    connect.setSlot(BigInteger.ZERO);
    byte[] slotHandle = ifd.connect(connect).getSlotHandle();
    // prepare pace call
    String xmlCall = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<iso:EstablishChannel xmlns:iso=\"urn:iso:std:iso-iec:24727:tech:schema\">\n" + "  <iso:SlotHandle>" + ByteUtils.toHexString(slotHandle) + "</iso:SlotHandle>\n" + "  <iso:AuthenticationProtocolData Protocol=\"urn:oid:0.4.0.127.0.7.2.2.4\">\n" + "    <iso:PinID>03</iso:PinID>\n" + "  </iso:AuthenticationProtocolData>\n" + "</iso:EstablishChannel>";
    WSMarshaller m = WSMarshallerFactory.createInstance();
    EstablishChannel eCh = (EstablishChannel) m.unmarshal(m.str2doc(xmlCall));
    // send pace call
    EstablishChannelResponse eChR = ifd.establishChannel(eCh);
}
Also used : SwingDialogWrapper(org.openecard.gui.swing.SwingDialogWrapper) ListIFDs(iso.std.iso_iec._24727.tech.schema.ListIFDs) EstablishChannel(iso.std.iso_iec._24727.tech.schema.EstablishChannel) ControlIFD(iso.std.iso_iec._24727.tech.schema.ControlIFD) Connect(iso.std.iso_iec._24727.tech.schema.Connect) EstablishChannelResponse(iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse) SwingUserConsent(org.openecard.gui.swing.SwingUserConsent) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) Test(org.testng.annotations.Test)

Example 3 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfResult.

@Test
public void testConversionOfResult() throws Exception {
    Result r = new Result();
    r.setResultMajor("major");
    r.setResultMinor("minor");
    InternationalStringType internationalStringType = new InternationalStringType();
    internationalStringType.setLang("lang");
    internationalStringType.setValue("value");
    r.setResultMessage(internationalStringType);
    WSMarshaller m = new AndroidMarshaller();
    Document d = m.marshal(r);
    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) Result(oasis.names.tc.dss._1_0.core.schema.Result) Test(org.testng.annotations.Test)

Example 4 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfWait.

@Test
public void testConversionOfWait() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    Wait w = new Wait();
    w.setContextHandle(new byte[] { 0x0, 0x1, 0x2 });
    w.setTimeOut(new BigInteger("123"));
    ChannelHandleType channelHandleType = new ChannelHandleType();
    channelHandleType.setBinding("binding");
    channelHandleType.setProtocolTerminationPoint("protocolterminatiopoint");
    channelHandleType.setSessionIdentifier("sessionidentifier");
    PathSecurityType pathSecurityType = new PathSecurityType();
    pathSecurityType.setParameters("omg");
    pathSecurityType.setProtocol("protocol");
    channelHandleType.setPathSecurity(pathSecurityType);
    w.setCallback(channelHandleType);
    Document d = m.marshal(w);
    String s = m.doc2str(d);
    LOG.debug(s);
}
Also used : PathSecurityType(iso.std.iso_iec._24727.tech.schema.PathSecurityType) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) BigInteger(java.math.BigInteger) ChannelHandleType(iso.std.iso_iec._24727.tech.schema.ChannelHandleType) Wait(iso.std.iso_iec._24727.tech.schema.Wait) Document(org.w3c.dom.Document) Test(org.testng.annotations.Test)

Example 5 with WSMarshaller

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

the class AndroidMarshallerTest method testConversionOfGetStatus.

@Test
public void testConversionOfGetStatus() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    GetStatus getStatus = new GetStatus();
    getStatus.setIFDName("ifdName");
    getStatus.setContextHandle(new byte[] { 0x0, 0x1, 0x2 });
    Document d = m.marshal(getStatus);
    String s = m.doc2str(d);
    LOG.debug(s);
}
Also used : WSMarshaller(org.openecard.ws.marshal.WSMarshaller) Document(org.w3c.dom.Document) GetStatus(iso.std.iso_iec._24727.tech.schema.GetStatus) 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