Class: Saml::Kit::XmlDecryption

Inherits:
Object
  • Object
show all
Defined in:
lib/saml/kit/xml_decryption.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration: Saml::Kit.configuration) ⇒ XmlDecryption

Returns a new instance of XmlDecryption.



6
7
8
# File 'lib/saml/kit/xml_decryption.rb', line 6

def initialize(configuration: Saml::Kit.configuration)
  @private_keys = configuration.private_keys(use: :encryption)
end

Instance Attribute Details

#private_keys ⇒ Object (readonly)

Returns the value of attribute private_keys.



4
5
6
# File 'lib/saml/kit/xml_decryption.rb', line 4

def private_keys
  @private_keys
end

Instance Method Details

#decrypt(data) ⇒ Object



10
11
12
13
14
15
# File 'lib/saml/kit/xml_decryption.rb', line 10

def decrypt(data)
  encrypted_data = data['EncryptedData']
  symmetric_key = symmetric_key_from(encrypted_data)
  cipher_text = Base64.decode64(encrypted_data["CipherData"]["CipherValue"])
  to_plaintext(cipher_text, symmetric_key, encrypted_data["EncryptionMethod"]['Algorithm'])
end