aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/auth_bytemark.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-06-09 18:09:52 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-06-09 18:09:52 +0100
commit495c44445642cfae8f23fadde299ad5307f5be58 (patch)
tree0104c9eef164235aa5ab05b126c8f63e52fb8624 /lib/mauve/auth_bytemark.rb
parent0c88fcc91db1b003cd5d5311f62700c7867b4099 (diff)
Big commit
--HG-- rename : views/please_authenticate.haml => views/login.haml
Diffstat (limited to 'lib/mauve/auth_bytemark.rb')
-rw-r--r--lib/mauve/auth_bytemark.rb10
1 files changed, 6 insertions, 4 deletions
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