lib/saml2/key.rb in saml2-1.0.10 vs lib/saml2/key.rb in saml2-1.1.0

- old
+ new

@@ -5,10 +5,28 @@ module Type ENCRYPTION = 'encryption'.freeze SIGNING = 'signing'.freeze end + class EncryptionMethod + module Algorithm + AES128_CBC = 'http://www.w3.org/2001/04/xmlenc#aes128-cbc'.freeze + end + + attr_accessor :algorithm, :key_size + + def initialize(algorithm = Algorithm::AES128_CBC, key_size = 128) + @algorithm, @key_size = algorithm, key_size + end + + def build(builder) + builder['md'].EncryptionMethod('Algorithm' => algorithm) do |encryption_method| + encryption_method['xenc'].KeySize(key_size) if key_size + end + end + end + attr_accessor :use, :x509, :encryption_methods def self.from_xml(node) return nil unless node @@ -44,10 +62,10 @@ key_info['dsig'].X509Data do |x509_data| x509_data['dsig'].X509Certificate(x509) end end encryption_methods.each do |method| - key_descriptor['xenc'].EncryptionMethod('Algorithm' => method) + method.build(key_descriptor) end end end end end