dot_net_services 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/LICENSE +21 -24
  2. data/README +26 -16
  3. data/Rakefile +65 -0
  4. data/lib/acs/saml_token_provider.rb +54 -0
  5. data/lib/acs/shared_secret_token_provider.rb +55 -0
  6. data/lib/acs/simple_api_auth_token_provider.rb +57 -0
  7. data/lib/acs/simple_web_token_provider.rb +54 -0
  8. data/lib/acs/token_constants.rb +112 -0
  9. data/lib/acs/token_info.rb +33 -0
  10. data/lib/acs/token_provider.rb +74 -0
  11. data/lib/acs/token_validator.rb +114 -0
  12. data/lib/common/dot_net_services_environment.rb +61 -0
  13. data/lib/common/environment.yml +23 -0
  14. data/lib/common/host_name_config.yml +45 -0
  15. data/lib/dot_net_services.rb +31 -144
  16. data/lib/service_bus/http_proxy.rb +34 -0
  17. data/lib/service_bus/locked_message_info.rb +34 -0
  18. data/lib/service_bus/message_buffer.rb +313 -0
  19. data/lib/service_bus/message_buffer_constants.rb +48 -0
  20. data/lib/service_bus/message_buffer_policy.rb +55 -0
  21. data/lib/service_bus/requests.rb +95 -0
  22. data/test/config/test_config.yml +40 -0
  23. data/test/dot_net_services_environment_test.rb +54 -0
  24. data/test/message_buffer_test.rb +96 -0
  25. data/test/token_test.rb +98 -0
  26. metadata +50 -48
  27. data/lib/dot_net_services/authentication.rb +0 -168
  28. data/lib/dot_net_services/error.rb +0 -4
  29. data/lib/dot_net_services/message_buffer.rb +0 -283
  30. data/lib/dot_net_services/session.rb +0 -308
  31. data/lib/net/http/create_mb.rb +0 -14
  32. data/lib/net/http/retrieve.rb +0 -14
  33. data/lib/net/http/subscribe.rb +0 -14
  34. data/lib/net/http/unsubscribe.rb +0 -14
  35. data/spec/integration/TestService/Service/AnonymousResourceService.cs +0 -9
  36. data/spec/integration/TestService/Service/App.config +0 -32
  37. data/spec/integration/TestService/Service/PlainTextService.cs +0 -37
  38. data/spec/integration/TestService/Service/Program.cs +0 -49
  39. data/spec/integration/TestService/Service/Properties/AssemblyInfo.cs +0 -33
  40. data/spec/integration/TestService/Service/ResourceContract.cs +0 -17
  41. data/spec/integration/TestService/Service/ResourceService.cs +0 -58
  42. data/spec/integration/TestService/Service/Service.csproj +0 -71
  43. data/spec/integration/TestService/TestService.sln +0 -33
  44. data/spec/integration/end_to_end_spec.rb +0 -84
  45. data/spec/integration/vmb_spec.rb +0 -30
  46. data/spec/spec_helper.rb +0 -23
  47. data/spec/unit/dot_net_services/authentication_spec.rb +0 -289
  48. data/spec/unit/dot_net_services/message_buffer_spec.rb +0 -161
  49. data/spec/unit/dot_net_services/session_spec.rb +0 -247
