From f965db794d27cf5f298fb2fc276da1cf829cd985 Mon Sep 17 00:00:00 2001 From: rautenberg Date: Tue, 7 Aug 2012 09:33:45 +0200 Subject: resource_not_found_error when authentication is impossible --- lib/authorization.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/authorization.rb') diff --git a/lib/authorization.rb b/lib/authorization.rb index fd20f68..438c7c6 100644 --- a/lib/authorization.rb +++ b/lib/authorization.rb @@ -5,7 +5,7 @@ module OpenTox #@example Authentication # require "opentox-client" # OpenTox::Authorization::AA = "https://opensso.in-silico.ch" #if not set in .opentox/conf/[environment].yaml - # token = OpenTox::Authorization.authenticate("username", "password") + # subjectid = OpenTox::Authorization.authenticate("username", "password") #@see http://www.opentox.org/dev/apis/api-1.2/AA OpenTox A&A API 1.2 specification module Authorization @@ -65,6 +65,7 @@ module OpenTox out = RestClientWrapper.post("#{AA}/auth/authenticate",{:username=>user, :password => pw}).sub("token.id=","").sub("\n","") return out rescue + resource_not_found_error "#{out.inspect}" return nil end end @@ -87,11 +88,12 @@ module OpenTox # @return [Boolean, nil] returns true, false or nil (if authorization-request fails). def self.authorize(uri, action, subjectid) return true if !AA - begin - return true if RestClientWrapper.post("#{AA}/auth/authorize",{:uri => uri, :action => action, :subjectid => subjectid})== "boolean=true\n" - rescue - return nil - end + #begin + return true if RestClientWrapper.post("#{AA}/auth/authorize",{:uri => uri, :action => action, :subjectid => subjectid})== "boolean=true\n" + return false + #rescue + # return nil + #end end #Checks if a token is a valid token @@ -101,7 +103,7 @@ module OpenTox return true if !AA begin return true if RestClientWrapper.post("#{AA}/auth/isTokenValid",:tokenid => subjectid) == "boolean=true\n" - rescue + rescue #do rescue because openSSO throws 401 return false end return false -- cgit v1.2.3