jruby-ldap 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jruby-ldap.gemspec
4
+ gemspec
@@ -0,0 +1,7 @@
1
+ == 0.0.2 (03/12/12)
2
+
3
+ - 1.9 compatibility (thanks Arkadiy Kraportov)
4
+
5
+ == 0.0.1 (10/09/07)
6
+
7
+ - Initial release.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require 'rake'
2
1
  require 'rake/testtask'
2
+ require 'bundler/gem_tasks'
3
3
 
4
- task :default => [:test, :package]
4
+ task :default => [:test, :build]
5
5
 
6
6
  desc "Run all tests"
7
7
  task :test => [:test_all]
@@ -12,31 +12,3 @@ Rake::TestTask.new(:test_all) do |t|
12
12
  t.libs.delete("lib") unless defined?(JRUBY_VERSION)
13
13
  end
14
14
 
15
-
16
- task :filelist do
17
- puts FileList['pkg/**/*'].inspect
18
- end
19
-
20
- MANIFEST = FileList["lib/**/*.rb", "test/**/*.rb", "Rakefile", "LICENSE", "README"]
21
-
22
- file "Manifest.txt" => :manifest
23
- task :manifest do
24
- File.open("Manifest.txt", "w") {|f| MANIFEST.each {|n| f << "#{n}\n"} }
25
- end
26
-
27
- Rake::Task['manifest'].invoke # Always regen manifest, so Hoe has up-to-date list of files
28
-
29
- begin
30
- require 'hoe'
31
- Hoe.new("jruby-ldap", "0.0.1") do |p|
32
- p.rubyforge_name = "jruby-extras"
33
- p.url = "http://jruby-extras.rubyforge.org/jruby-ldap"
34
- p.author = "Ola Bini"
35
- p.email = "ola.bini@gmail.com"
36
- p.summary = "Port of Ruby/LDAP to JRuby"
37
- end.spec.dependencies.delete_if { |dep| dep.name == "hoe" }
38
- rescue LoadError
39
- puts "You really need Hoe installed to be able to package this gem"
40
- rescue => e
41
- puts "ignoring error while loading hoe: #{e.to_s}"
42
- end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "jruby-ldap/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "jruby-ldap"
7
+ s.version = JRuby::LDAP::VERSION
8
+ s.authors = ["Ola Bini"]
9
+ s.email = ["ola.bini@gmail.com"]
10
+ s.homepage = "http://jruby-extras.rubyforge.org/jruby-ldap"
11
+ s.summary = "Port of Ruby/LDAP to JRuby"
12
+ s.description = "Port of Ruby/LDAP to JRuby"
13
+ s.rubyforge_project = "jruby-extras"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,7 @@
1
+ require "jruby-ldap/version"
2
+
3
+ module JRuby
4
+ module LDAP
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module JRuby
2
+ module LDAP
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -3,51 +3,51 @@ require 'java'
3
3
  module LDAP
4
4
  def self.err2string(err)
5
5
  case err||0
