Пример #1
0
        public virtual AC CreateAC(IObjectWithAC dest)
        {
            int numAC = 0;

            if (dest is BSO)
            {
                numAC = 7;
            }
            if (dest is DF)
            {
                numAC = 9;
            }
            if (dest is EF)
            {
                numAC = 9;
            }
            if (dest is SecurityEnvironmenet)
            {
                numAC = 2;
            }
            if (numAC == 0)
            {
                throw new Exception("Oggetto con AC non valido");
            }
            return(new AC(AC.Always, dest, numAC));
        }
Пример #2
0
 public AC(byte allConditions, IObjectWithAC owner, int numAC)
 {
     this.numAC = numAC;
     this.owner = owner;
     conditions = new byte[numAC];
     for (int i = 0; i < numAC; i++)
     {
         conditions[i] = allConditions;
     }
 }
Пример #3
0
 public AC(byte[] conditions, IObjectWithAC owner, int numAC)
 {
     this.numAC = numAC;
     this.owner = owner;
     if (conditions.Length > numAC)
     {
         throw new ISO7816Exception(Error.DataFieldNotValid);
     }
     this.conditions = conditions;
 }
        public bool IsVerifiedAC(ICardObject obj, byte ac)
        {
            if (!(obj is IObjectWithAC))
            {
                throw new ISO7816Exception(Error.InternalError);
            }
            IObjectWithAC acObj     = obj as IObjectWithAC;
            byte          condition = acObj.AC[ac];

            if (condition == AC.Never)
            {
                return(false);
            }
            if (condition == AC.Always)
            {
                return(true);
            }
            BSO refrencedObject = obj is DF ? (obj as DF).GetChildBSO(condition, true) : obj.Parent.GetChildBSO(condition, true);

            if (context.securityStatus.ContainsKey(condition))
            {
                BSO bso = context.securityStatus[condition];
                if (refrencedObject == bso)
                {
                    if (bso.CurValidityCounter == 0)
                    {
                        context.securityStatus.Remove((byte)bso.ID);
                        return(false);
                    }
                    else if (bso.CurValidityCounter != 0xff)
                    {
                        bso.CurValidityCounter--;
                    }
                    return(true);
                }
                return(false);
            }
            else
            {
                // potrebbe essereun logical
                if (refrencedObject == null)
                {
                    return(false);
                }
                if (refrencedObject.Algo == BSOAlgo.Logic)
                {
                    int exprLen;
                    return(TestLogic(refrencedObject, refrencedObject.Data.Length - 1, out exprLen));
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #5
0
 //public override string ToString()
 //{
 //    return "AC for " + (obj as ICardObject).Description;
 //}
 public WrapperSEAC(IObjectWithAC obj)
 {
     this.obj = obj;
 }