Class: Sphragis::Providers::HaricaProvider
Overview
Harica (Hellenic Academic and Research Institutions CA) Provider Harica provides free digital certificates for academic institutions in Greece and paid certificates for commercial use.
Constant Summary
collapse
- HARICA_API_BASE =
"https://api.harica.gr/v1"
Instance Attribute Summary
Attributes inherited from BaseProvider
#config
Instance Method Summary
collapse
#connected?, #provider_name
Constructor Details
Initialize Harica provider
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/sphragis/providers/harica_provider.rb', line 27
def initialize(config = {})
super
@config = {
api_key: config[:api_key],
certificate_id: config[:certificate_id],
username: config[:username],
password: config[:password],
environment: config[:environment] || "production"
}
@api_base = @config[:environment] == "sandbox" ? "#{HARICA_API_BASE}/sandbox" : HARICA_API_BASE
end
|
Instance Method Details
#certificate ⇒ Object
81
82
83
84
85
86
|
# File 'lib/sphragis/providers/harica_provider.rb', line 81
def certificate
raise ProviderError, "Not connected to Harica" unless connected?
simulate_harica_certificate
end
|
#connect ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/sphragis/providers/harica_provider.rb', line 39
def connect
validate_configuration!
response = authenticate_with_harica
@session = {
connected: true,
provider: "harica",
access_token: response[:access_token],
token_expires_at: Time.now + 3600,
certificate_id: @config[:certificate_id]
}
true
rescue StandardError => e
raise ProviderError, "Failed to connect to Harica: #{e.message}"
end
|
#disconnect ⇒ Object
58
59
60
61
62
63
|
# File 'lib/sphragis/providers/harica_provider.rb', line 58
def disconnect
@session = nil
true
end
|
#service_available? ⇒ Boolean
Check if Harica service is available
96
97
98
99
|
# File 'lib/sphragis/providers/harica_provider.rb', line 96
def service_available?
true
end
|
#sign(data) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/sphragis/providers/harica_provider.rb', line 65
def sign(data)
raise ProviderError, "Not connected to Harica" unless connected?
refresh_token_if_needed
simulate_harica_signing(data)
rescue StandardError => e
raise ProviderError, "Failed to sign with Harica: #{e.message}"
end
|
#validate_configuration! ⇒ Object
88
89
90
91
92
|
# File 'lib/sphragis/providers/harica_provider.rb', line 88
def validate_configuration!
raise ProviderError, "Harica API key not configured" if @config[:api_key].nil?
raise ProviderError, "Harica certificate ID not configured" if @config[:certificate_id].nil?
raise ProviderError, "Harica username not configured" if @config[:username].nil?
end
|