File: openid.rb

package info (click to toggle)
libyadis-ruby 0.3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze
  • size: 440 kB
  • ctags: 372
  • sloc: ruby: 2,122; sh: 12; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 678 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# example of finding an OpenID server using YADIS

require 'yadis'

# Want to verify server certificates for https?
# Visit http://curl.haxx.se/docs/caextract.html and uncomment:
# YADIS.ca_path = '/path/to/cacert.pem'

url = 'http://brianellin.com/'
puts "Looking for servers for #{url}\n"

yadis = YADIS.discover(url)
openid_filter = Proc.new do |service|
  service.service_types.member?('http://openid.net/signon/1.0') ? service : nil
end

if yadis.nil?
  puts 'No XRDS found.'
else
  services = yadis.filter_services(openid_filter)
  if services.length > 0
    services.each {|s| puts "OpenID server found: #{s.uri}"}
  else
    puts 'No OpenID servers found.'  
  end
end