public DeviceManager(SmartCardParams smartCardParams, ParameterSet parameterSet, bool useVirtualDevice = true)
 {
   this.UseVirtualDevice = useVirtualDevice;
   this.parameterSet = parameterSet;
   if (smartCardParams == null)
   {
     this.smartCardParam = new SmartCardParams("1234", 1, 0, 1);
   }
   else
   {
     this.smartCardParam = smartCardParams;
   }
 }
Exemple #2
0
 public DeviceManager(SmartCardParams smartCardParams, ParameterSet parameterSet, bool useVirtualDevice = true)
 {
     this.UseVirtualDevice = useVirtualDevice;
     this.parameterSet     = parameterSet;
     if (smartCardParams == null)
     {
         this.smartCardParam = new SmartCardParams("1234", 1, 0, 1);
     }
     else
     {
         this.smartCardParam = smartCardParams;
     }
 }
Exemple #3
0
        /// <summary>
        /// Constructs a new SampleDevice instance.
        /// </summary>
        /// <param name="gq">The group construction.</param>
        /// <param name="gd">The device generator.</param>
        public SmartCardDevice(GroupDescription gq, GroupElement gd, SmartCardParams smartCardParam)
        {
            pin      = smartCardParam.pin;
            credID   = smartCardParam.credID;
            groupID  = smartCardParam.groupID;
            proverID = smartCardParam.proverID;

            // As SnartCardDevice do not provide a way to lookup card readr names
            // we provide a small potion of logic to lookup a card and cardreader
            List <CardInfo> cardInfoList = SmartCardUtils.GetReaderNames();
            // loop until we find a card with the status of "working mode". if none found
            // throw
            String readerName = null;

            foreach (CardInfo i in cardInfoList)
            {
                if (i.CardMode == (int)CardMode.WORKING)
                {
                    readerName = i.ReaderName;
                    break;
                }
            }
            if (readerName == null)
            {
                // TODO create a better exception
                throw new Exception("No card founds in working mode");
            }
            bool doTimeProfile = ParseConfigManager.DoTimeProfile();

            this.device = new SmartCard(readerName, pin, doTimeProfile);
            // As the group and generator is set from the java init service we will only verify
            // TODO fix to see that group 0 is set on the hw smartcard.
            //if (!this.device.IsGeneratorSet(groupID))
            //{
            // TODO Find better exception
            // throw new Exception("No generator is set on the card to use this group");
            //}

            this.Gq = gq;
            this.Gd = gd;
        }
    /// <summary>
    /// Constructs a new SampleDevice instance.
    /// </summary>
    /// <param name="gq">The group construction.</param>
    /// <param name="gd">The device generator.</param>
    public SmartCardDevice(GroupDescription gq, GroupElement gd, SmartCardParams smartCardParam)
    {
      pin = smartCardParam.pin;
      credID = smartCardParam.credID;
      groupID = smartCardParam.groupID;
      proverID = smartCardParam.proverID;
     
      // As SnartCardDevice do not provide a way to lookup card readr names
      // we provide a small potion of logic to lookup a card and cardreader
      List<CardInfo> cardInfoList = SmartCardUtils.GetReaderNames();
      // loop until we find a card with the status of "working mode". if none found
      // throw
      String readerName = null;
      foreach (CardInfo i in cardInfoList)
      {
        if (i.CardMode == (int)CardMode.WORKING)
        {
          readerName = i.ReaderName;
          break;
        }
      }
      if (readerName == null)
      {
        // TODO create a better exception
        throw new Exception("No card founds in working mode");
      }
      bool doTimeProfile = ParseConfigManager.doTimeProfile();
      this.device = new SmartCard(readerName, pin, doTimeProfile);
      // As the group and generator is set from the java init service we will only verify
      // TODO fix to see that group 0 is set on the hw smartcard.
      //if (!this.device.IsGeneratorSet(groupID))
      //{
        // TODO Find better exception
       // throw new Exception("No generator is set on the card to use this group");
      //}

      this.Gq = gq;
      this.Gd = gd;
    }