Class: Sphragis::Providers::ItsmeProvider
Overview
Itsme.free Provider
Free e-signature service (hypothetical - adjust based on actual service)
Note: This is a template implementation. Adjust based on actual Itsme.free API
Constant Summary
collapse
- ITSME_API_BASE =
"https://api.itsme.free/v1"
Instance Attribute Summary
Attributes inherited from BaseProvider
#config
Instance Method Summary
collapse
#connected?, #provider_name
Constructor Details
#initialize(config = {}) ⇒ ItsmeProvider
Initialize Itsme.free provider
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/sphragis/providers/itsme_provider.rb', line 24
def initialize(config = {})
super
@config = {
client_id: config[:client_id],
client_secret: config[:client_secret],
user_email: config[:user_email],
environment: config[:environment] || "production"
}
@api_base = @config[:environment] == "sandbox" ? "#{ITSME_API_BASE}/sandbox" : ITSME_API_BASE
end
|
Instance Method Details
#certificate ⇒ Object
81
82
83
84
85
86
|
# File 'lib/sphragis/providers/itsme_provider.rb', line 81
def certificate
raise ProviderError, "Not connected to Itsme" unless connected?
simulate_itsme_certificate
end
|
#check_signing_status(session_id) ⇒ Hash
123
124
125
126
127
128
129
130
|
# File 'lib/sphragis/providers/itsme_provider.rb', line 123
def check_signing_status(session_id)
{
session_id: session_id,
status: "completed",
signature: simulate_itsme_signing("data")
}
end
|
#connect ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/sphragis/providers/itsme_provider.rb', line 35
def connect
validate_configuration!
response = authenticate_with_itsme
@private_key = OpenSSL::PKey::RSA.generate(2048)
@signing_cert = build_self_signed_cert
@session = {
connected: true,
provider: "itsme",
access_token: response[:access_token],
refresh_token: response[:refresh_token],
token_expires_at: Time.now + response[:expires_in],
user_email: @config[:user_email]
}
true
rescue StandardError => e
raise ProviderError, "Failed to connect to Itsme: #{e.message}"
end
|
#disconnect ⇒ Object
59
60
61
62
63
64
|
# File 'lib/sphragis/providers/itsme_provider.rb', line 59
def disconnect
@session = nil
true
end
|
#initiate_signing(data) ⇒ Hash
Initiate signing with user interaction
110
111
112
113
114
115
116
117
118
|
# File 'lib/sphragis/providers/itsme_provider.rb', line 110
def initiate_signing(data)
{
session_id: SecureRandom.uuid,
confirmation_url: "#{@api_base}/sign/#{SecureRandom.uuid}",
expires_at: Time.now + 300,
status: "pending"
}
end
|
#sign(data) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/sphragis/providers/itsme_provider.rb', line 66
def sign(data)
raise ProviderError, "Not connected to Itsme" unless connected?
refresh_token_if_needed
simulate_itsme_signing(data)
rescue StandardError => e
raise ProviderError, "Failed to sign with Itsme: #{e.message}"
end
|
#sign_bytes(hash) ⇒ Object
94
95
96
97
98
99
|
# File 'lib/sphragis/providers/itsme_provider.rb', line 94
def sign_bytes(hash)
raise ProviderError, "Not connected to Itsme" unless connected?
@private_key.sign_raw("SHA256", hash)
end
|
#validate_configuration! ⇒ Object
88
89
90
91
92
|
# File 'lib/sphragis/providers/itsme_provider.rb', line 88
def validate_configuration!
raise ProviderError, "Itsme client ID not configured" if @config[:client_id].nil?
raise ProviderError, "Itsme client secret not configured" if @config[:client_secret].nil?
raise ProviderError, "User email not configured" if @config[:user_email].nil?
end
|
#x509_certificate ⇒ Object
101
102
103
104
105
|
# File 'lib/sphragis/providers/itsme_provider.rb', line 101
def x509_certificate
raise ProviderError, "Not connected to Itsme" unless connected?
@signing_cert
end
|