Class: AadhaarAuth::DigitalSigner
- Inherits:
-
Object
- Object
- AadhaarAuth::DigitalSigner
show all
- Defined in:
- lib/aadhaar_auth/digital_signer.rb
Defined Under Namespace
Classes: InvalidSignature
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.private_key ⇒ Object
21
22
23
|
# File 'lib/aadhaar_auth/digital_signer.rb', line 21
def private_key
@private_key ||= OpenSSL::PKey::RSA.new(pkcs12.key.to_s)
end
|
.private_key_cert ⇒ Object
25
26
27
|
# File 'lib/aadhaar_auth/digital_signer.rb', line 25
def private_key_cert
@private_key_cert ||= OpenSSL::X509::Certificate.new(pkcs12.certificate.to_s)
end
|
.private_key_cert_val ⇒ Object
29
30
31
|
# File 'lib/aadhaar_auth/digital_signer.rb', line 29
def private_key_cert_val
@private_key_cert_val ||= private_key_cert.to_s.sub(/^-----BEGIN CERTIFICATE-----\n/, '').sub(/-----END CERTIFICATE-----\n$/, '')
end
|
Instance Method Details
#sign(xml) ⇒ Object
6
7
8
|
# File 'lib/aadhaar_auth/digital_signer.rb', line 6
def sign(xml)
Xmldsig::SignedDocument.new(xml).sign(self.class.private_key)
end
|
#verify_signature(xml) ⇒ Object
10
11
12
13
14
|
# File 'lib/aadhaar_auth/digital_signer.rb', line 10
def verify_signature(xml)
if !Xmldsig::SignedDocument.new(xml).validate(Encrypter.public_cert)
raise InvalidSignature.new("Invalid response signature")
end
end
|