Class: R509::Validity::Redis::Checker
- Inherits:
-
Checker
- Object
- Checker
- R509::Validity::Redis::Checker
- Defined in:
- lib/r509/validity/redis/checker.rb
Instance Method Summary collapse
- #check(issuer, serial) ⇒ R509::Validity::Status
-
#initialize(redis) ⇒ Checker
constructor
A new instance of Checker.
- #is_available? ⇒ Boolean
Constructor Details
#initialize(redis) ⇒ Checker
Returns a new instance of Checker.
5 6 7 8 |
# File 'lib/r509/validity/redis/checker.rb', line 5 def initialize(redis) raise ArgumentError.new("Redis must be provided") if redis.nil? @redis = redis end |
Instance Method Details
#check(issuer, serial) ⇒ R509::Validity::Status
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/r509/validity/redis/checker.rb', line 11 def check(issuer,serial) raise ArgumentError.new("Serial and issuer must be provided") if serial.to_s.empty? or issuer.to_s.empty? hash = @redis.hgetall("cert:#{issuer}:#{serial}") if not hash.nil? and hash.has_key?("status") R509::Validity::Status.new( :status => hash["status"].to_i, :revocation_time => hash["revocation_time"].to_i || nil, :revocation_reason => hash["revocation_reason"].to_i || 0 ) else R509::Validity::Status.new(:status => R509::Validity::UNKNOWN) end end |
#is_available? ⇒ Boolean
26 27 28 |
# File 'lib/r509/validity/redis/checker.rb', line 26 def is_available? (@redis.ping == "PONG")? true : false end |