Sha256: 7fdacc99f576924d7992d127f95350953d347f24503407bc3f5843d0b7e48ed8

Contents?: true

Size: 1.85 KB

Versions: 2

Compression:

Stored size: 1.85 KB

Contents

module Saml
  module Kit
    class Configuration
      BEGIN_CERT=/-----BEGIN CERTIFICATE-----/
      END_CERT=/-----END CERTIFICATE-----/

      attr_accessor :issuer
      attr_accessor :signature_method, :digest_method
      attr_accessor :signing_certificate_pem, :signing_private_key_pem, :signing_private_key_password
      attr_accessor :encryption_certificate_pem, :encryption_private_key_pem, :encryption_private_key_password
      attr_accessor :registry, :session_timeout
      attr_accessor :logger

      def initialize
        @signature_method = :SHA256
        @digest_method = :SHA256
        @signing_private_key_password = SecureRandom.uuid
        @encryption_private_key_password = SecureRandom.uuid
        @signing_certificate_pem, @signing_private_key_pem = SelfSignedCertificate.new(@signing_private_key_password).create
        @encryption_certificate_pem, @encryption_private_key_pem = SelfSignedCertificate.new(@encryption_private_key_password).create
        @registry = DefaultRegistry.new
        @session_timeout = 3.hours
        @logger = Logger.new(STDOUT)
      end

      def stripped_signing_certificate
        normalize(signing_certificate_pem)
      end

      def stripped_encryption_certificate
        normalize(encryption_certificate_pem)
      end

      def signing_x509
        Certificate.to_x509(signing_certificate_pem)
      end

      def encryption_x509
        Certificate.to_x509(encryption_certificate_pem)
      end

      def signing_private_key
        OpenSSL::PKey::RSA.new(signing_private_key_pem, signing_private_key_password)
      end

      def encryption_private_key
        OpenSSL::PKey::RSA.new(encryption_private_key_pem, encryption_private_key_password)
      end

      private

      def normalize(certificate)
        certificate.to_s.gsub(BEGIN_CERT, '').gsub(END_CERT, '').gsub(/\n/, '')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
saml-kit-0.2.2 lib/saml/kit/configuration.rb
saml-kit-0.2.1 lib/saml/kit/configuration.rb