Sha256: c8bd5bb75999bf6816a256b25213ce0ef1068db89ac3db169e98360f9051b71c

Contents?: true

Size: 980 Bytes

Versions: 3

Compression:

Stored size: 980 Bytes

Contents

module Saml
  module Elements
    class KeyDescriptor
      class KeyInfo
        class X509Data
          include Saml::Base

          tag 'X509Data'
          namespace 'ds'

          element :x509certificate, String, :tag => "X509Certificate", :on_save => lambda { |c| c.present? ? Base64.encode64(c.to_der) : "" }

          validates :x509certificate, :presence => true

          def initialize(cert = nil)
            self.x509certificate = cert
          end

          def x509certificate=(cert)
            if cert.present?
              unless cert =~ /-----BEGIN CERTIFICATE-----/
                cert = cert.gsub(/\n/, '')
                cert = "-----BEGIN CERTIFICATE-----\n#{cert.gsub(/(.{1,64})/, "\\1\n")}-----END CERTIFICATE-----"
              end
              @x509certificate = OpenSSL::X509::Certificate.new(cert)
            end
          rescue OpenSSL::X509::CertificateError => e
            nil
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
libsaml-2.1.0 lib/saml/elements/key_descriptor/key_info/x509_data.rb
libsaml-2.0.6 lib/saml/elements/key_descriptor/key_info/x509_data.rb
libsaml-2.0.5 lib/saml/elements/key_descriptor/key_info/x509_data.rb