A newer version of this documentation is available.

View Latest

Scripting

There are four functions available via the scripting interface.

GetProperty

String GetProperty(String name)

This function is used to get different properties from the plugin. The properties may be static like the plugin version or dynamic as a result from a signature operation. The name is the name of the property and the result is either a string describing the property or empty string if property is not available.

The following list of properties is available, for descriptions see Operations:

  • ActiveSlot

  • ActiveToken

  • Certificate

  • CertificateInfo

  • ConfigFileGlobal

  • ConfigFileLocal

  • Config:

  • ConfigGlobal:<section>:<entry>

  • ConfigLocal:<section>:<entry>

  • ComponentConfig:<section>:<entry>

  • CryptoEngine

  • Data

  • Error <number>

  • FileName

  • HaveSlotEvent

  • Issuer

  • KeyUsage

  • LoggedIn

  • Random

  • Request

  • RunningProtectedMode*

  • Signature

  • Subject

  • TokenData

  • TokenInfo

  • Version

*) This property is only available on Windows platforms.

SetProperty

void SetProperty(String name, String value)

This function is used to set the properties required for a specific operation. The name is the name of the property and value is the value of the property. Unknown properties or invalid property values will be ignored and there is no result value.

The following list of properties is available; the meaning of each property will be described in the operation in which it will be used:

  • ActiveSlot

  • ActiveToken

  • Algorithm

  • AllowExternalCert

  • AppendCert

  • Authentication

  • Base64

  • Certificate

  • CertificateLabel

  • CKA_<name>

  • Command

  • Config:<section>:<entry>

  • ConfigGlobal:<section>:<entry>

  • ConfigLocal:<section>:<entry>

  • ComponentConfig:<section>:<entry>

  • Data

  • DataReturnName

  • DataToBeSigned

  • DataURL

  • Detached

  • ExpectedVersion

  • Extractable

  • FileName

  • ImportPassword

  • IncludeCaCert

  • IncludeRootCaCert

  • InvokeWait

  • Issuers

  • Key

  • KeyId

  • KeyLabel

  • KeyReuse

  • KeySize

  • KeyUsage

  • Label

  • Link

  • Name

  • NewPassword

  • MIME

  • MoreData

  • MoreDataToBeSigned

  • OneTimePassword

  • Other

  • Password

  • PasswordMinLen

  • PasswordMaxLen

  • PasswordType

  • PostURL

  • Profile

  • PrivateData

  • PublicData

  • PubKey

  • Raw

  • RenewMode

  • RequestInfo

  • RequestType

  • Seed

  • Signature

  • SignReturnName

  • Subject

  • Subjects

  • SubjectAltName

  • Template

  • Text

  • Title

  • TokenData

  • TokenLabel

  • Type

  • UnlockPassword

  • URLEncode

  • User

  • Value

  • Version

  • VersionReturnName

  • WindowName

EnumProperty

String EnumProperty(String name, String index)

This function is used to enumerate properties from the plugin. The difference between this function and GetProperty function is this function may have several available property values. For example, this function is used to enumerate all available smart card readers, it is not known how many will be available.

The name is the name of the property and index is the index number of the property, starting from ‘0’. The function will return the value of the desired property and an empty string when no more values are available.

The following list of properties is available for enumeration, for description see Enumeration properties

  • Certificate

  • CertificateEx

  • Component

  • Key

  • Language

  • Profile

  • Slot

  • SlotCard

  • SlotSoft

  • Token

  • TokenCard

  • TokenSoft

Invoke

int Invoke(String name)

This function is used to initiate an operation. The name is the name of the desired operation. The operation may require one or more properties; see section describing each operation for details.

The same property may be used by several different operations, for example current active slot. To avoid any undesirable effects when reusing the same plugin object for several different operations it is recommended to always start the scripting with invoke the ‘Reset’ operation:

iid = document.getElementById(‘iid’);
if (iid != null) {
  iid.Invoke(‘Reset’);
  iid.SetProperty(‘Property 1’, ‘Value 1’);
  iid.SetProperty(‘Property 2’, ‘Value 2’);
  iid.SetProperty(‘Property 3’, ‘Value 3’);
  err = iid.Invoke(‘Operation’);
}

The following operations are available:

  • ApplyConfig

  • ApplyComponentConfig:<name>

  • ChangePassword

  • CreateObject

  • CreateRequest

  • CreateToken

  • Decrypt

  • DeleteCertificate

  • DeleteKey

  • DeleteToken

  • DestroyObject

  • Digest

  • DisableTrace

  • EnableTrace

  • Encrypt

  • Export

  • FindObject

  • GenerateChallenge

  • HasCertificate

  • InitToken

  • IsRefreshing*

  • Login

  • Logout

  • OpenTrace*

  • Refresh

  • RefreshInternal

  • RefreshService*

  • Reload

  • Reset

  • ResetToken

  • ResetUserData

  • RestoreComponentConfig: <name>

  • Run*

  • Sign

  • ShowMessage*

  • StartService*

  • StopService*

  • UnlockPassword

  • UpdateObject

  • ValidateInstallation

  • ValidatePassword

  • Verify

  • ViewCertificate*

  • WriteCertificate

  • WriteKey

*) This operation is only available on Windows platforms.

The list of available operations will change over time, some new will be added and some may be removed. The operations available on all platforms will probably always be available.

There are already problems with displaying of user interface for the plugin, so all operations that require displaying of user interface are considered obsolete and will be removed in the future. As a result the operation ‘ShowMessage’ will be completely removed and also the options to display user interface for ‘ChangePassword’, ‘UnlockPassword’ and ’Login’. The last three may still be used with parameters sent via SetProperty.