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)
- - (R509::Validity::Status) check(issuer, serial)
-
- (Checker) initialize(redis)
constructor
A new instance of Checker.
- - (Boolean) is_available?
Constructor Details
- (Checker) initialize(redis)
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
- (R509::Validity::Status) check(issuer, serial)
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 |
- (Boolean) is_available?
26 27 28 |
# File 'lib/r509/validity/redis/checker.rb', line 26 def is_available? (@redis.ping == "PONG")? true : false end |