Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Lianja) ScMinidriver - Get Smartcard PropertiesSee more ScMinidriver ExamplesGets information about the smart card currently inserted in the reader (or USB token). Note: This functionality was introduced in Chilkat v9.5.0.87. Note: The ScMinidriver functionality is for Windows-only because ScMinidriver DLLs only exist on Windows. In the next version, Chilkat will be releasing a Pkcs11 class to support Linux, MacOSX, and possibly other operating systems.
// This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loScmd = createobject("CkScMinidriver") // Reader names (smart card readers or USB tokens) can be discovered // via PCSC List Readers or PCSC Find Smart Cards lcReaderName = "Alcor Micro USB Smart Card Reader 0" llSuccess = loScmd.AcquireContext(lcReaderName) if (llSuccess = .F.) then ? loScmd.LastErrorText release loScmd return endif loJson = createobject("CkJsonObject") loJson.EmitCompact = .F. llSuccess = loScmd.GetCardProperties(loJson) if (llSuccess = .F.) then ? loScmd.LastErrorText release loScmd release loJson return endif ? loJson.Emit() // Here is sample output: // See below for sample code to parse the JSON. // // NOTE: Not all smart cards support all properties. // The GetCardProperties method will return information for all properties supported by the card. // { // "bytesAvailable": 74752, // "containersAvailable": 18, // "maxKeyContainers": 20, // "capabilities": { // "fCertificateCompression": false, // "fKeyGen": true // }, // "keySizes": { // "minimumBitlen": 2048, // "defaultBitlen": 2048, // "maximumBitlen": 4096, // "incrementalBitlen": 1024 // }, // "readOnly": false, // "cacheMode": "global", // "supportsWinX509Enrollment": true, // "guid": "1201803d-03e6-772a-3d80-0112e6032a77", // "serial": "e6032a773d800112e6032a77", // "pins": [ // "user", // "admin", // "role3", // "role4" // ], // "pin": { // "user": { // "type": "regular", // "purpose": "primaryCard", // "changePermission": [ // "user" // ], // "unblockPermission": [ // "admin" // ], // "cachePolicy": "normal", // "policyInfo": "00000000", // "flags": "00000000", // "acceptPlainTextPin": true, // "generateSessionPin": false // }, // "admin": { // "type": "challenge/response", // "purpose": "administrator", // "changePermission": [ // "admin" // ], // "cachePolicy": "normal", // "policyInfo": "00000000", // "flags": "00000000" // }, // "role3": { // "type": "regular", // "purpose": "digitalSignature", // "changePermission": [ // "role3" // ], // "unblockPermission": [ // "role4" // ], // "cachePolicy": "alwaysPrompt", // "policyInfo": "00000000", // "flags": "00000000", // "acceptPlainTextPin": true, // "generateSessionPin": false // }, // "role4": { // "type": "regular", // "purpose": "unblockOnly", // "changePermission": [ // "role4" // ], // "cachePolicy": "normal", // "policyInfo": "00000000", // "flags": "00000000", // "acceptPlainTextPin": true, // "generateSessionPin": false // } // }, // "importSupport": [ // "plainText", // "rsaKeyest", // "eccKeyest", // "symmetric" // ], // "algorithms": [ // "AES" // ], // "paddingSchemes": [ // "block", // "pkcs1", // "pss", // "oaep" // ], // "chainingModes": [ // "ChainingModeCBC" // ] // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON lnBytesAvailable = loJson.IntOf("bytesAvailable") lnContainersAvailable = loJson.IntOf("containersAvailable") lnMaxKeyContainers = loJson.IntOf("maxKeyContainers") llCapabilitiesFCertificateCompression = loJson.BoolOf("capabilities.fCertificateCompression") llCapabilitiesFKeyGen = loJson.BoolOf("capabilities.fKeyGen") lnKeySizesMinimumBitlen = loJson.IntOf("keySizes.minimumBitlen") lnKeySizesDefaultBitlen = loJson.IntOf("keySizes.defaultBitlen") lnKeySizesMaximumBitlen = loJson.IntOf("keySizes.maximumBitlen") lnKeySizesIncrementalBitlen = loJson.IntOf("keySizes.incrementalBitlen") llReadOnly = loJson.BoolOf("readOnly") lcCacheMode = loJson.StringOf("cacheMode") llSupportsWinX509Enrollment = loJson.BoolOf("supportsWinX509Enrollment") lcGuid = loJson.StringOf("guid") lcSerial = loJson.StringOf("serial") lcPinUserType = loJson.StringOf("pin.user.type") lcPinUserPurpose = loJson.StringOf("pin.user.purpose") lcPinUserCachePolicy = loJson.StringOf("pin.user.cachePolicy") lcPinUserPolicyInfo = loJson.StringOf("pin.user.policyInfo") lcPinUserFlags = loJson.StringOf("pin.user.flags") llPinUserAcceptPlainTextPin = loJson.BoolOf("pin.user.acceptPlainTextPin") llPinUserGenerateSessionPin = loJson.BoolOf("pin.user.generateSessionPin") lcPinAdminType = loJson.StringOf("pin.admin.type") lcPinAdminPurpose = loJson.StringOf("pin.admin.purpose") lcPinAdminCachePolicy = loJson.StringOf("pin.admin.cachePolicy") lcPinAdminPolicyInfo = loJson.StringOf("pin.admin.policyInfo") lcPinAdminFlags = loJson.StringOf("pin.admin.flags") lcPinRole3Type = loJson.StringOf("pin.role3.type") lcPinRole3Purpose = loJson.StringOf("pin.role3.purpose") lcPinRole3CachePolicy = loJson.StringOf("pin.role3.cachePolicy") lcPinRole3PolicyInfo = loJson.StringOf("pin.role3.policyInfo") lcPinRole3Flags = loJson.StringOf("pin.role3.flags") llPinRole3AcceptPlainTextPin = loJson.BoolOf("pin.role3.acceptPlainTextPin") llPinRole3GenerateSessionPin = loJson.BoolOf("pin.role3.generateSessionPin") lcPinRole4Type = loJson.StringOf("pin.role4.type") lcPinRole4Purpose = loJson.StringOf("pin.role4.purpose") lcPinRole4CachePolicy = loJson.StringOf("pin.role4.cachePolicy") lcPinRole4PolicyInfo = loJson.StringOf("pin.role4.policyInfo") lcPinRole4Flags = loJson.StringOf("pin.role4.flags") llPinRole4AcceptPlainTextPin = loJson.BoolOf("pin.role4.acceptPlainTextPin") llPinRole4GenerateSessionPin = loJson.BoolOf("pin.role4.generateSessionPin") i = 0 lnCount_i = loJson.SizeOfArray("pins") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("pins[i]") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("pin.user.changePermission") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("pin.user.changePermission[i]") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("pin.user.unblockPermission") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("pin.user.unblockPermission[i]") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("pin.admin.changePermission") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("pin.admin.changePermission[i]") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("pin.role3.changePermission") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("pin.role3.changePermission[i]") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("pin.role3.unblockPermission") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("pin.role3.unblockPermission[i]") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("pin.role4.changePermission") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("pin.role4.changePermission[i]") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("importSupport") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("importSupport[i]") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("algorithms") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("algorithms[i]") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("paddingSchemes") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("paddingSchemes[i]") i = i + 1 enddo i = 0 lnCount_i = loJson.SizeOfArray("chainingModes") do while i < lnCount_i loJson.I = i lcStrVal = loJson.StringOf("chainingModes[i]") i = i + 1 enddo // Delete the context when finished with the card. llSuccess = loScmd.DeleteContext() if (llSuccess = .F.) then ? loScmd.LastErrorText endif release loScmd release loJson |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.