6
- when -1: "Can't contact LDAP server"
7
- when 0: "Success"
8
- when 1: "Operations error"
9
- when 2: "Protocol error"
10
- when 3: "Time limit exceeded"
11
- when 4: "Size limit exceeded"
12
- when 5: "Compare False"
13
- when 6: "Compare True"
14
- when 7: "Authentication method not supported"
15
- when 8: "Strong(er) authentication required"
16
- when 9: "Partial results and referral received"
17
- when 10: "Referral"
18
- when 11: "Administrative limit exceeded"
19
- when 12: "Critical extension is unavailable"
20
- when 13: "Confidentiality required"
21
- when 14: "SASL bind in progress"
22
- when 15: "Unknown error"
23
- when 16: "No such attribute"
24
- when 17: "Undefined attribute type"
25
- when 18: "Inappropriate matching"
26
- when 19: "Constraint violation"
27
- when 20: "Type or value exists"
28
- when 21: "Invalid syntax"
29
- when 32: "No such object"
30
- when 33: "Alias problem"
31
- when 34: "Invalid DN syntax"
32
- when 35: "Entry is a leaf"
33
- when 36: "Alias dereferencing problem"
34
- when 47: "Proxy Authorization Failure"
35
- when 48: "Inappropriate authentication"
36
- when 49: "Invalid credentials"
37
- when 50: "Insufficient access"
38
- when 51: "Server is busy"
39
- when 52: "Server is unavailable"
40
- when 53: "Server is unwilling to perform"
41
- when 54: "Loop detected"
42
- when 64: "Naming violation"
43
- when 65: "Object class violation"
44
- when 66: "Operation not allowed on non-leaf"
45
- when 67: "Operation not allowed on RDN"
46
- when 68: "Already exists"
47
- when 69: "Cannot modify object class"
48
- when 70: "Results too large"
49
- when 71: "Operation affects multiple DSAs"
50
- when 80: "Internal (implementation specific) error"
6
+ when -1 then "Can't contact LDAP server"
7
+ when 0 then "Success"
8
+ when 1 then "Operations error"
9
+ when 2 then "Protocol error"
10
+ when 3 then "Time limit exceeded"
11
+ when 4 then "Size limit exceeded"
12
+ when 5 then "Compare False"
13
+ when 6 then "Compare True"
14
+ when 7 then "Authentication method not supported"
15
+ when 8 then "Strong(er) authentication required"
16
+ when 9 then "Partial results and referral received"
17
+ when 10 then "Referral"
18
+ when 11 then "Administrative limit exceeded"
19
+ when 12 then "Critical extension is unavailable"
20
+ when 13 then "Confidentiality required"
21
+ when 14 then "SASL bind in progress"
22
+ when 15 then "Unknown error"
23
+ when 16 then "No such attribute"
24
+ when 17 then "Undefined attribute type"
25
+ when 18 then "Inappropriate matching"
26
+ when 19 then "Constraint violation"
27
+ when 20 then "Type or value exists"
28
+ when 21 then "Invalid syntax"
29
+ when 32 then "No such object"
30
+ when 33 then "Alias problem"
31
+ when 34 then "Invalid DN syntax"
32
+ when 35 then "Entry is a leaf"
33
+ when 36 then "Alias dereferencing problem"
34
+ when 47 then "Proxy Authorization Failure"
35
+ when 48 then "Inappropriate authentication"
36
+ when 49 then "Invalid credentials"
37
+ when 50 then "Insufficient access"
38
+ when 51 then "Server is busy"
39
+ when 52 then "Server is unavailable"
40
+ when 53 then "Server is unwilling to perform"
41
+ when 54 then "Loop detected"
42
+ when 64 then "Naming violation"
43
+ when 65 then "Object class violation"
44
+ when 66 then "Operation not allowed on non-leaf"
45
+ when 67 then "Operation not allowed on RDN"
46
+ when 68 then "Already exists"
47
+ when 69 then "Cannot modify object class"
48
+ when 70 then "Results too large"
49
+ when 71 then "Operation affects multiple DSAs"
50
+ when 80 then "Internal (implementation specific) error"
51
51
  else "Unknown error"
52
52
  end
53
53
  end
@@ -70,7 +70,7 @@ module LDAP
70
70
  end
71
71
 
72
72
  def self.configuration(attrs = { })
73
- @environment.update attrs
73
+ @environment.merge attrs
74
74
  end
75
75
  end
76
76
 
@@ -1,9 +1,5 @@
1
1
  module LDAP
2
2
  module ConnImplementation
3
- def compare(*args)
4
- raise "NOT IMPLEMENTED"
5
- end
6
-
7
3
  def controls(*args)
8
4
  raise "NOT IMPLEMENTED"
9
5
  end
@@ -12,8 +8,35 @@ module LDAP
12
8
  raise "NOT IMPLEMENTED"
13
9
  end
14
10
 
15
- def modrdn(*args)
16
- raise "NOT IMPLEMENTED"
11
+ # Modify the RDN of the entry with DN, +dn+, giving it the new RDN,
12
+ # +new_rdn+. If +delete_old_rdn+ is *true*, the old RDN value will be deleted
13
+ # from the entry.
14
+ def modrdn(dn, new_rdn, delete_old_rdn)
15
+ begin
16
+ if delete_old_rdn
17
+ @context.rename(dn, new_rdn)
18
+ else
19
+ obj = @context.lookup(dn)
20
+ @context.bind(new_rdn, obj)
21
+ end
22
+ @err = 0
23
+ rescue javax.naming.NameAlreadyBoundException => e
24
+ @err = 68
25
+ rescue javax.naming.InvalidNameException => e
26
+ @err = 34
27
+ rescue javax.naming.NoPermissionException => e
28
+ @err = 50
29
+ rescue javax.naming.directory.SchemaViolationException => e
30
+ @err = 65
31
+ rescue javax.naming.NamingException => e
32
+ @err = 21
33
+ rescue javax.naming.NoPermissionException => e
34
+ @err = 50
35
+ rescue javax.naming.NamingException => e
36
+ @err = -1
37
+ end
38
+ raise LDAP::ResultError.wrap(LDAP::err2string(@err), e) if @err != 0
39
+ self
17
40
  end
18
41
 
19
42
  def perror(*args)
@@ -26,9 +26,9 @@ module LDAP
26
26
 
27
27
  def ruby_mod_to_java(mod_op)
28
28
  case (mod_op&~LDAP::LDAP_MOD_BVALUES)
29
- when LDAP::LDAP_MOD_ADD: DirContext::ADD_ATTRIBUTE
30
- when LDAP::LDAP_MOD_REPLACE: DirContext::REPLACE_ATTRIBUTE
31
- when LDAP::LDAP_MOD_DELETE: DirContext::REMOVE_ATTRIBUTE
29
+ when LDAP::LDAP_MOD_ADD then DirContext::ADD_ATTRIBUTE
30
+ when LDAP::LDAP_MOD_REPLACE then DirContext::REPLACE_ATTRIBUTE
31
+ when LDAP::LDAP_MOD_DELETE then DirContext::REMOVE_ATTRIBUTE
32
32
  else raise LDAP::Error, "can't handle operation #{mod_op}"
