Class: Saml::Elements::EncryptedID
- Inherits:
-
Object
- Object
- Saml::Elements::EncryptedID
- Includes:
- HappyMapper, Base, XMLHelpers
- Defined in:
- lib/saml/elements/encrypted_id.rb
Instance Method Summary collapse
- #encrypt(key_descriptor, key_options = {}) ⇒ Object
-
#initialize(*args) ⇒ EncryptedID
constructor
A new instance of EncryptedID.
Methods included from XMLHelpers
#add_signature, #to_soap, #to_xml
Constructor Details
#initialize(*args) ⇒ EncryptedID
Returns a new instance of EncryptedID.
19 20 21 22 |
# File 'lib/saml/elements/encrypted_id.rb', line 19 def initialize(*args) = args. super(*(args << )) end |
Instance Method Details
#encrypt(key_descriptor, key_options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/saml/elements/encrypted_id.rb', line 24 def encrypt(key_descriptor, = {}) certificate = key_descriptor.certificate key_name = key_descriptor.key_info.key_name self.encrypted_data = Xmlenc::Builder::EncryptedData.new self.encrypted_data.set_key_retrieval_method Xmlenc::Builder::RetrievalMethod.new( uri: "##{[:id]}" ) self.encrypted_data.set_encryption_method( algorithm: 'http://www.w3.org/2001/04/xmlenc#aes256-cbc' ) encrypted_key = self.encrypted_data.encrypt(name_id_xml, ) encrypted_key.set_encryption_method( algorithm: 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p', digest_method_algorithm: 'http://www.w3.org/2000/09/xmldsig#sha1' ) encrypted_key.set_key_name key_name encrypted_key.encrypt certificate.public_key self.encrypted_keys = [encrypted_key] self.name_id = nil end |