class Azure::ServiceBus::Auth::WrapSigner

Attributes

tokens[RW]

Public Class Methods

new() click to toggle source
# File lib/azure/service_bus/auth/wrap_signer.rb, line 25
def initialize
  @tokens = {}
  @wrap_service = Azure::ServiceBus::Auth::WrapService.new
end

Public Instance Methods

name() click to toggle source
# File lib/azure/service_bus/auth/wrap_signer.rb, line 32
def name
  "WRAP"
end
sign(method, uri, headers) click to toggle source
# File lib/azure/service_bus/auth/wrap_signer.rb, line 37
def sign(method, uri, headers)
  access_token = get_access_token(create_scope_uri(uri))
  'access_token="%s"' % access_token
end

Private Instance Methods

create_scope_uri(target_uri) click to toggle source
# File lib/azure/service_bus/auth/wrap_signer.rb, line 50
def create_scope_uri(target_uri)
  targetUriComponents = URI.parse(target_uri.to_s)

  # ACS body and caching should be HTTP
  targetUriComponents.scheme = 'http'

  # ACS body and caching should not include query
  targetUriComponents.query = nil

  targetUriComponents
end
get_access_token(uri) click to toggle source
# File lib/azure/service_bus/auth/wrap_signer.rb, line 43
def get_access_token(uri)
  token = tokens[uri.to_s]
  token = tokens[uri.to_s] = @wrap_service.get_access_token(uri) unless valid_token?(token)
  token[:token]
end
valid_token?(token) click to toggle source
# File lib/azure/service_bus/auth/wrap_signer.rb, line 63
def valid_token?(token)
  token and token[:expiration] > Time.now.to_i
end