Class: Sphragis::Providers::HaricaProvider
- Inherits:
-
BaseProvider
- Object
- BaseProvider
- Sphragis::Providers::HaricaProvider
- Defined in:
- lib/sphragis/providers/harica_provider.rb
Overview
Harica (Hellenic Academic and Research Institutions CA) Provider
Uses Harica's remote document signing API (rsign-api.harica.gr). The API is a full-document cloud signer: you POST the PDF, Harica signs it server-side and returns the complete signed PDF. No local key material is needed. Authentication is per-request via username + password + OTP.
OTP must be supplied per signing call (it rotates every ~30 s). Pass it via PdfSigner options: PdfSigner.new(path, otp: "123456", provider: :harica)
Constant Summary collapse
- PRODUCTION_URL =
"https://rsign-api.harica.gr/dsa/v1/sign"- SANDBOX_URL =
"https://rsign-api-dev.harica.gr/dsa/v1/sign"
Instance Attribute Summary
Attributes inherited from BaseProvider
Instance Method Summary collapse
-
#certificate ⇒ Object
Harica's DSA API does not expose a certificate endpoint; return descriptive metadata derived from the configured username instead.
-
#connect ⇒ Object
Validate credentials are present.
- #disconnect ⇒ Object
-
#initialize(config = {}) ⇒ HaricaProvider
constructor
A new instance of HaricaProvider.
-
#sign(pdf_bytes) ⇒ Hash
Sign a PDF document via Harica's remote signing API.
- #validate_configuration! ⇒ Object
Methods inherited from BaseProvider
Constructor Details
#initialize(config = {}) ⇒ HaricaProvider
Returns a new instance of HaricaProvider.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sphragis/providers/harica_provider.rb', line 26 def initialize(config = {}) super @config = { username: config[:username], password: config[:password], otp: config[:otp], environment: config[:environment] || "production", x: config[:x] || 140, y: config[:y] || 230, width: config[:width] || 150, height: config[:height] || 100, page: config[:page], # nil → send -1 (all pages) to Harica reason: config[:reason] || "", graphical_signature: config[:graphical_signature] || "" } end |
Instance Method Details
#certificate ⇒ Object
Harica's DSA API does not expose a certificate endpoint; return descriptive metadata derived from the configured username instead.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/sphragis/providers/harica_provider.rb', line 76 def certificate raise ProviderError, "Not connected to Harica" unless connected? { provider: "harica", subject: "CN=#{@config[:username]}, O=Harica User", issuer: "CN=HARICA TLS RSA Root CA 2021, O=Hellenic Academic and Research Institutions CA", key_usage: ["digitalSignature", "nonRepudiation"], certificate_type: "qualified" } end |
#connect ⇒ Object
Validate credentials are present. The Harica API is stateless — no persistent session is opened here.
45 46 47 48 49 50 51 |
# File 'lib/sphragis/providers/harica_provider.rb', line 45 def connect validate_configuration! @session = { connected: true, provider: "harica" } true rescue StandardError => e raise ProviderError, "Failed to connect to Harica: #{e.}" end |
#disconnect ⇒ Object
53 54 55 56 |
# File 'lib/sphragis/providers/harica_provider.rb', line 53 def disconnect @session = nil true end |
#sign(pdf_bytes) ⇒ Hash
Sign a PDF document via Harica's remote signing API.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/sphragis/providers/harica_provider.rb', line 62 def sign(pdf_bytes) raise ProviderError, "Not connected to Harica" unless connected? payload = build_payload(pdf_bytes) response = post_to_harica(payload) parse_response(response) rescue ProviderError raise rescue StandardError => e raise ProviderError, "Failed to sign with Harica: #{e.}" end |
#validate_configuration! ⇒ Object
88 89 90 91 92 |
# File 'lib/sphragis/providers/harica_provider.rb', line 88 def validate_configuration! raise ProviderError, "Harica username not configured" if @config[:username].nil? raise ProviderError, "Harica password not configured" if @config[:password].nil? raise ProviderError, "Harica OTP not provided" if @config[:otp].nil? end |