Class: Certmeister::Policy::Existing
- Inherits:
-
Object
- Object
- Certmeister::Policy::Existing
- Defined in:
- lib/certmeister/policy/existing.rb
Instance Method Summary collapse
- #authenticate(request) ⇒ Object
-
#initialize(store) ⇒ Existing
constructor
A new instance of Existing.
Constructor Details
#initialize(store) ⇒ Existing
Returns a new instance of Existing.
9 10 11 12 |
# File 'lib/certmeister/policy/existing.rb', line 9 def initialize(store) is_a_store?(store) or raise ArgumentError.new("expected a fetchable store but received a #{store.class}") @store = store end |
Instance Method Details
#authenticate(request) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/certmeister/policy/existing.rb', line 14 def authenticate(request) if not request[:cn] Certmeister::Policy::Response.new(false, "missing cn") elsif @store.fetch(request[:cn]).nil? Certmeister::Policy::Response.new(true, nil) else Certmeister::Policy::Response.new(false, "certificate for cn already exists") end end |