33
33
  end
34
34
  end
@@ -59,7 +59,7 @@ module LDAP
59
59
  def to_java_attribute
60
60
  v = BasicAttribute.new(self.mod_type)
61
61
  binary = mod_op & LDAP::LDAP_MOD_BVALUES
62
- if binary
62
+ if binary != 0
63
63
  self.mod_vals.each do |val|
64
64
  v.add(val.to_java_bytes)
65
65
  end
@@ -1,4 +1,5 @@
1
-
1
+ require 'rubygems'
2
+ require 'bundler/setup'
2
3
  require 'ldap'
3
4
  require './username_and_password'
4
5
 
metadata CHANGED
@@ -1,64 +1,83 @@
1
- --- !ruby/object:Gem::Specification
2
- required_ruby_version: !ruby/object:Gem::Version::Requirement
3
- requirements:
4
- - - '>'
5
- - !ruby/object:Gem::Version
6
- version: 0.0.0
7
- version:
8
- email: ola.bini@gmail.com
9
- cert_chain:
10
- summary: Port of Ruby/LDAP to JRuby
11
- post_install_message:
12
- homepage: http://jruby-extras.rubyforge.org/jruby-ldap
13
- extra_rdoc_files: []
14
- signing_key:
1
+ --- !ruby/object:Gem::Specification
15
2
  name: jruby-ldap
16
- rdoc_options:
17
- - --main
18
- - README.txt
19
- rubyforge_project: jruby-extras
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.2
6
+ platform: ruby
7
+ authors:
8
+ - Ola Bini
20
9
  autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-03-12 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: Port of Ruby/LDAP to JRuby
17
+ email:
18
+ - ola.bini@gmail.com
21
19
  executables: []
22
- description: The author was too lazy to write a description
23
- default_executable:
24
- files:
25
- - lib/ldap.rb
26
- - lib/ldap/conn.rb
27
- - lib/ldap/constants.rb
28
- - lib/ldap/control.rb
29
- - lib/ldap/entry.rb
30
- - lib/ldap/error.rb
31
- - lib/ldap/ldif.rb
32
- - lib/ldap/mod.rb
33
- - lib/ldap/schema.rb
34
- - test/setup.rb
35
- - test/test_add.rb
36
- - test/test_connection.rb
37
- - test/test_delete.rb
38
- - test/test_search.rb
39
- - test/test_ssl.rb
40
- - test/username_and_password.rb
41
- - Rakefile
42
- - LICENSE
43
- - README
44
- specification_version: 1
20
+
45
21
  extensions: []
46
- rubygems_version: 0.9.4
47
- requirements: []
48
- authors:
49
- - Ola Bini
50
- platform: ruby
51
- date: 2007-10-09 23:00:00 +00:00
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - .gitignore
27
+ - Gemfile
28
+ - History.txt
29
+ - LICENSE
30
+ - README
31
+ - Rakefile
32
+ - jruby-ldap.gemspec
33
+ - lib/jruby-ldap.rb
34
+ - lib/jruby-ldap/version.rb
35
+ - lib/ldap.rb
36
+ - lib/ldap/conn.rb
37
+ - lib/ldap/constants.rb
38
+ - lib/ldap/control.rb
39
+ - lib/ldap/entry.rb
40
+ - lib/ldap/error.rb
41
+ - lib/ldap/ldif.rb
42
+ - lib/ldap/mod.rb
43
+ - lib/ldap/schema.rb
44
+ - test/setup.rb
45
+ - test/test_add.rb
46
+ - test/test_connection.rb
47
+ - test/test_delete.rb
48
+ - test/test_search.rb
49
+ - test/test_ssl.rb
50
+ homepage: http://jruby-extras.rubyforge.org/jruby-ldap
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options: []
55
+
52
56
  require_paths:
53
- - lib
54
- version: !ruby/object:Gem::Version
55
- version: 0.0.1
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ requirements: []
71
+
72
+ rubyforge_project: jruby-extras
73
+ rubygems_version: 1.8.15
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Port of Ruby/LDAP to JRuby
56
77
  test_files:
57
- - test/test_add.rb
58
- - test/test_connection.rb
59
- - test/test_delete.rb
60
- - test/test_search.rb
61
- - test/test_ssl.rb
62
- bindir: bin
63
- dependencies: []
64
- has_rdoc: true
78
+ - test/setup.rb
79
+ - test/test_add.rb
80
+ - test/test_connection.rb
81
+ - test/test_delete.rb
82
+ - test/test_search.rb
83
+ - test/test_ssl.rb
@@ -1,2 +0,0 @@
1
- $LDAP_test_username = 'cn=olabini'
2
- $LDAP_test_password = 'd3$tRuct1on'