@@ -0,0 +1,114 @@
1
+ # Copyright (c) 2009, Persistent Systems Limited
2
+ #
3
+ # Redistribution and use, with or without modification, are permitted
4
+ # provided that the following conditions are met:
5
+ # - Redistributions of source code must retain the above copyright notice,
6
+ # this list of conditions and the following disclaimer.
7
+ # - Neither the name of Persistent Systems Limited nor the names of its contributors
8
+ # may be used to endorse or promote products derived from this software
9
+ # without specific prior written permission.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
13
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
14
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
15
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS
18
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
21
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+
23
+ require "cgi"
24
+ require "base64"
25
+ require 'rubygems'
26
+ require 'hmac-sha2'
27
+ require "#{__FILE__}/../../service_bus/requests"
28
+
29
+ class TokenValidator
30
+
31
+ attr_reader :claims, :trusted_token_issuer, :trusted_audience, :trusted_signing_key, :token
32
+
33
+ # service_name: Defined in the contants file
34
+ # solution_name: Name of the service created
35
+ # truste_audience: Applies_to url
36
+ # trusted_signing_key: Management key provided when the service was created
37
+ # token: service_name + " " + token received
38
+ def initialize(service_name, solution_name, trusted_audience, trusted_signing_key, token)
39
+ token_separator = ' '
40
+ @issuer_label = "Issuer"
41
+ @expires_label = "ExpiresOn"
42
+ @audience_label = "Audience"
43
+ @hmacSHA256_label = "HMACSHA256"
44
+
45
+ @trusted_token_issuer = "https://" + solution_name + "." + DotNetServicesEnvironment.acm_host_name +
46
+ "/" + service_name
47
+ @trusted_audience = trusted_audience
48
+ @trusted_signing_key = trusted_signing_key
49
+
50
+ @token = CGI::unescape(token.split(token_separator).last)
51
+ populate_claims(@token)
52
+ end
53
+
54
+ # Validates the token based on hmac key, expiry, issuer and audience.
55
+ def validate
56
+ return false if(@token[0..7] == "WRAPv0.8")
57
+ return false unless hmac_valid?
58
+ self.populate_claims(@token)
59
+ return false if expired?
60
+ return false unless issuer_trusted?
61
+ return false unless audience_trusted?
62
+ return true
63
+ end
64
+
65
+ # Checks the token against hmac key
66
+ def hmac_valid?
67
+ @token_signature = @token.split('&' + @hmacSHA256_label + '=')
68
+ return false if(@token_signature.size != 2)
69
+ @computed_signature = Base64.encode64(HMAC::SHA256.digest(Base64.decode64(@trusted_signing_key), @token_signature.first))
70
+ @computed_signature = @computed_signature.gsub("\n", "")
71
+ return (@computed_signature == (CGI::unescape(@token_signature.last)))
72
+ end
73
+
74
+ # Validates claims received in the tokens with the expected claims
75
+ # * expected_claims: Hask containing key-value pairs of claims
76
+ def validate_claims(expected_claims)
77
+ expected_claim_keys = expected_claims.keys
78
+ expected_claim_keys.each do |key|
79
+ return false unless @claims[key]
80
+ return false unless (expected_claims[key] == @claims[key])
81
+ end
82
+ end
83
+
84
+ # Extracts the claims from token
85
+ # * token_value: Token returned by the .NET services
86
+ def populate_claims(token_value)
87
+ token_value.extend DotNetServices::HTTPRequests::ToHash
88
+ @claims = token_value.to_hash
89
+ end
90
+
91
+ # Checks if the token is expired or not
92
+ def expired?
93
+ raise StandardError.new("Claims not defined in the token.") if(@claims.empty?)
94
+ expires_on_seconds = @claims[@expires_label]
95
+ expiry_time = Time.at(expires_on_seconds.to_i)
96
+ current_time = Time.new
97
+ # Current timestamp must be less than expiration time stamp
98
+ return (current_time > expiry_time)
99
+ end
100
+
101
+ # Checks if the issuer in the token is the same as the trusted token issuer
102
+ def issuer_trusted?
103
+ raise StandardError.new("Claims not defined in the token.") if(@claims.empty?)
104
+ @issuer = @claims[@issuer_label]
105
+ return ((@issuer.empty?) || (@issuer.casecmp(@trusted_token_issuer) != 0))
106
+ end
107
+
108
+ # Checks if the audience (applies to) in the token is the same as the trusted token issuer
109
+ def audience_trusted?
110
+ raise StandardError.new("Claims not defined in the token.") if(@claims.empty?)
111
+ audience = @claims[@audience_label]
112
+ return ((!audience.empty?) || (audience == @trusted_audience))
113
+ end
114
+ end
@@ -0,0 +1,61 @@
1
+ # Copyright (c) 2009, Persistent Systems Limited
2
+ #
3
+ # Redistribution and use, with or without modification, are permitted
4
+ # provided that the following conditions are met:
5
+ # - Redistributions of source code must retain the above copyright notice,
6
+ # this list of conditions and the following disclaimer.
7
+ # - Neither the name of Persistent Systems Limited nor the names of its contributors
8
+ # may be used to endorse or promote products derived from this software
9
+ # without specific prior written permission.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
13
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
14
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
15
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS
18
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
21
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+
23
+ require 'yaml'
24
+ # Class that holds Service bus and ACS host names for bvt, int, ppe and prod environment.
25
+ # The environment can be set in environment.properties file
26
+ class DotNetServicesEnvironment
27
+
28
+ ENV_FILE = File.join(File.dirname(__FILE__), "environment.yml")
29
+ HOST_NAME_CONFIG_FILE = File.join(File.dirname(__FILE__), "host_name_config.yml")
30
+ ENCODING = "UTF-8"
31
+ # Default env is set to bvt during development,
32
+ # will be changed to prod at the time of release
33
+ HOST_NAMES = YAML.load(File.open(HOST_NAME_CONFIG_FILE))["environments"]
34
+
35
+ class << self
36
+ # Returns the environment from the environment.yml file
37
+ def environment
38
+ environment = YAML.load(File.open(ENV_FILE))
39
+ (environment && environment['Environment'])
40
+ end
41
+
42
+ def acm_host_name(env = nil)
43
+ HOST_NAMES[valid_env(env)]['acm']
44
+ end
45
+
46
+ def sts_host_name(env = nil)
47
+ HOST_NAMES[valid_env(env)]['sts']
48
+ end
49
+
50
+ def service_bus_host_name(env = nil)
51
+ HOST_NAMES[valid_env(env)]['service_bus']
52
+ end
53
+
54
+ def valid_env(env)
55
+ env ||= environment
56
+ HOST_NAMES.keys.include?(env) ? env : 'default'
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,23 @@
1
+ # Copyright (c) 2009, Persistent Systems Limited
2
+ #
3
+ # Redistribution and use, with or without modification, are permitted
4
+ # provided that the following conditions are met:
5
+ # - Redistributions of source code must retain the above copyright notice,
6
+ # this list of conditions and the following disclaimer.
7
+ # - Neither the name of Persistent Systems Limited nor the names of its contributors
8
+ # may be used to endorse or promote products derived from this software
9
+ # without specific prior written permission.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
13
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
14
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
15
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS
18
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
21
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+
23
+ Environment: prod
@@ -0,0 +1,45 @@
1
+ # Copyright (c) 2009, Persistent Systems Limited
2
+ #
3
+ # Redistribution and use, with or without modification, are permitted
4
+ # provided that the following conditions are met:
5
+ # - Redistributions of source code must retain the above copyright notice,
6
+ # this list of conditions and the following disclaimer.
7
+ # - Neither the name of Persistent Systems Limited nor the names of its contributors
8
+ # may be used to endorse or promote products derived from this software
9
+ # without specific prior written permission.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
13
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
14
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
15
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS
18
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
21
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+
23
+ environments:
24
+ bvt: &bvt
25
+ service_bus: servicebus.windows-bvt.net
26
+ acm: accesscontrol.windows-bvt.net
27
+ sts: accesscontrol.windows-bvt.net
28
+
29
+ int: &int
30
+ service_bus: servicebus.int2.windows-int.net
31
+ acm: accesscontrol.int2.windows-int.net
32
+ sts: accesscontrol.int2.windows-int.net
33
+
34
+ ppe: &ppe
35
+ service_bus: servicebus.windows-ppe.net
36
+ acm: accesscontrol.windows-ppe.net
37
+ sts: accesscontrol.windows-ppe.net
38
+
39
+ prod: &prod
40
+ service_bus: servicebus.windows.net
41
+ acm: accesscontrol.windows.net
42
+ sts: accesscontrol.windows.net
43
+
44
+ default:
45
+ <<: *prod
@@ -1,145 +1,32 @@
1
- require 'dot_net_services/session'
2
- require 'dot_net_services/authentication'
3
- require 'dot_net_services/error'
4
- require 'dot_net_services/message_buffer'
5
- require 'net/http/create_mb'
6
- require 'net/http/retrieve'
7
- require 'net/http/subscribe'
1
+ # Copyright (c) 2009, Persistent Systems Limited
2
+ #
3
+ # Redistribution and use, with or without modification, are permitted
4
+ # provided that the following conditions are met:
5
+ # - Redistributions of source code must retain the above copyright notice,
6
+ # this list of conditions and the following disclaimer.
7
+ # - Neither the name of Persistent Systems Limited nor the names of its contributors
8
+ # may be used to endorse or promote products derived from this software
9
+ # without specific prior written permission.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
13
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
14
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
15
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS
18
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
21
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+
23
+ require "#{__FILE__}/../acs/shared_secret_token_provider"
24
+ require "#{__FILE__}/../acs/simple_api_auth_token_provider"
25
+ require "#{__FILE__}/../acs/simple_web_token_provider"
26
+ require "#{__FILE__}/../acs/saml_token_provider"
27
+ require "#{__FILE__}/../acs/token_constants"
28
+ require "#{__FILE__}/../acs/token_info"
29
+ require "#{__FILE__}/../acs/token_provider"
30
+ require "#{__FILE__}/../acs/token_validator"
31
+ require "#{__FILE__}/../service_bus/message_buffer"
8
32
 
