Changeset 1028
- Timestamp:
- 06/17/08 22:25:08 (21 months ago)
- Location:
- easyweb/trunk
- Files:
-
- 1 added
- 3 modified
-
. (modified) (1 prop)
-
easyweb/authenticator.rb (modified) (2 diffs)
-
easyweb/login.rb (modified) (1 diff)
-
test.rb (added)
Legend:
- Unmodified
- Added
- Removed
-
easyweb/trunk
- Property svn:ignore
-
old new 1 test.rb 1 auth.yaml 2
-
- Property svn:ignore
-
easyweb/trunk/easyweb/authenticator.rb
r1026 r1028 1 class EasyWeb::PlainAuthenticator 1 require 'yaml' 2 3 class EasyWeb::RubyAuthenticator 2 4 attr_reader :user, :password 5 3 6 def initialize(user, pass, &oracle) 4 7 @user = user; @password = pass; @oracle = oracle … … 6 9 def challenge(q); @oracle[q]; end 7 10 end 11 12 # YAML should contain: 13 # - user 14 # - password 15 # - challenge: 16 # hash of regexes matching challenge questions, to challenge answers 17 class EasyWeb::YAMLAuthenticator 18 attr_reader :user, :password 19 20 def initialize(io) 21 yaml = YAML.load(io) 22 @user = "%013d" % yaml['user'].to_i 23 @password = yaml['password'] 24 @answers = yaml['challenge'].map { |k,v| [Regexp.new(k), v] } 25 end 26 27 def challenge(q) 28 @answers.each { |re, a| return a if re === q } 29 nil 30 end 31 end -
easyweb/trunk/easyweb/login.rb
r1026 r1028 10 10 11 11 def login_page 12 refresh = @mech.get('https://easyweb.tdcanadatrust.com/ /main.jsp' +12 refresh = @mech.get('https://easyweb.tdcanadatrust.com/main.jsp' + 13 13 '?lang=english&fromIndex=true') 14 14 md = /"(http[^"]*tdcanadatrust[^"]*)"/.match(refresh.body)
