From 495c44445642cfae8f23fadde299ad5307f5be58 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Thu, 9 Jun 2011 18:09:52 +0100 Subject: Big commit --HG-- rename : views/please_authenticate.haml => views/login.haml --- lib/mauve/auth_bytemark.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/mauve/auth_bytemark.rb') diff --git a/lib/mauve/auth_bytemark.rb b/lib/mauve/auth_bytemark.rb index 7419d10..9e0a6d1 100644 --- a/lib/mauve/auth_bytemark.rb +++ b/lib/mauve/auth_bytemark.rb @@ -3,7 +3,7 @@ require 'sha1' require 'xmlrpc/client' require 'timeout' -class AuthSourceBytemark +class AuthBytemark def initialize (srv='auth.bytemark.co.uk', port=443) raise ArgumentError.new("Server must be a String, not a #{srv.class}") if String != srv.class @@ -11,6 +11,7 @@ class AuthSourceBytemark @srv = srv @port = port @timeout = 7 + @logger = Log4r::Logger.new(self.class.to_s) end ## Not really needed. @@ -33,15 +34,16 @@ class AuthSourceBytemark raise ArgumentError.new("Login must be a string, not a #{login.class}") if String != login.class raise ArgumentError.new("Password must be a string, not a #{password.class}") if String != password.class raise ArgumentError.new("Login or/and password is/are empty.") if login.empty? || password.empty? + client = XMLRPC::Client.new(@srv,"/",@port,nil,nil,nil,nil,true,@timeout).proxy("bytemark.auth") + begin challenge = client.getChallengeForUser(login) response = Digest::SHA1.new.update(challenge).update(password).hexdigest client.login(login, response) - rescue XMLRPC::FaultException => fault - return "Fault code is #{fault.faultCode} stating #{fault.faultString}" + rescue Exception => ex + return false end - return true end end -- cgit v1.2.1