Class: Sphragis::Providers::FortifyProvider
Instance Attribute Summary
Attributes inherited from BaseProvider
#config
Instance Method Summary
collapse
#connected?, #provider_name
Constructor Details
Initialize Fortify provider with hardware token configuration
16
17
18
19
20
21
22
23
24
|
# File 'lib/sphragis/providers/fortify_provider.rb', line 16
def initialize(config = {})
super
@config = {
library_path: config[:library_path] || Sphragis.configuration.fortify_library_path,
token_pin: config[:token_pin] || Sphragis.configuration.token_pin,
token_slot: config[:token_slot] || Sphragis.configuration.token_slot,
certificate_label: config[:certificate_label] || Sphragis.configuration.certificate_label
}
end
|
Instance Method Details
#certificate ⇒ Object
59
60
61
62
63
|
# File 'lib/sphragis/providers/fortify_provider.rb', line 59
def certificate
raise ProviderError, "Not connected to Fortify token" unless connected?
simulate_certificate
end
|
#connect ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/sphragis/providers/fortify_provider.rb', line 26
def connect
validate_configuration!
@session = {
connected: true,
slot: @config[:token_slot],
provider: "fortify"
}
true
rescue StandardError => e
raise ProviderError, "Failed to connect to Fortify token: #{e.message}"
end
|
#disconnect ⇒ Object
41
42
43
44
|
# File 'lib/sphragis/providers/fortify_provider.rb', line 41
def disconnect
@session = nil
true
end
|
#sign(data) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/sphragis/providers/fortify_provider.rb', line 46
def sign(data)
raise ProviderError, "Not connected to Fortify token" unless connected?
simulate_signing(data)
rescue StandardError => e
raise ProviderError, "Failed to sign data with Fortify: #{e.message}"
end
|
#validate_configuration! ⇒ Object
65
66
67
68
|
# File 'lib/sphragis/providers/fortify_provider.rb', line 65
def validate_configuration!
raise ProviderError, "Fortify library path not configured" if @config[:library_path].nil?
raise ProviderError, "Token PIN not configured" if @config[:token_pin].nil?
end
|