rubysspi 0.0.1-i386-mswin32 → 0.0.2-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -8,6 +8,18 @@ This project can be found on rubyforge at:
8
8
 
9
9
  http://rubyforge.org/projects/rubysspi
10
10
 
11
+ = Using with rubygems (and other libraries)
12
+
13
+ If RubyGems is not working because of proxy authorization errors, the rubysspi library can be used to solve the problem. The gem includes a file called <tt>spa.rb</tt> in the root directory. Copy this file to your site_ruby directory and then run the gem script directly:
14
+
15
+ ruby -rspa 'C:\Program Files\ruby\gem'
16
+
17
+ For example, to list remote gems that match "sspi" this command can be used
18
+
19
+ ruby -rspa 'C:\Program Files\ruby\gem' list --remote sspi
20
+
21
+ You must copy the <tt></tt> file yourself, however. Rubygems is not able to do it for you on install.
22
+
11
23
  = Using with open-uri
12
24
 
13
25
  To use the library with open-uri, make sure to set the environment variable +http_proxy+ to your proxy server. This must be a hostname and port in URL form. E.g.:
@@ -16,10 +28,10 @@ To use the library with open-uri, make sure to set the environment variable +htt
16
28
 
17
29
  The library will grab your current username and domain from the environment variables +USERNAME+ and +USERDOMAIN+. This should be set for you by Windows already.
18
30
 
19
- The library implements a patch on top of Net::HTTP, which means open-uri gets it too. At the top of your script, make sure to require the patch after +open-uri+:
31
+ The library implements a patch on top of Net::HTTP, which means open-uri gets it too. At the top of your script, make sure to require the patch after <tt>open-uri</tt>:
20
32
 
21
- require +open-uri+
22
- require +rubysspi/proxy_auth+
33
+ require open-uri
34
+ require rubysspi/proxy_auth
23
35
 
24
36
  open("http://www.google.com") { |f| puts(f.gets(nil)) }
25
37
 
@@ -30,7 +42,7 @@ Note that this patch does NOT work with the +http_proxy_user+ and +http_proxy_pa
30
42
  Net::HTTP will not use the proxy server supplied in the environment variable automatically, so you have to supply the proxy address yourself. Otherwise, it's exactly the same:
31
43
 
32
44
  require 'net/http'
33
- require 'rubysspi/proxy_auth+
45
+ require 'rubysspi/proxy_auth'
34
46
 
35
47
  Net::HTTP::Proxy("proxy.corp.com", 8080).start("www.google.com") do |http|
36
48
  resp = http.request_get "/"
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
  spec = Gem::Specification.new do |s|
6
6
  s.name = "rubysspi"
7
7
  s.summary = "A library which adds implements Ruby bindings to the Win32 SSPI library. Also includes a module to add Negotate authentication support to Net::HTTP."
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
  s.author = "Justin Bailey"
10
10
  s.email = "jgbailey @nospan@ gmail.com"
11
11
  s.homepage = "http://rubyforge.org/projects/rubysspi/"
@@ -22,7 +22,7 @@ is set.
22
22
  EOS
23
23
 
24
24
  s.platform = Gem::Platform::CURRENT
25
- s.files = FileList["lib/**/*", "test/*", "*.txt", "Rakefile"].to_a
25
+ s.files = FileList["lib/**/*", "test/*", "*.txt", "Rakefile", "spa.rb"].to_a
26
26
 
27
27
  s.require_path = "lib"
28
28
  s.autorequire = "rubysspi"
data/lib/rubysspi.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'dl/win32'
1
+ require 'Win32API'
2
2
  require 'base64'
3
3
 
4
4
  # Implements bindings to Win32 SSPI functions, focused on authentication to a proxy server over HTTP.
@@ -24,13 +24,13 @@ module SSPI
24
24
  # Win32 API Functions. Uses dl/win32 to bind methods to constants contained in class.
25
25
  module API
26
26
  # Can be called with AcquireCredentialsHandle.call()
