Class: Oxd::UMACommands
- Inherits:
-
OxdConnector
- Object
- OxdConnector
- Oxd::UMACommands
- Defined in:
- lib/oxd/uma_commands.rb
Overview
This class carries out the commands for UMA Resource Server and UMA Requesting Party
Instance Method Summary collapse
-
#initialize ⇒ UMACommands
constructor
class constructor.
-
#uma_add_resource(path, *conditions) ⇒ ARRAY
combines multiple resources into @resources array to pass to uma_rs_protect method.
-
#uma_rp_get_claims_gathering_url(claims_redirect_uri) ⇒ Hash
method to check if we have permission to access particular resource or not.
-
#uma_rp_get_rpt(claim_token = nil, claim_token_format = nil, pct = nil, rpt = nil, scope = nil, state = nil) ⇒ Hash
method for obtaining RPT to gain access to protected resources at the UMA resource server.
-
#uma_rs_check_access(path, http_method) ⇒ Hash
method to check if we have permission to access particular resource or not.
-
#uma_rs_protect ⇒ STRING
method to protect resources with UMA resource server.
Methods inherited from OxdConnector
#getData, #getData2, #getResponseData, #getResponseObject, #is_json?, #logger, #oxd_http_request, #oxd_socket_request, #request, #validate_command
Constructor Details
#initialize ⇒ UMACommands
class constructor
11 12 13 14 |
# File 'lib/oxd/uma_commands.rb', line 11 def initialize @resources = Array.new super end |
Instance Method Details
#uma_add_resource(path, *conditions) ⇒ ARRAY
combines multiple resources into @resources array to pass to uma_rs_protect method
24 25 26 |
# File 'lib/oxd/uma_commands.rb', line 24 def uma_add_resource(path, *conditions) @resources.push({:path => path, :conditions => conditions}) end |
#uma_rp_get_claims_gathering_url(claims_redirect_uri) ⇒ Hash
method to check if we have permission to access particular resource or not
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/oxd/uma_commands.rb', line 102 def uma_rp_get_claims_gathering_url( claims_redirect_uri ) if (claims_redirect_uri.empty?) logger(:log_msg => "Empty/Wrong value in place of claims_redirect_uri.") end @command = 'uma_rp_get_claims_gathering_url' @params = { "oxd_id" => @configuration.oxd_id, "ticket" => @configuration.ticket, "claims_redirect_uri" => claims_redirect_uri, "protection_access_token" => @configuration.protection_access_token } request('uma-rp-get-claims-gathering-url') getResponseData end |
#uma_rp_get_rpt(claim_token = nil, claim_token_format = nil, pct = nil, rpt = nil, scope = nil, state = nil) ⇒ Hash
method for obtaining RPT to gain access to protected resources at the UMA resource server
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/oxd/uma_commands.rb', line 52 def uma_rp_get_rpt( claim_token = nil, claim_token_format = nil, pct = nil, rpt = nil, scope = nil, state = nil ) @command = 'uma_rp_get_rpt' @params = { "oxd_id" => @configuration.oxd_id, "ticket" => @configuration.ticket, "claim_token" => claim_token, "claim_token_format" => claim_token_format, "pct" => pct, "rpt" => (!rpt.nil?)? rpt : @configuration.rpt, "scope" => scope, "state" => state, "protection_access_token" => @configuration.protection_access_token } request('uma-rp-get-rpt') if getResponseData['error'] == 'need_info' && !getResponseData['details']['ticket'].empty? @configuration.ticket = getResponseData['details']['ticket'] end getResponseData end |
#uma_rs_check_access(path, http_method) ⇒ Hash
method to check if we have permission to access particular resource or not
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/oxd/uma_commands.rb', line 78 def uma_rs_check_access(path, http_method) if (path.empty? || http_method.empty? || (!['GET', 'POST', 'PUT', 'DELETE'].include? http_method)) logger(:log_msg => "Empty/Wrong value in place of path or http_method.") end @command = 'uma_rs_check_access' @params = { "oxd_id" => @configuration.oxd_id, "rpt" => @configuration.rpt, "path" => path, "http_method" => http_method, "protection_access_token" => @configuration.protection_access_token } request('uma-rs-check-access') if getResponseData['access'] == 'denied' && !getResponseData['ticket'].empty? @configuration.ticket = getResponseData['ticket'] elsif getResponseData['access'] == 'granted' @configuration.ticket = "" end getResponseData end |
#uma_rs_protect ⇒ STRING
method to protect resources with UMA resource server
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/oxd/uma_commands.rb', line 31 def uma_rs_protect logger(:log_msg => "Please set resources with uma_add_resource(path, *conditions) method first.") if(@resources.nil?) logger(:log_msg => "UMA configuration #{@configuration}", :error => '') @command = 'uma_rs_protect' @params = { "oxd_id" => @configuration.oxd_id, "resources" => @resources, "protection_access_token" => @configuration.protection_access_token } request('uma-rs-protect') getResponseData['oxd_id'] end |