Class: OpenID::Store::MongoidStore
- Inherits:
-
Interface
- Object
- Interface
- OpenID::Store::MongoidStore
- Defined in:
- lib/openid/store/mongoid_store.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_association(server_url, handle = nil) ⇒ Object
- #store_association(server_url, assoc) ⇒ Object
- #use_nonce(server_url, timestamp, salt) ⇒ Object
Class Method Details
.cleanup ⇒ Object
10 11 12 13 |
# File 'lib/openid/store/mongoid_store.rb', line 10 def self.cleanup cleanup_nonces cleanup_associations end |
Instance Method Details
#get_association(server_url, handle = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/openid/store/mongoid_store.rb', line 15 def get_association(server_url, handle = nil) assns = query_associations(server_url, handle) assns.reverse.each do |assn| a = assn.from_record if a.expires_in == 0 assn.destroy else return a end end if assns.any? return nil end |
#store_association(server_url, assoc) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/openid/store/mongoid_store.rb', line 30 def store_association(server_url, assoc) remove_association(server_url, assoc.handle) # BSON::Binary is used because secrets raise an exception # due to character encoding Association.create(:server_url => server_url, :handle => assoc.handle, :secret => Moped::BSON::Binary.new(:generic, assoc.secret), :issued => assoc.issued.to_i, :lifetime => assoc.lifetime, :assoc_type => assoc.assoc_type) end |
#use_nonce(server_url, timestamp, salt) ⇒ Object
43 44 45 46 47 |
# File 'lib/openid/store/mongoid_store.rb', line 43 def use_nonce(server_url, , salt) return false if any_nonces?(server_url, , salt) || delta_beyond_skew?() Nonce.create(:server_url => server_url, :timestamp => , :salt => salt) return true end |