コード例 #1
0
        public string WithTokenInfo(ITokenInfoExtended tokenInfo)
        {
            string tokenModel   = $"Rutoken {tokenInfo.TokenClass}";
            var    serialNumber = int.Parse(tokenInfo.SerialNumber, System.Globalization.NumberStyles.HexNumber).ToString();

            return(string.Format(Resources.TokenSerialNumber, serialNumber) + "\n" +
                   string.Format(Resources.TokenModel, tokenModel) + "\n" +
                   string.Format(Resources.Memory, tokenInfo.FreeMemory, tokenInfo.TotalMemory) + "\n" +
                   string.Format(Resources.UserPinLength, tokenInfo.MinUserPinLen, tokenInfo.MaxUserPinLen) + "\n" +
                   string.Format(Resources.AdminPinLength, tokenInfo.MinAdminPinLen, tokenInfo.MaxAdminPinLen) + "\n" +
                   string.Format(Resources.UserPinAttempts, tokenInfo.UserRetryCountLeft, tokenInfo.MaxUserRetryCount) + "\n" +
                   string.Format(Resources.AdminPinAttempts, tokenInfo.AdminRetryCountLeft, tokenInfo.MaxAdminRetryCount));
        }
コード例 #2
0
        public void _HL_04_02_TokenInfoExtendedTest()
        {
            using (var pkcs11 = Settings.Factories.RutokenPkcs11LibraryFactory.LoadRutokenPkcs11Library(Settings.Factories, Settings.Pkcs11LibraryPath, Settings.AppType))
            {
                // Find first slot with token present
                var slot = Helpers.GetUsableSlot(pkcs11);

                // Get token info
                ITokenInfoExtended tokenInfo = slot.GetTokenInfoExtended();

                // Do something interesting with token info
                Assert.IsFalse(String.IsNullOrEmpty(tokenInfo.SerialNumber));
            }
        }