lib/cerner/oauth1a/access_token.rb
def authenticate(
        access_token_agent,
        http_method: 'GET',
        fully_qualified_url: nil,
        request_params: nil
      )
        raise ArgumentError, 'access_token_agent is nil' unless access_token_agent

        if @realm && !access_token_agent.realm_eql?(@realm)
          raise OAuthError.new('realm does not match provider', nil, 'token_rejected', nil, access_token_agent.realm)
        end

        # Set realm to the provider's realm if it's not already set
        @realm ||= access_token_agent.realm

        tuples = Protocol.parse_url_query_string(@token)

        unless @consumer_key == tuples.delete(:ConsumerKey)
          raise OAuthError.new('consumer keys do not match', nil, 'consumer_key_rejected', nil, @realm)
        end

        verify_expiration(tuples.delete(:ExpiresOn))

        keys = load_keys(access_token_agent, tuples.delete(:KeysVersion))

        verify_token(keys)
        # RSASHA1 param gets consumed in #verify_token, so remove it too
        tuples.delete(:RSASHA1)

        verify_signature(
          keys: keys,
          hmac_secrets: tuples.delete(:HMACSecrets),
          http_method: http_method,
          fully_qualified_url: fully_qualified_url,
          request_params: request_params
        )

        @consumer_principal = tuples.delete(:"Consumer.Principal")

        tuples
      end
# Public: Authenticates the #token against the #consumer_key, #signature and side-channel
# secrets exchange via AccessTokenAgent#retrieve_keys. If this instance has a #realm set,
# then it will compare it to the AccessTokenAgent#realm using the AccessTokenAgent#realm_eql?
# method.
#
# access_token_agent - An instance of Cerner::OAuth1a::AccessTokenAgent configured with
#                      appropriate credentials to retrieve secrets via
#                      Cerner::OAuth1a::AccessTokenAgent#retrieve_keys.
# keywords           - The keyword arguments:
#                      :http_method         - An optional String or Symbol containing an HTTP
#                                             method name. (default: 'GET')
#                      :fully_qualified_url - An optional String or URI that contains the
#                                             scheme, host, port (optional) and path of a URL.
#                      :request_params      - An optional Hash of name/value pairs
#                                             representing the request parameters. The keys
#                                             and values  of the Hash will be assumed to be
#                                             represented by the value returned from #to_s.
#
# Returns a Hash (symbolized keys) of any extra parameters within #token (oauth_token),
# if authentication succeeds. In most scenarios, the Hash will be empty.
#
# Raises ArgumentError if access_token_agent is nil
# Raises Cerner::OAuth1a::OAuthError with an oauth_problem if authentication fails.
Authenticates the #token against the #consumer_key, #signature and side-channel
secrets exchange via AccessTokenAgent#retrieve_keys. If this instance has a #realm set,
then it will compare it to the AccessTokenAgent#realm using the AccessTokenAgent#realm_eql.
method.



Returns a Hash (symbolized keys) of any extra parameters within #token (oauth_token),
if authentication succeeds. In most scenarios, the Hash will be empty.


Authenticates the #token against the #consumer_key #signature and side - channel secrets exchange via AccessTokenAgent#retrieve_keys . If this instance has a #realm set then it will compare it to the AccessTokenAgent#realm using the AccessTokenAgent#realm_eql . method . Returns a Hash ( symbolized keys ) of any extra parameters within #token ( oauth_token ) if authentication succeeds . In most scenarios the Hash will be empty .
def authenticate(
        access_token_agent,
        http_method: 'GET',
        fully_qualified_url: nil,
        request_params: nil
      )
        raise ArgumentError, 'access_token_agent is nil' unless access_token_agent
        if @realm && !access_token_agent.realm_eql?(@realm)
          raise OAuthError.new('realm does not match provider', nil, 'token_rejected', nil, access_token_agent.realm)
        end
        @realm ||= access_token_agent.realm
        tuples = Protocol.parse_url_query_string(@token)
        unless @consumer_key == tuples.delete(:ConsumerKey)
          raise OAuthError.new('consumer keys do not match', nil, 'consumer_key_rejected', nil, @realm)
        end
        verify_expiration(tuples.delete(:ExpiresOn))
        keys = load_keys(access_token_agent, tuples.delete(:KeysVersion))
        verify_token(keys)
        tuples.delete(:RSASHA1)
        verify_signature(
          keys: keys,
          hmac_secrets: tuples.delete(:HMACSecrets),
          http_method: http_method,
          fully_qualified_url: fully_qualified_url,
          request_params: request_params
        )
        @consumer_principal = tuples.delete(:"Consumer.Principal")
        tuples
      end
def authenticate ( access_token_agent , http_method : 'GET' , fully_qualified_url : nil , request_params : nil ) raise ArgumentError , 'access_token_agent is nil' unless access_token_agent if @realm && ! access_token_agent . realm_eql? ( @realm ) raise OAuthError . new ( 'realm does not match provider' , nil , 'token_rejected' , nil , access_token_agent . realm ) end @realm ||= access_token_agent . realm tuples = Protocol . parse_url_query_string ( @token ) unless @consumer_key == tuples . delete ( :ConsumerKey ) raise OAuthError . new ( 'consumer keys do not match' , nil , 'consumer_key_rejected' , nil , @realm ) end verify_expiration ( tuples . delete ( :ExpiresOn ) ) keys = load_keys ( access_token_agent , tuples . delete ( :KeysVersion ) ) verify_token ( keys ) tuples . delete ( :RSASHA1 ) verify_signature ( keys : keys , hmac_secrets : tuples . delete ( :HMACSecrets ) , http_method : http_method , fully_qualified_url : fully_qualified_url , request_params : request_params ) @consumer_principal = tuples . delete ( :" Consumer.Principal " ) tuples end
Public: Authenticates the #token against the #consumer_key, #signature and side-channel
secrets exchange via AccessTokenAgent#retrieve_keys.
Public : Authenticates the #token against the #consumer_key #signature and side - channel secrets exchange via AccessTokenAgent#retrieve_keys .
# Set realm to the provider's realm if it's not already set # RSASHA1 param gets consumed in #verify_token, so remove it too
access_token_agent
http_method
fully_qualified_url
request_params