1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
# encoding: utf-8
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
module MsRestAzure
#
# Class that provides access to authentication token.
#
class TopicCredentials < MsRest::ServiceClientCredentials
private
# @return [String] the topic key
attr_reader :topic_key
public
#
# Creates and initialize new instance of the TopicCredentials class.
# @param topic_key [String] topic key
def initialize(topic_key)
fail ArgumentError, 'Topic key cannot be nil' if topic_key.nil?
fail ArgumentError, 'Topic key must be of type string' if topic_key.class.to_s != 'String'
@topic_key = topic_key
end
def sign_request(request)
super(request)
if (request.respond_to?(:request_headers))
request.request_headers['aeg-sas-key'] = @topic_key
elsif request.respond_to?(:headers)
request.headers['aeg-sas-key'] = @topic_key
else
fail ArgumentError, 'Incorrect request object was provided'
end
end
end
end
|