Sha256: ffa7da3eaa542ff7e1c726cf9edc0767911be6d47f92c233a3d6b65a73ffe17a

Contents?: true

Size: 645 Bytes

Versions: 11

Compression:

Stored size: 645 Bytes

Contents

module Saml
  module Kit
    class Fingerprint
      attr_reader :x509

      def initialize(raw_certificate)
        @x509 = Certificate.to_x509(raw_certificate)
      end

      def algorithm(algorithm)
        pretty_fingerprint(algorithm.new.hexdigest(x509.to_der))
      end

      def ==(other)
        self.to_s == other.to_s
      end

      def eql?(other)
        self == other
      end

      def hash
        to_s.hash
      end

      def to_s
        algorithm(OpenSSL::Digest::SHA256)
      end

      private

      def pretty_fingerprint(fingerprint)
        fingerprint.upcase.scan(/../).join(":")
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
saml-kit-0.2.11 lib/saml/kit/fingerprint.rb
saml-kit-0.2.10 lib/saml/kit/fingerprint.rb
saml-kit-0.2.9 lib/saml/kit/fingerprint.rb
saml-kit-0.2.8 lib/saml/kit/fingerprint.rb
saml-kit-0.2.7 lib/saml/kit/fingerprint.rb
saml-kit-0.2.6 lib/saml/kit/fingerprint.rb
saml-kit-0.2.5 lib/saml/kit/fingerprint.rb
saml-kit-0.2.4 lib/saml/kit/fingerprint.rb
saml-kit-0.2.3 lib/saml/kit/fingerprint.rb
saml-kit-0.2.2 lib/saml/kit/fingerprint.rb
saml-kit-0.2.1 lib/saml/kit/fingerprint.rb