Search in sources :

Example 11 with ChannelHandleType

use of iso.std.iso_iec._24727.tech.schema.ChannelHandleType in project open-ecard by ecsec.

the class HandlePrinter method printHandle.

public static void printHandle(Writer w, ConnectionHandleType handle) throws IOException {
    ChannelHandleType channel = handle.getChannelHandle();
    String session = null;
    if (channel != null) {
        session = channel.getSessionIdentifier();
    }
    byte[] ctx = handle.getContextHandle();
    String ifdname = handle.getIFDName();
    BigInteger slotIdx = handle.getSlotIndex();
    byte[] slotHandle = handle.getSlotHandle();
    ConnectionHandleType.RecognitionInfo rec = handle.getRecognitionInfo();
    String cardType = null;
    if (rec != null) {
        cardType = rec.getCardType();
    }
    w.write("ConnectionHandle:");
    if (session != null) {
        w.write("\n  Session: ");
        w.write(session);
    }
    if (ctx != null) {
        w.write("\n  ContextHandle: ");
        w.write(ByteUtils.toHexString(ctx));
    }
    if (ifdname != null) {
        w.write("\n  IFDName: ");
        w.write(ifdname);
        if (slotIdx != null) {
            w.write("  SlotIndex: ");
            w.write(slotIdx.toString());
        }
    }
    if (slotHandle != null) {
        w.write("\n  SlotHandle: ");
        w.write(ByteUtils.toHexString(slotHandle));
    }
    if (cardType != null) {
        w.write("\n  CardType: ");
        w.write(cardType);
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) BigInteger(java.math.BigInteger) ChannelHandleType(iso.std.iso_iec._24727.tech.schema.ChannelHandleType)

Example 12 with ChannelHandleType

use of iso.std.iso_iec._24727.tech.schema.ChannelHandleType 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 13 with ChannelHandleType

use of iso.std.iso_iec._24727.tech.schema.ChannelHandleType in project open-ecard by ecsec.

the class AndroidMarshaller method marshalCardApplicationPathResult.

private Element marshalCardApplicationPathResult(CardApplicationPathType type, Document document, String name) {
    Element em = createElementIso(document, name);
    // ChannelHandle
    ChannelHandleType h = type.getChannelHandle();
    Element emChild = createElementIso(document, "ChannelHandle");
    Element emChildOfCH;
    if (h.getProtocolTerminationPoint() != null) {
        emChildOfCH = createElementIso(document, "ProtocolTerminationPoint");
        emChildOfCH.appendChild(document.createTextNode(h.getProtocolTerminationPoint()));
        emChild.appendChild(emChildOfCH);
    }
    if (h.getSessionIdentifier() != null) {
        emChildOfCH = createElementIso(document, "SessionIdentifier");
        emChildOfCH.appendChild(document.createTextNode(h.getSessionIdentifier()));
        emChild.appendChild(emChildOfCH);
    }
    if (h.getBinding() != null) {
        emChildOfCH = createElementIso(document, "Binding");
        emChildOfCH.appendChild(document.createTextNode(h.getBinding()));
        emChild.appendChild(emChildOfCH);
    }
    PathSecurityType ps = h.getPathSecurity();
    if (ps != null) {
        emChildOfCH = createElementIso(document, "PathSecurity");
        Element emChildOfPS = createElementIso(document, "Protocol");
        emChildOfPS.appendChild(document.createTextNode(ps.getProtocol()));
        emChildOfCH.appendChild(emChildOfPS);
        // TODO here any type parsen
        LOG.error("AnyType of CardApplicationPath: " + ps.getParameters().toString());
        emChild.appendChild(emChildOfCH);
        em.appendChild(emChild);
    }
    // context handle
    emChild = createElementIso(document, "ContextHandle");
    emChild.appendChild(document.createTextNode(ByteUtils.toHexString(type.getContextHandle())));
    em.appendChild(emChild);
    // IFDName
    emChild = createElementIso(document, "IFDName");
    emChild.appendChild(document.createTextNode(type.getIFDName()));
    em.appendChild(emChild);
    // SlotIndex
    emChild = createElementIso(document, "SlotIndex");
    emChild.appendChild(document.createTextNode(type.getSlotIndex().toString()));
    em.appendChild(emChild);
    // Card Application
    emChild = createElementIso(document, "CardApplication");
    emChild.appendChild(document.createTextNode(ByteUtils.toHexString(type.getCardApplication())));
    em.appendChild(emChild);
    return em;
}
Also used : PathSecurityType(iso.std.iso_iec._24727.tech.schema.PathSecurityType) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) ChannelHandleType(iso.std.iso_iec._24727.tech.schema.ChannelHandleType)

Example 14 with ChannelHandleType

use of iso.std.iso_iec._24727.tech.schema.ChannelHandleType in project open-ecard by ecsec.

the class HandlerBuilder method buildChannelHandle.

/**
 * Creates a {@code ChannelHandleType} if the relevant values are set in the instance.
 *
 * @return A {@code ChannelHandleType} instance, or {@code null} if no values are available.
 */
@Nullable
public ChannelHandleType buildChannelHandle() {
    if (protocolEndpoint != null || sessionId != null || binding != null) {
        ChannelHandleType chan = new ChannelHandleType();
        chan.setProtocolTerminationPoint(protocolEndpoint);
        chan.setSessionIdentifier(sessionId);
        chan.setBinding(binding);
        return chan;
    } else {
        return null;
    }
}
Also used : ChannelHandleType(iso.std.iso_iec._24727.tech.schema.ChannelHandleType) Nullable(javax.annotation.Nullable)

Aggregations

ChannelHandleType (iso.std.iso_iec._24727.tech.schema.ChannelHandleType)12 BigInteger (java.math.BigInteger)8 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)6 PathSecurityType (iso.std.iso_iec._24727.tech.schema.PathSecurityType)4 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)3 BeginTransaction (iso.std.iso_iec._24727.tech.schema.BeginTransaction)2 BeginTransactionResponse (iso.std.iso_iec._24727.tech.schema.BeginTransactionResponse)2 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)2 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)2 CardApplicationDisconnect (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect)2 CardApplicationDisconnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnectResponse)2 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)2 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)2 Connect (iso.std.iso_iec._24727.tech.schema.Connect)2 ConnectResponse (iso.std.iso_iec._24727.tech.schema.ConnectResponse)2 SlotInfo (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.SlotInfo)2 DIDAuthenticate (iso.std.iso_iec._24727.tech.schema.DIDAuthenticate)2 DIDAuthenticateResponse (iso.std.iso_iec._24727.tech.schema.DIDAuthenticateResponse)2 DestroyChannel (iso.std.iso_iec._24727.tech.schema.DestroyChannel)2 DestroyChannelResponse (iso.std.iso_iec._24727.tech.schema.DestroyChannelResponse)2