Class: LiveIdentity
- Inherits:
-
Object
show all
- Includes:
- IDCRL::Constants
- Defined in:
- lib/live_identity.rb,
lib/live_identity/version.rb,
lib/live_identity/idcrl/enums.rb,
lib/live_identity/idcrl/hresult.rb,
lib/live_identity/idcrl/structs.rb,
lib/live_identity/idcrl/constants.rb,
lib/live_identity/idcrl.rb
Defined Under Namespace
Modules: IDCRL
Classes: Identities, Identity, LiveIdentityError
Constant Summary
collapse
- VERSION =
'0.1.0'
IDCRL::Constants::MaxLiveIDLength, IDCRL::Constants::MaxLivePasswordLength, IDCRL::Constants::PPCRL_CREDPROPERTY_BRANDIDLIST, IDCRL::Constants::PPCRL_CREDPROPERTY_CID, IDCRL::Constants::PPCRL_CREDPROPERTY_ISDOMAINUSER, IDCRL::Constants::PPCRL_CREDPROPERTY_ISWINLIVEUSER, IDCRL::Constants::PPCRL_CREDPROPERTY_MAINBRANDID, IDCRL::Constants::PPCRL_CREDPROPERTY_MEMBER_NAME, IDCRL::Constants::PPCRL_CREDPROPERTY_ONETIMECREDENTIAL, IDCRL::Constants::PPCRL_CREDPROPERTY_PUIDSTR, IDCRL::Constants::PPCRL_CREDTYPE_ACTIVE, IDCRL::Constants::PPCRL_CREDTYPE_MEMBERNAMEONLY, IDCRL::Constants::PPCRL_CREDTYPE_PASSWORD, IDCRL::Constants::PPCRL_CREDTYPE_VIRUTUALAPP, IDCRL::Constants::PPCRL_PROPERTY_FEDERATIONBRANDNAME
Class Method Summary
collapse
Instance Method Summary
collapse
-
#GetExtendedProperty(property) ⇒ Object
-
#GetIdentities(cachedCredType) ⇒ Object
-
#GetIdentity(memberName, flags) ⇒ Object
-
#GetUserExtendedProperty(userName, name) ⇒ Object
-
#initialize(guid, version, flags, options) ⇒ LiveIdentity
constructor
A new instance of LiveIdentity.
-
#RemoveChangeNotificationCallback ⇒ Object
-
#SetChangeNotificationCallback(virtualApp, callBackFunction) ⇒ Object
-
#SetExtendedProperty(property, value) ⇒ Object
-
#SetIdcrlOptions(options, flags) ⇒ Object
-
#SetUserExtendedProperty(userName, name, value) ⇒ Object
Constructor Details
#initialize(guid, version, flags, options) ⇒ LiveIdentity
Returns a new instance of LiveIdentity.
64
65
66
67
68
69
70
71
72
73
74
75
|
# 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
|
Class Method Details
.finalize ⇒ Object
77
78
79
|
# File 'lib/live_identity.rb', line 77
def self.finalize()
Proc.new { IDCRL.Uninitialize() }
end
|
.FreeMemory(pMemoryToFree) ⇒ Object
.GetServiceConfig(valueName) ⇒ Object
113
114
115
116
117
118
119
120
121
122
|
# 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
|
.isAvailable? ⇒ Boolean
60
61
62
|
# File 'lib/live_identity.rb', line 60
def self.isAvailable?
defined?(IDCRL.InitializeEx)
end
|
.IsError?(hr) ⇒ Boolean
11
12
13
|
# File 'lib/live_identity.rb', line 11
def self.IsError?(hr)
WinCommon::Errors::HRESULT::IsError?(hr)
end
|
.processOptions(options) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# 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) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# 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
|
.VerifyCertificate(certSet, minTTL) ⇒ Object
86
87
88
89
90
91
92
93
94
|
# 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
|
.waitFor(pr, errorText, time = 20, wait = 0.2) ⇒ Object
51
52
53
54
55
56
57
58
|
# 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
|
Instance Method Details
#GetExtendedProperty(property) ⇒ Object
103
104
105
106
107
108
109
110
111
|
# 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) ⇒ Object
162
163
164
|
# File 'lib/live_identity.rb', line 162
def GetIdentities(cachedCredType)
Identities.new(cachedCredType)
end
|
#GetIdentity(memberName, flags) ⇒ Object
166
167
168
|
# File 'lib/live_identity.rb', line 166
def GetIdentity(memberName, flags)
Identity.new(memberName, flags)
end
|
#GetUserExtendedProperty(userName, name) ⇒ Object
140
141
142
143
144
145
146
147
148
149
|
# 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 ⇒ Object
#SetChangeNotificationCallback(virtualApp, callBackFunction) ⇒ Object
151
152
153
154
155
|
# 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) ⇒ Object
#SetIdcrlOptions(options, flags) ⇒ Object
#SetUserExtendedProperty(userName, name, value) ⇒ Object