KeyChainException
From Real Software Documentation
Class (inherits from RuntimeException)
| This class is only available on the OS X platform. For cross-platform development, use #If...#Endif with the Target... specifiers to make sure you will not attempt to use this class on an incompatible platform. |
A method of the KeyChain or KeyChainItem classes failed. See the error code returned by KeyChainException to diagnose the problem.
| Properties | |||
|
Notes
The following tables shows the values of ErrorNumber and the associated text returned in the Message property.
| Error Number | Message |
|---|---|
| -128 | User Cancelled. |
| -25291 | Key Chain not available. |
| -25292 | Key Chain read only. |
| -25293 | Key Chain Authorization failed. |
| -25294 | No such Key Chain. |
| -25295 | Invalid Key Chain. |
| -25296 | Duplicate Key Chain. |
| -25797 | Key Chain Duplicate Callback. |
| -25298 | Key Chain Invalid Callback. |
| -25299 | Key Chain Duplicate Item. |
| -25300 | Key Chain Item Not Found. |
| -25301 | Key Chain Buffer Too Small. |
| -25302 | Key Chain Data Too Large. |
| -25303 | Key Chain No Such Attribute. |
| -25304 | Key Chain Invalid Item Reference. |
| -25305 | Key Chain Invalid Search Reference. |
| -25306 | Key Chain No Such Class. |
| -25307 | No Default Key Chain. |
| -25308 | Key Chain Interaction Not Allowed. |
| -25309 | Key Chain Read Only Attribute. |
| -25310 | Wrong Key Chain Version. |
| -25311 | Key Chain Key Size Not Allowed. |
| -25312 | Key Chain No Storage Module. |
| -25313 | Key Chain No Certificate Module. |
| -25314 | Key Chain No Policy Module. |
| -25315 | Key Chain Interaction Required. |
| -25316 | Key Chain Data Not Available. |
| -25317 | Key Chain Data Not Modifiable. |
| -25318 | Key Chain Create Chain Failed. |
Examples
The following example displays a message box if, for example, you try to create more than one KeyChainItem for the same application.
Dim NewItem as KeyChainItem
If System.KeyChainCount > 0 then
NewItem = New KeyChainItem
'Indicate the name of the application
NewItem.ServiceName = "MyApplication"
'Create a new keychain item for the application and assign the password
System.KeyChain.AddPassword NewItem, "SecretPassword"
Else
Beep
MsgBox "You don't have a key chain."
End if
Exception err as KeyChainException
MsgBox err.Message+". Error Code: "+Str(err.errorNumber)
If System.KeyChainCount > 0 then
NewItem = New KeyChainItem
'Indicate the name of the application
NewItem.ServiceName = "MyApplication"
'Create a new keychain item for the application and assign the password
System.KeyChain.AddPassword NewItem, "SecretPassword"
Else
Beep
MsgBox "You don't have a key chain."
End if
Exception err as KeyChainException
MsgBox err.Message+". Error Code: "+Str(err.errorNumber)
The following example uses an Exception block to display a message box if the application specified by ServiceName does not have a KeyChainItem.
Dim ItemToFind as KeyChainItem
Dim password As String
ItemToFind = New KeyChainItem
'Indicate the name of the application whose keychain item you wish to find
ItemToFind.ServiceName = "MyApplication"
'get application's password from the system keychain
password = System.KeyChain.FindPassword(ItemToFind)
MsgBox "The password for this item is: " + password
Exception err as KeyChainException
MsgBox "Can't find item: " + err.Message
Dim password As String
ItemToFind = New KeyChainItem
'Indicate the name of the application whose keychain item you wish to find
ItemToFind.ServiceName = "MyApplication"
'get application's password from the system keychain
password = System.KeyChain.FindPassword(ItemToFind)
MsgBox "The password for this item is: " + password
Exception err as KeyChainException
MsgBox "Can't find item: " + err.Message
See Also
KeyChain, KeyChainItem, RuntimeException classes; System module.
