Sha256: 602ee70bc17c501ac5e168d522c146a29e6ec9fc543ea4bbda655a8cc3c54988

Contents?: true

Size: 635 Bytes

Versions: 12

Compression:

Stored size: 635 Bytes

Contents

require 'certmeister/policy/response'

module Certmeister

  module Policy

    class Existing

      def initialize(store)
        is_a_store?(store) or raise ArgumentError.new("expected a fetchable store but received a #{store.class}")
        @store = store
      end

      def authenticate(request)
        if @store.fetch(request[:cn]).nil?
          Certmeister::Policy::Response.new(true, nil)
        else
          Certmeister::Policy::Response.new(false, "certificate for cn already exists")
        end
      end

      private

      def is_a_store?(store)
        store.respond_to?(:fetch)
      end

    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
certmeister-1.0.0 lib/certmeister/policy/existing.rb
certmeister-0.4.1 lib/certmeister/policy/existing.rb
certmeister-0.4.0 lib/certmeister/policy/existing.rb
certmeister-0.3.2 lib/certmeister/policy/existing.rb
certmeister-0.3.1 lib/certmeister/policy/existing.rb
certmeister-0.3.0 lib/certmeister/policy/existing.rb
certmeister-0.2.3 lib/certmeister/policy/existing.rb
certmeister-0.2.1 lib/certmeister/policy/existing.rb
certmeister-0.2.0 lib/certmeister/policy/existing.rb
certmeister-0.1.0 lib/certmeister/policy/existing.rb
certmeister-0.0.2 lib/certmeister/policy/existing.rb
certmeister-0.0.1 lib/certmeister/policy/existing.rb