27
- AcquireCredentialsHandle = Win32API.new("secur32", "AcquireCredentialsHandle", ['ppLpppppp'], 'L')
28
- # Can be called with AcquireCredentialsHandle.call()
29
- InitializeSecurityContext = Win32API.new("secur32", "InitializeSecurityContext", [ 'pppLLLpLpppp'], 'L')
30
- # Can be called with AcquireCredentialsHandle.call()
31
- DeleteSecurityContext = Win32API.new("secur32", "DeleteSecurityContext", ['P'], 'L')
32
- # Can be called with AcquireCredentialsHandle.call()
33
- FreeCredentialsHandle = Win32API.new("secur32", "FreeCredentialsHandle", ['P'], 'L')
27
+ AcquireCredentialsHandle = Win32API.new("secur32", "AcquireCredentialsHandle", 'ppLpppppp', 'L')
28
+ # Can be called with InitializeSecurityContext.call()
29
+ InitializeSecurityContext = Win32API.new("secur32", "InitializeSecurityContext", 'pppLLLpLpppp', 'L')
30
+ # Can be called with DeleteSecurityContext.call()
31
+ DeleteSecurityContext = Win32API.new("secur32", "DeleteSecurityContext", 'P', 'L')
32
+ # Can be called with FreeCredentialsHandle.call()
33
+ FreeCredentialsHandle = Win32API.new("secur32", "FreeCredentialsHandle", 'P', 'L')
34
34
  end
35
35
 
36
36
  # SecHandle struct
@@ -291,7 +291,8 @@ module SSPI
291
291
  @credentials = CredHandle.new
292
292
  ts = TimeStamp.new
293
293
  @identity = Identity.new @user, @domain
294
- result = SSPIResult.new(API::AcquireCredentialsHandle.call(nil, "Negotiate", SECPKG_CRED_OUTBOUND, nil, @identity.to_p, nil, nil, @credentials.to_p, ts.to_p))
294
+ result = SSPIResult.new(API::AcquireCredentialsHandle.call(nil, "Negotiate", SECPKG_CRED_OUTBOUND, nil, @identity.to_p,
295
+ nil, nil, @credentials.to_p, ts.to_p))
295
296
  raise "Error acquire credentials: #{result}" unless result.ok?
296
297
  end
297
298
 
data/spa.rb ADDED
@@ -0,0 +1,19 @@
1
+ # Copy this file to site_ruby directory to enable inclusion of Negotiate authoritation on arbitrary scripts.
2
+ # For example, to run gems w/ the library use:
3
+ #
4
+ # ruby -rspa 'C:\Program Files\ruby\bin\gem'
5
+ #
6
+ # Notice the gem script is executed directly, instead of executing the gem.cmd file.
7
+ #
8
+
9
+ require 'pathname'
10
+ if (Pathname.new(__FILE__).dirname + "/lib/rubysspi.rb").exist?
11
+ # If running directly from root of gem, load rubysspi directly
12
+ $: << (Pathname.new(__FILE__).dirname + "/lib").to_s
13
+ require 'rubysspi/proxy_auth'
14
+ else
15
+ # Production require - must be running from site_ruby. Use rubygems to get
16
+ # to rubysspi
17
+ require 'rubygems'
18
+ require 'rubysspi/proxy_auth'
19
+ end
@@ -0,0 +1,21 @@
1
+ require 'test/unit'
2
+ require 'net/http'
3
+ require 'rubygems'
4
+ $: << (File.dirname(__FILE__) << "/../lib")
5
+ require 'rubysspi/proxy_auth'
6
+
7
+ class NTLMTest < Test::Unit::TestCase
8
+ def setup
9
+ assert ENV["http_proxy"], "http_proxy must be set before running tests."
10
+ end
11
+
12
+ # Previous implementation of rubysspi used dl/win32 and a
13
+ # bug occurred when gem list was executed. This tests to ensure
14
+ # bug does not come back.
15
+ def test_gem_list
16
+ Gem.manage_gems
17
+ assert_nothing_raised "'gem list --remote rubysspi' failed to execute" do
18
+ Gem::GemRunner.new.run(["list", "--remote", "rubysspi"])
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: rubysspi
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2006-07-14 00:00:00 -07:00
6
+ version: 0.0.2
7
+ date: 2006-07-17 00:00:00 -07:00
8
8
  summary: A library which adds implements Ruby bindings to the Win32 SSPI library. Also includes a module to add Negotate authentication support to Net::HTTP.
9
9
  require_paths:
10
10
  - lib
@@ -33,9 +33,11 @@ files:
33
33
  - lib/rubysspi.rb
34
34
  - lib/rubysspi/proxy_auth.rb
35
35
  - test/ruby_sspi_test.rb
36
+ - test/test_gem_list.rb
36
37
  - test/test_net_http.rb
37
38
  - README.txt
38
39
  - Rakefile
40
+ - spa.rb
39
41
  test_files: []
40
42
 
41
43
  rdoc_options: