Module: Sec
- Extended by:
- FFI::Library
- Defined in:
- lib/keychain/sec.rb,
lib/keychain/item.rb,
lib/keychain/error.rb,
lib/keychain/keychain.rb
Overview
The module to which FFI attaches constants
Defined Under Namespace
Modules: Classes, Query, Search, Value Classes: Base, KeychainSettings
Constant Summary collapse
- ATTR_MAP =
map of kSecAttr* constants to the corresponding ruby name for the attribute Used in Keychain::Item#attributes}
{ CF::Base.typecast(kSecAttrAccess) => :access, CF::Base.typecast(kSecAttrAccount) => :account, CF::Base.typecast(kSecAttrAuthenticationType) => :authentication_type, CF::Base.typecast(kSecAttrComment) => :comment, CF::Base.typecast(kSecAttrCreationDate) => :created_at, CF::Base.typecast(kSecAttrCreator) => :creator, CF::Base.typecast(kSecAttrDescription) => :description, CF::Base.typecast(kSecAttrGeneric) => :generic, CF::Base.typecast(kSecAttrIsInvisible) => :invisible, CF::Base.typecast(kSecAttrIsNegative) => :negative, CF::Base.typecast(kSecAttrLabel) => :label, CF::Base.typecast(kSecAttrModificationDate) => :updated_at, CF::Base.typecast(kSecAttrPath) => :path, CF::Base.typecast(kSecAttrPort) => :port, CF::Base.typecast(kSecAttrProtocol) => :protocol, CF::Base.typecast(kSecAttrSecurityDomain) => :security_domain, CF::Base.typecast(kSecAttrServer) => :server, CF::Base.typecast(kSecAttrService) => :service, CF::Base.typecast(kSecAttrType) => :type, CF::Base.typecast(kSecClass) => :klass }
- INVERSE_ATTR_MAP =
Inverse of ATTR_MAP
ATTR_MAP.invert
Class Method Summary collapse
-
.check_osstatus(result) ⇒ Object
If the result is non-zero raises an exception.
Class Method Details
.check_osstatus(result) ⇒ Object
If the result is non-zero raises an exception.
The exception will have the result code as well as a human readable description
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/keychain/sec.rb', line 147 def self.check_osstatus result if result != 0 case result when Sec.enum_value(:errSecDuplicateItem) raise Keychain::DuplicateItemError.new(result) when Sec.enum_value(:errCancelled) raise Keychain::UserCancelledError.new(result) when Sec.enum_value(:errSecAuthFailed) raise Keychain::AuthFailedError.new(result) when Sec.enum_value(:errSecNoSuchKeychain) raise Keychain::NoSuchKeychainError.new(result) else raise Keychain::Error.new(result) end end end |