9
- # DotNetServices is the top-level namespace of <b>.NET Services for Ruby</b>, Ruby interoperability layer for
10
- # .NET Services plain HTTP (REST) API.
11
- #
12
- # == .NET Services
13
- #
14
- # Since you are reading this, you probably already know that .NET Services is a Microsoft product, described as the
15
- # "Internet Services Bus", a messaging bus in the cloud. Like any other messaging bus, it helps services and consumers
16
- # to communicate with each other. Further information on .NET Services can be found on MSDN:
17
- # http://go.microsoft.com/fwlink/?LinkID=129428.
18
- #
19
- # While .NET Services primarily target .NET platform, non-Microsoft software is also catered for,
20
- # by providing open protocols for most of the bus functionality, in both SOAP/WS-* and plain HTTP style. The latter
21
- # is structured in a way that makes it easy to implement REST interactions over the bus, including both
22
- # synchronous and asynchronous semantics. .NET Services bus doesn't force an application to use REST, any
23
- # other kind of plain HTTP protocol can be routed through it, too.
24
- #
25
- #
26
- # == Functionality
27
- #
28
- # This library is a simple Ruby wrapper for .NET Services plain HTPP (REST) APIs. Current version allows Ruby
29
- # developers to build consumers of synchronous RESTful services (implemented as .NET WCF services, using
30
- # webHttpRelayBinding, provided by the .NET Services SDK). You can also exchange messages between Ruby processes via
31
- # Volatile Message Buffers (VMBs), which are .NET Services mechanism for asynchronous communications.
32
- #
33
- # .NET Services for Ruby looks like Net::HTTP API from the standard library, but deals with authentication,
34
- # VMB management and message retrieval.
35
- #
36
- # Since this is a 0.1.0 version of an interoperability layer for a PDC version of a bus, a few things are missing.
37
- #
38
- # Most notably, with this version you still can not:
39
- # * communicate with WCF services bound by anything other than webHttpRelayBinding.
40
- # * communicate with the bus via WS-* protocols.
41
- # * communicate with a WCF-based service via a VMB. At least, not until .NET Services SDK adds a WCF binding for
42
- # REST via VMB. Once it's available, we should be able to work with it.
43
- # * use VMB pub-sub and multicast functionality
44
- # * use Workflow Services
45
- # * use Identity Service as a dfederated identity provider for end-users
46
- #
47
- # == Usage examples
48
- #
49
- # Say, you are a cellphone dealer. You have a Point of Sale web application, written in Rails. It sells cellphones.
50
- # The phones you sell are operated by a phone company, which offers a .NET Services solution (group of services in
51
- # the .NET Services world), called Dealership. It includes two services, Customer and Provisioning.
52
- #
53
- # Customer service is a RESTful service endpoint, implemented by WCF service with a webHttpRelayBinding. It's listening
54
- # on /Customer URL, and provides the usual CRUD functionality for managing customers.
55
- #
56
- # Provisioning service endpoint is a VMB. Coincidentally, it's also written in Ruby! :) When a customer buys a new phone,
57
- # provisioning application should activate the phohe on the network, so that the customer can actually make calls with it.
58
- # Activation can take several minutes, even hours, and we don't want the point of sale terminal to hang until it's over.
59
- # Hence the use of a VMB as an asynchronous communication device.
60
- #
61
- # To create a customer, point of sale app needs to post a URL-encoded form to a webHttpRelayBinding endpoint. That's
62
- # where you need to use a DotNetServices::Session class:
63
- #
64
- # require 'dotnetservices'
65
- # session = DotNetServices::Session.open("/Dealership/Customer", :username => 'Dealership', :password => '_password')
66
- # session.post :first_name => 'John', :last_name => 'Doe'
67
- #
68
- # Posting a message to a Provisioning endpoint would actually look the same:
69
- #
70
- # session = DotNetServices::Session.open("/Dealership/Provisioning", :username => 'Dealership', :password => '_password')
71
- # session.post :phone_number => '555 888-8888'
72
- #
73
- # DotNetServices::MessageBuffer is needed by the Provisioning *service* (and not the client), to register the VMB and
74
- # retrieve messages from it. Usage typically looks like this:
75
- #
76
- # buffer = DotNetServices::MessageBuffer.new("/Dealership/Provisioning",
77
- # :username => 'Dealership', :password => '_password')
78
- # buffer.open_and_poll do |message|
79
- # ... process incoming messages ...
80
- # end
81
- #
82
- # This code will check that the VMB exists, create one if necessary, and continuously poll it for new messages. Whenever
83
- # a new message is sent to VMB, MessageBuffer#open_and_poll retrieves it and invokesthe block, passing it a
84
- # Net::HTTP::Request instance that looks exactly like what the sender originally sent to the VMB. Nice and easy.
85
- #
86
- # To understand and use .NET Services for Ruby, you should probably also read the documentation for the two classes
87
- # mentioned above: DotNetServices::Session and DotNetServices::MessageBuffer.
88
- #
89
- # Happy bussing!
90
- module DotNetServices
91
-
92
- class << self
93
-
94
- # The name of the host providing DotNetServices relay services.
95
- def relay_host
96
- "servicebus.windows.net"
97
- end
98
-
99
- # The name of the host providing DotNetServices identity services.
100
- def identity_host
101
- 'accesscontrol.windows.net'
102
- end
103
-
104
- # The root URL used for exposing services.
105
- def root_url
106
- # Modified as per changes in enpoint URL naming conventions in
107
- # .Net Services March 09 CTP release (M5)
108
- "#{relay_host}/"
109
- end
110
-
111
- # Host and port of the bus endpoint.
112
- def host_port
113
- return @host_port if @host_port
114
- uri = URI.parse(root_url)
115
- @host_port = [uri.host, uri.port]
116
- @host_port
117
- end
118
-
119
- # Use an HTTP proxy to connect to .NET Services
120
- #
121
- # If you call this method, all subsequent communications with .NET Services will use an HTTP proxy.
122
- # You must given hostname and password #use proxy
123
- # DotNetServices.use_proxy()
124
- def use_proxy(proxy_host, proxy_port, proxy_user = nil, proxy_password = nil)
125
- @proxy = Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_password)
126
- end
127
-
128
- # An HTTP proxy to connect through.
129
- #
130
- # Defaults to Net::HTTP (direct connection without proxy). To set a proxy, see #use_proxy.
131
- def proxy
132
- @proxy || Net::HTTP
133
- end
134
-
135
- # TODO implement!
136
- def logger
137
- if RAILS_ENV
138
- nil
139
- else
140
- @logger ||= nil
141
- end
142
- end
143
-
144
- end
145
- end
@@ -0,0 +1,34 @@
1
+ # Copyright (c) 2009, Persistent Systems Limited
2
+ #
3
+ # Redistribution and use, with or without modification, are permitted
4
+ # provided that the following conditions are met:
5
+ # - Redistributions of source code must retain the above copyright notice,
6
+ # this list of conditions and the following disclaimer.
7
+ # - Neither the name of Persistent Systems Limited nor the names of its contributors
8
+ # may be used to endorse or promote products derived from this software
9
+ # without specific prior written permission.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
13
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
14
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
15
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS
18
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
21
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+
23
+ require 'net/http'
24
+
25
+ module HTTPProxy # :nodoc:
26
+
27
+ def set_http_web_proxy(proxy)
28
+ if proxy['http_web_proxy_server'] && proxy['http_web_proxy_port']
29
+ @http_web_proxy = Net::HTTP::Proxy(proxy['http_web_proxy_server'], proxy['http_web_proxy_port'], proxy['http_web_proxy_username'], proxy['http_web_proxy_password'])
30
+ end
31
+ end
32
+ end
33
+
34
+
@@ -0,0 +1,34 @@
1
+ # Copyright (c) 2009, Persistent Systems Limited
2
+ #
3
+ # Redistribution and use, with or without modification, are permitted
4
+ # provided that the following conditions are met:
5
+ # - Redistributions of source code must retain the above copyright notice,
6
+ # this list of conditions and the following disclaimer.
7
+ # - Neither the name of Persistent Systems Limited nor the names of its contributors
8
+ # may be used to endorse or promote products derived from this software
9
+ # without specific prior written permission.
10
+ #
11
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
13
+ # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
14
+ # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
15
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16
+ # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17
+ # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, DATA, OR PROFITS
18
+ # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20
+ # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
21
+ # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+
23
+ class LockedMessageInfo # :nodoc:
24
+
25
+ attr_accessor :lock_id, :lock_uri, :message_uri
26
+
27
+ def initialize(lock_id, lock_uri, message_uri)
28
+ @lock_id = lock_id
29
+ @lock_uri = lock_uri
30
+ @message_uri = message_uri
31
+ end
32
+
33
+ end
34
+