class LiveIdentity
Constants
- VERSION
Public Class Methods
FreeMemory(pMemoryToFree)
click to toggle source
# File lib/live_identity.rb, line 81 def self.FreeMemory(pMemoryToFree) hr = IDCRL.PassportFreeMemory(pMemoryToFree) raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) end
GetServiceConfig(valueName)
click to toggle source
# File lib/live_identity.rb, line 113 def self.GetServiceConfig(valueName) wszValueName = StringToWSTR(valueName) szUrlValue = FFI::MemoryPointer.new(:PLPWSTR) hr = IDCRL.GetServiceConfig(wszValueName, szUrlValue) raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) return nil if szUrlValue.read_pointer.null? urlValue = read_wide_string(szUrlValue.read_pointer) LiveIdentity::FreeMemory(szUrlValue.read_pointer) urlValue end
IsError?(hr)
click to toggle source
# File lib/live_identity.rb, line 11 def self.IsError?(hr) WinCommon::Errors::HRESULT::IsError?(hr) end
VerifyCertificate(certSet, minTTL)
click to toggle source
# File lib/live_identity.rb, line 86 def self.VerifyCertificate(certSet, minTTL) dwMinTTL = FFI::MemoryPointer.new(:DWORD) dwMinTTL.write_uint(minTTL) pCACertContext = FFI::MemoryPointer.new(:PCERT_CONTEXT) hr = IDCRL.VerifyCertificate(certSet[:pCertContext], dwMinTTL, certSet[:pbPOP], certSet[:cbPOP], pCACertContext) certSet[:pCACertContext] = pCACertContext.read_pointer certSet.CACertContext raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) end
finalize()
click to toggle source
# File lib/live_identity.rb, line 77 def self.finalize() Proc.new { IDCRL.Uninitialize() } end
isAvailable?()
click to toggle source
# File lib/live_identity.rb, line 60 def self.isAvailable? defined?(IDCRL.InitializeEx) end
new(guid, version, flags, options)
click to toggle source
# File lib/live_identity.rb, line 64 def initialize(guid, version, flags, options) raise 'IDCRL isn\'t available!' unless LiveIdentity::isAvailable? guidClientApplication = IDCRL::GUID.new guidClientApplication.from_str(guid) lPPCRLVersion = version dwFlags = flags dwOptions = options.count pOptions = LiveIdentity::processOptions(options) hr = IDCRL.InitializeEx(guidClientApplication, lPPCRLVersion, dwFlags, pOptions, dwOptions) raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) ObjectSpace.define_finalizer( self, self.class.finalize() ) end
processOptions(options)
click to toggle source
# File lib/live_identity.rb, line 15 def self.processOptions(options) pOptions = nil if options.count > 0 pOptions = FFI::MemoryPointer.new(IDCRL::IDCRL_OPTION, options.count) i = 0 options.each do |id, value| option = IDCRL::IDCRL_OPTION.new(pOptions + i * IDCRL::IDCRL_OPTION.size) option[:dwId] = id option[:pValue] = FFI::MemoryPointer.new(:pointer) if value.is_a?(String) data = StringToWSTR(value) option[:pValue].write_string(data) option[:cbValue] = data.bytesize elsif value.is_a?(Fixnum) option[:pValue].write_int(data) option[:cbValue] = 4 else raise "Uknown value type #{value.inspect}" end i += 1 end end pOptions end
processRSTParams(params)
click to toggle source
# File lib/live_identity.rb, line 40 def self.processRSTParams(params) pRSTParams = nil if params.count > 0 pRSTParams = FFI::MemoryPointer.new(IDCRL::RSTParams, params.count) params.each_index do |i| IDCRL::RSTParams.build(params[i], pRSTParams + i * IDCRL::RSTParams.size) end end pRSTParams end
waitFor(pr, errorText, time = 20, wait = 0.2) { || ... }
click to toggle source
# File lib/live_identity.rb, line 51 def self.waitFor(pr, errorText, time = 20, wait = 0.2) Timeout::timeout(time) do while !pr.call do sleep(wait) end end rescue Timeout::Error yield raise errorText end
Public Instance Methods
GetExtendedProperty(property)
click to toggle source
# File lib/live_identity.rb, line 103 def GetExtendedProperty(property) wszPropertyName = StringToWSTR(property) wszPropertyValue = FFI::MemoryPointer.new(:PLPWSTR) hr = IDCRL.GetExtendedProperty(wszPropertyName, wszPropertyValue) raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) propertyValue = read_wide_string(wszPropertyValue.read_pointer) LiveIdentity::FreeMemory(wszPropertyValue.read_pointer) propertyValue end
GetIdentities(cachedCredType)
click to toggle source
# File lib/live_identity.rb, line 162 def GetIdentities(cachedCredType) Identities.new(cachedCredType) end
GetIdentity(memberName, flags)
click to toggle source
# File lib/live_identity.rb, line 166 def GetIdentity(memberName, flags) Identity.new(memberName, flags) end
GetUserExtendedProperty(userName, name)
click to toggle source
# File lib/live_identity.rb, line 140 def GetUserExtendedProperty(userName, name) szUserName = StringToWSTR(userName) szPropertyName = StringToWSTR(name) szPropertyValue = FFI::MemoryPointer.new(:PLPWSTR) hr = IDCRL.GetUserExtendedProperty(szUserName, szPropertyName, szPropertyValue) raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) propertyValue = read_wide_string(szPropertyValue.read_pointer) LiveIdentity::FreeMemory(szPropertyValue.read_pointer) propertyValue end
RemoveChangeNotificationCallback()
click to toggle source
# File lib/live_identity.rb, line 157 def RemoveChangeNotificationCallback() hr = IDCRL.RemoveChangeNotificationCallback() raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) end
SetChangeNotificationCallback(virtualApp, callBackFunction)
click to toggle source
# File lib/live_identity.rb, line 151 def SetChangeNotificationCallback(virtualApp, callBackFunction) szVirtualApp = StringToWSTR(virtualApp) hr = IDCRL.SetChangeNotificationCallback(szVirtualApp, nil, callBackFunction) raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) end
SetExtendedProperty(property, value)
click to toggle source
# File lib/live_identity.rb, line 96 def SetExtendedProperty(property, value) wszPropertyName = StringToWSTR(property) wszPropertyValue = StringToWSTR(value) hr = IDCRL.SetExtendedProperty(wszPropertyName, wszPropertyValue) raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) end
SetIdcrlOptions(options, flags)
click to toggle source
# File lib/live_identity.rb, line 124 def SetIdcrlOptions(options, flags) dwOptions = options.count pOptions = LiveIdentity::processOptions(options) dwFlags = flags hr = IDCRL.SetIdcrlOptions(pOptions, dwOptions, dwFlags) raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) end
SetUserExtendedProperty(userName, name, value)
click to toggle source
# File lib/live_identity.rb, line 132 def SetUserExtendedProperty(userName, name, value) szUserName = StringToWSTR(userName) szPropertyName = StringToWSTR(name) szPropertyValue = StringToWSTR(value) hr = IDCRL.SetUserExtendedProperty(szUserName, szPropertyName, szPropertyValue) raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr) end