lib/xml/kit/encryption.rb in xml-kit-0.2.0 vs lib/xml/kit/encryption.rb in xml-kit-0.3.0

- old
+ new

@@ -1,31 +1,34 @@ # frozen_string_literal: true module Xml module Kit - class Encryption + # @deprecated Use {#Xml::Kit::EncryptedData} class instead of this + class Encryption < EncryptedData attr_reader :asymmetric_algorithm - attr_reader :asymmetric_cipher_value attr_reader :symmetric_algorithm attr_reader :symmetric_cipher_value + attr_reader :key_info def initialize( raw_xml, public_key, - symmetric_algorithm: ::Xml::Kit::Crypto::SymmetricCipher::DEFAULT_ALGORITHM, - asymmetric_algorithm: ::Xml::Kit::Crypto::RsaCipher::ALGORITHM + symmetric_algorithm: Crypto::SymmetricCipher::DEFAULT_ALGORITHM, + asymmetric_algorithm: Crypto::RsaCipher::ALGORITHM, + key_info: nil ) @symmetric_algorithm = symmetric_algorithm - symmetric_cipher = symmetric(symmetric_algorithm) - @symmetric_cipher_value = Base64.strict_encode64(symmetric_cipher.encrypt(raw_xml)) - @asymmetric_algorithm = asymmetric_algorithm - asymmetric_cipher = asymmetric(asymmetric_algorithm, public_key) - @asymmetric_cipher_value = Base64.strict_encode64(asymmetric_cipher.encrypt(symmetric_cipher.key)) + Xml::Kit.deprecate('Encryption is deprecated. Use EncryptedData.') + super(raw_xml, + symmetric_cipher: symmetric(symmetric_algorithm), + asymmetric_cipher: asymmetric(asymmetric_algorithm, public_key), + key_info: key_info + ) end - def to_xml(xml: ::Builder::XmlMarkup.new) - ::Xml::Kit::Template.new(self).to_xml(xml: xml) + def template_path + Template::TEMPLATES_DIR.join('encrypted_data.builder') end private def symmetric(algorithm)