def clean
nonces = Dir[@nonce_dir.join("*")]
now = Time.now
nonces.each do |nonce|
filename = nonce_dir.join(nonce)
begin
st = File.stat(filename)
rescue Errno::ENOENT
next
else
nonce_age = now - st.mtime
self.remove_if_present(filename) if nonce_age > @max_nonce_age
end
end
association_filenames = Dir[@association_dir.join("*")]
association_filenames.each do |af|
begin
f = File.open(af, 'r')
rescue Errno::ENOENT
next
else
begin
assoc_s = f.read
ensure
f.close
end
begin
association = OpenID::Association.deserialize(assoc_s)
rescue "VersionError"
self.remove_if_present(af)
next
else
self.remove_if_present(af) if association.expires_in == 0
end
end
end
end