diff options
author | rautenberg <rautenberg@in-silico.ch> | 2012-08-07 09:33:45 +0200 |
---|---|---|
committer | rautenberg <rautenberg@in-silico.ch> | 2012-08-07 09:33:45 +0200 |
commit | f965db794d27cf5f298fb2fc276da1cf829cd985 (patch) | |
tree | 8a9f766c4fa208bc785726ea76ce3e6a7d214d52 /lib/authorization.rb | |
parent | 7046901ac5b45e138669c4faa482007a0481e53e (diff) |
resource_not_found_error when authentication is impossible
Diffstat (limited to 'lib/authorization.rb')
-rw-r--r-- | lib/authorization.rb | 16 |
1 files changed, 9 insertions, 7 deletions
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 |