Search in sources :

Example 11 with SlotStatusType

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

the class IFDStatusDiff method merge.

private List<IFDStatusType> merge(List<IFDStatusType> deleted) {
    ArrayList<IFDStatusType> states = new ArrayList<IFDStatusType>(result.size() + deleted.size());
    states.addAll(result);
    // transform all deleted terminals so it is clear they disappeared
    for (IFDStatusType next : deleted) {
        IFDStatusType s = new IFDStatusType();
        s.setIFDName(next.getIFDName());
        s.setConnected(Boolean.FALSE);
        // slots must be present too
        for (SlotStatusType nextST : next.getSlotStatus()) {
            SlotStatusType st = new SlotStatusType();
            st.setIndex(nextST.getIndex());
            st.setCardAvailable(Boolean.FALSE);
            s.getSlotStatus().add(st);
        }
        // add new deleted terminal type to states list
        states.add(s);
    }
    this.result = states;
    return states;
}
Also used : ArrayList(java.util.ArrayList) IFDStatusType(iso.std.iso_iec._24727.tech.schema.IFDStatusType) SlotStatusType(iso.std.iso_iec._24727.tech.schema.SlotStatusType)

Example 12 with SlotStatusType

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

the class IFDStatusDiff method diff.

public void diff(List<IFDStatusType> others, boolean withNew) {
    result = new LinkedList<IFDStatusType>();
    deleted = new LinkedList<IFDStatusType>(expected);
    for (IFDStatusType next : others) {
        String nextName = next.getIFDName();
        if (expectedContains(nextName)) {
            // check for terminal connection
            IFDStatusType other = expectedGet(nextName);
            Boolean otherCard = other.isConnected();
            boolean otherCardB = (otherCard == null) ? false : otherCard.booleanValue();
            Boolean thisCard = next.isConnected();
            boolean thisCardB = (thisCard == null) ? false : thisCard.booleanValue();
            if (thisCardB != otherCardB) {
                result.add(next);
            } else {
                // check for card insertions or removals
                if (other.getSlotStatus().size() == next.getSlotStatus().size()) {
                    for (SlotStatusType nextSlot : next.getSlotStatus()) {
                        BigInteger thisSlotIdx = nextSlot.getIndex();
                        SlotStatusType otherSlot = null;
                        for (SlotStatusType nextOtherSlot : other.getSlotStatus()) {
                            if (thisSlotIdx.equals(nextOtherSlot.getIndex())) {
                                otherSlot = nextOtherSlot;
                                break;
                            }
                        }
                        // no equivalent slot, only occurs on evolving terminals ;-)
                        if (otherSlot == null) {
                            result.add(next);
                            break;
                        }
                        // compare card status of slot
                        if (nextSlot.isCardAvailable() != otherSlot.isCardAvailable()) {
                            result.add(next);
                            break;
                        }
                        // compare if there are different cards in slot
                        byte[] nextATR = nextSlot.getATRorATS();
                        byte[] otherATR = otherSlot.getATRorATS();
                        if (!(nextATR == null && otherATR == null) && !(IFDStatusDiff.arrayEquals(nextATR, otherATR))) {
                            result.add(next);
                            break;
                        }
                    }
                }
            }
            // delete card from deleted list
            deleted.remove(expectedGet(nextName));
        } else if (withNew) {
            result.add(next);
        }
    }
    merge(deleted);
}
Also used : BigInteger(java.math.BigInteger) IFDStatusType(iso.std.iso_iec._24727.tech.schema.IFDStatusType) SlotStatusType(iso.std.iso_iec._24727.tech.schema.SlotStatusType)

Aggregations

SlotStatusType (iso.std.iso_iec._24727.tech.schema.SlotStatusType)12 IFDStatusType (iso.std.iso_iec._24727.tech.schema.IFDStatusType)9 BigInteger (java.math.BigInteger)4 Nonnull (javax.annotation.Nonnull)4 SCIOException (org.openecard.common.ifd.scio.SCIOException)4 ArrayList (java.util.ArrayList)3 NoSuchTerminal (org.openecard.common.ifd.scio.NoSuchTerminal)3 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)2 SingleThreadChannel (org.openecard.ifd.scio.wrapper.SingleThreadChannel)2 ChannelHandleType (iso.std.iso_iec._24727.tech.schema.ChannelHandleType)1 GetStatus (iso.std.iso_iec._24727.tech.schema.GetStatus)1 GetStatusResponse (iso.std.iso_iec._24727.tech.schema.GetStatusResponse)1 IFDCapabilitiesType (iso.std.iso_iec._24727.tech.schema.IFDCapabilitiesType)1 WaitResponse (iso.std.iso_iec._24727.tech.schema.WaitResponse)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 FutureTask (java.util.concurrent.FutureTask)1 Result (oasis.names.tc.dss._1_0.core.schema.Result)1