net-ldap 0.3.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Contributors.rdoc +4 -0
- data/Hacking.rdoc +3 -8
- data/History.rdoc +181 -0
- data/README.rdoc +44 -12
- data/lib/net-ldap.rb +1 -1
- data/lib/net/ber.rb +41 -7
- data/lib/net/ber/ber_parser.rb +21 -7
- data/lib/net/ber/core_ext.rb +11 -18
- data/lib/net/ber/core_ext/array.rb +14 -0
- data/lib/net/ber/core_ext/integer.rb +74 -0
- data/lib/net/ber/core_ext/string.rb +24 -4
- data/lib/net/ber/core_ext/true_class.rb +2 -3
- data/lib/net/ldap.rb +441 -639
- data/lib/net/ldap/auth_adapter.rb +29 -0
- data/lib/net/ldap/auth_adapter/gss_spnego.rb +41 -0
- data/lib/net/ldap/auth_adapter/sasl.rb +62 -0
- data/lib/net/ldap/auth_adapter/simple.rb +34 -0
- data/lib/net/ldap/connection.rb +716 -0
- data/lib/net/ldap/dataset.rb +23 -9
- data/lib/net/ldap/dn.rb +13 -14
- data/lib/net/ldap/entry.rb +27 -9
- data/lib/net/ldap/error.rb +49 -0
- data/lib/net/ldap/filter.rb +58 -32
- data/lib/net/ldap/instrumentation.rb +23 -0
- data/lib/net/ldap/password.rb +23 -14
- data/lib/net/ldap/pdu.rb +70 -6
- data/lib/net/ldap/version.rb +5 -0
- data/lib/net/snmp.rb +237 -241
- metadata +71 -116
- data/.autotest +0 -11
- data/.gemtest +0 -0
- data/.rspec +0 -2
- data/Manifest.txt +0 -49
- data/Rakefile +0 -74
- data/autotest/discover.rb +0 -1
- data/lib/net/ber/core_ext/bignum.rb +0 -22
- data/lib/net/ber/core_ext/fixnum.rb +0 -66
- data/net-ldap.gemspec +0 -58
- data/spec/integration/ssl_ber_spec.rb +0 -36
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -5
- data/spec/unit/ber/ber_spec.rb +0 -109
- data/spec/unit/ber/core_ext/string_spec.rb +0 -51
- data/spec/unit/ldap/dn_spec.rb +0 -80
- data/spec/unit/ldap/entry_spec.rb +0 -51
- data/spec/unit/ldap/filter_spec.rb +0 -84
- data/spec/unit/ldap_spec.rb +0 -48
- data/test/common.rb +0 -3
- data/test/test_entry.rb +0 -59
- data/test/test_filter.rb +0 -122
- data/test/test_ldap_connection.rb +0 -24
- data/test/test_ldif.rb +0 -79
- data/test/test_password.rb +0 -17
- data/test/test_rename.rb +0 -77
- data/test/test_snmp.rb +0 -114
- data/test/testdata.ldif +0 -101
- data/testserver/ldapserver.rb +0 -210
- data/testserver/testdata.ldif +0 -101
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 02707fcb56d13184b4bbcc16c1555a0d417efb7e20c216a97ee8f28c9553ea84
|
4
|
+
data.tar.gz: 26a82f5021146fe6ec84d83e41722364964e155eb898102e3a8618facc020d9a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d19e1bc7cdcaceff6263f2bca2e9326ef441e301ab74556c42313e01704800abb59231f760abec64a8f2d1e313c18324b97c57a64d2b2ee24943be9e4bd2c428
|
7
|
+
data.tar.gz: fa69d36265e7b11b7c83cf812caca680e30af3a0be31c145d70396835081fc06f6a2bf43262ec08f4d6fab1094823dc70de069441229a991f3c5b2eadeb7c4e5
|
data/Contributors.rdoc
CHANGED
data/Hacking.rdoc
CHANGED
@@ -25,7 +25,7 @@ patches being accepted, we recommend that you follow the guidelines below:
|
|
25
25
|
|
26
26
|
== Documentation
|
27
27
|
|
28
|
-
* Documentation: {net-ldap}[http://net-ldap
|
28
|
+
* Documentation: {net-ldap}[http://rubydoc.info/gems/net-ldap]
|
29
29
|
|
30
30
|
It is very important that, if you add new methods or objects, your code is
|
31
31
|
well-documented. The purpose of the changes should be clearly described so that
|
@@ -40,8 +40,8 @@ modification to +Contributors.rdoc+ to add yourself.
|
|
40
40
|
|
41
41
|
== Tests
|
42
42
|
|
43
|
-
The Net::LDAP team uses
|
44
|
-
tests for any new or changed features.
|
43
|
+
The Net::LDAP team uses [Minitest](http://docs.seattlerb.org/minitest/) for unit
|
44
|
+
testing; all changes must have tests for any new or changed features.
|
45
45
|
|
46
46
|
Your changes should have been tested against at least one real LDAP server; the
|
47
47
|
current tests are not sufficient to find all possible bugs. It's unlikely that
|
@@ -55,14 +55,9 @@ us with a sample LDIF data file for importing into LDAP servers for testing.
|
|
55
55
|
Net::LDAP uses several libraries during development, all of which can be
|
56
56
|
installed using RubyGems.
|
57
57
|
|
58
|
-
* *hoe*
|
59
|
-
* *hoe-git*
|
60
|
-
* *metaid*
|
61
|
-
* *rspec*
|
62
58
|
* *flexmock*
|
63
59
|
|
64
60
|
== Participation
|
65
61
|
|
66
|
-
* RubyForge: {net-ldap}[http://rubyforge.org/projects/net-ldap]
|
67
62
|
* GitHub: {ruby-ldap/ruby-net-ldap}[https://github.com/ruby-ldap/ruby-net-ldap/]
|
68
63
|
* Group: {ruby-ldap}[http://groups.google.com/group/ruby-ldap]
|
data/History.rdoc
CHANGED
@@ -1,3 +1,184 @@
|
|
1
|
+
=== Net::LDAP 0.17.0
|
2
|
+
* Added private recursive_delete as alternative to DELETE_TREE #268
|
3
|
+
* Test suite updates #373 #376 #377
|
4
|
+
* Use Base64.strict_encode64 and SSHA256 #303
|
5
|
+
* Remove deprecated ConnectionRefusedError #366
|
6
|
+
* Added method to get a duplicate of the internal Hash #286
|
7
|
+
* remove a circular require #380
|
8
|
+
* fix LdapServerAsnSyntax compile #379
|
9
|
+
* Implement '==' operator for entries #381
|
10
|
+
* fix for undefined method for write exception #383
|
11
|
+
|
12
|
+
=== Net::LDAP 0.16.3
|
13
|
+
|
14
|
+
* Add Net::LDAP::InvalidDNError #371
|
15
|
+
* Use require_relative instead of require #360
|
16
|
+
* Address some warnings and fix JRuby test omissions #365
|
17
|
+
* Bump rake dev dependency to 12.3 #359
|
18
|
+
* Enable rubocop in ci #251
|
19
|
+
* Enhance rubocop configuration and test syntax #344
|
20
|
+
* CI: Drop rbx-2, uninstallable #364
|
21
|
+
* Fix RuboCop warnings #312
|
22
|
+
* Fix wrong error class #305
|
23
|
+
* CONTRIBUTING.md: Repair link to Issues #309
|
24
|
+
* Make the generate() method more idiomatic... #326
|
25
|
+
* Make encode_sort_controls() more idiomatic... #327
|
26
|
+
* Make the instrument() method more idiomatic... #328
|
27
|
+
* Fix uninitialised Net::LDAP::LdapPduError #338
|
28
|
+
* README.rdoc: Use SVG build badge #310
|
29
|
+
* Update TravisCI config to inclue Ruby 2.7 #346
|
30
|
+
* add explicit ** to silence Ruby 2.7 warning #342
|
31
|
+
* Support parsing filters with attribute tags #345
|
32
|
+
* Bump rubocop development dependency version #336
|
33
|
+
* Add link to generated and hosted documentation on rubydoc #319
|
34
|
+
* Fix 'uninitialized constant Net::LDAP::PDU::LdapPduError' error #317
|
35
|
+
* simplify encoding logic: no more chomping required #362
|
36
|
+
|
37
|
+
=== Net::LDAP 0.16.2
|
38
|
+
|
39
|
+
* Net::LDAP#open does not cache bind result {#334}[https://github.com/ruby-ldap/ruby-net-ldap/pull/334]
|
40
|
+
* Fix CI build {#333}[https://github.com/ruby-ldap/ruby-net-ldap/pull/333]
|
41
|
+
* Fix to "undefined method 'result_code'" {#308}[https://github.com/ruby-ldap/ruby-net-ldap/pull/308]
|
42
|
+
* Fixed Exception: incompatible character encodings: ASCII-8BIT and UTF-8 in filter.rb {#285}[https://github.com/ruby-ldap/ruby-net-ldap/pull/285]
|
43
|
+
|
44
|
+
=== Net::LDAP 0.16.1
|
45
|
+
|
46
|
+
* Send DN and newPassword with password_modify request {#271}[https://github.com/ruby-ldap/ruby-net-ldap/pull/271]
|
47
|
+
|
48
|
+
=== Net::LDAP 0.16.0
|
49
|
+
|
50
|
+
* Sasl fix {#281}[https://github.com/ruby-ldap/ruby-net-ldap/pull/281]
|
51
|
+
* enable TLS hostname validation {#279}[https://github.com/ruby-ldap/ruby-net-ldap/pull/279]
|
52
|
+
* update rubocop to 0.42.0 {#278}[https://github.com/ruby-ldap/ruby-net-ldap/pull/278]
|
53
|
+
|
54
|
+
=== Net::LDAP 0.15.0
|
55
|
+
|
56
|
+
* Respect connect_timeout when establishing SSL connections {#273}[https://github.com/ruby-ldap/ruby-net-ldap/pull/273]
|
57
|
+
|
58
|
+
=== Net::LDAP 0.14.0
|
59
|
+
|
60
|
+
* Normalize the encryption parameter passed to the LDAP constructor {#264}[https://github.com/ruby-ldap/ruby-net-ldap/pull/264]
|
61
|
+
* Update Docs: Net::LDAP now requires ruby >= 2 {#261}[https://github.com/ruby-ldap/ruby-net-ldap/pull/261]
|
62
|
+
* fix symbol proc {#255}[https://github.com/ruby-ldap/ruby-net-ldap/pull/255]
|
63
|
+
* fix trailing commas {#256}[https://github.com/ruby-ldap/ruby-net-ldap/pull/256]
|
64
|
+
* fix deprecated hash methods {#254}[https://github.com/ruby-ldap/ruby-net-ldap/pull/254]
|
65
|
+
* fix space after comma {#253}[https://github.com/ruby-ldap/ruby-net-ldap/pull/253]
|
66
|
+
* fix space inside brackets {#252}[https://github.com/ruby-ldap/ruby-net-ldap/pull/252]
|
67
|
+
* Rubocop style fixes {#249}[https://github.com/ruby-ldap/ruby-net-ldap/pull/249]
|
68
|
+
* Lazy initialize Net::LDAP::Connection's internal socket {#235}[https://github.com/ruby-ldap/ruby-net-ldap/pull/235]
|
69
|
+
* Support for rfc3062 Password Modify, closes #163 {#178}[https://github.com/ruby-ldap/ruby-net-ldap/pull/178]
|
70
|
+
|
71
|
+
=== Net::LDAP 0.13.0
|
72
|
+
|
73
|
+
Avoid this release for because of an backwards incompatibility in how encryption
|
74
|
+
is initialized https://github.com/ruby-ldap/ruby-net-ldap/pull/264. We did not
|
75
|
+
yank it because people have already worked around it.
|
76
|
+
|
77
|
+
* Set a connect_timeout for the creation of a socket {#243}[https://github.com/ruby-ldap/ruby-net-ldap/pull/243]
|
78
|
+
* Update bundler before installing gems with bundler {#245}[https://github.com/ruby-ldap/ruby-net-ldap/pull/245]
|
79
|
+
* Net::LDAP#encryption accepts string {#239}[https://github.com/ruby-ldap/ruby-net-ldap/pull/239]
|
80
|
+
* Adds correct UTF-8 encoding to Net::BER::BerIdentifiedString {#242}[https://github.com/ruby-ldap/ruby-net-ldap/pull/242]
|
81
|
+
* Remove 2.3.0-preview since ruby-head already is included {#241}[https://github.com/ruby-ldap/ruby-net-ldap/pull/241]
|
82
|
+
* Drop support for ruby 1.9.3 {#240}[https://github.com/ruby-ldap/ruby-net-ldap/pull/240]
|
83
|
+
* Fixed capitalization of StartTLSError {#234}[https://github.com/ruby-ldap/ruby-net-ldap/pull/234]
|
84
|
+
|
85
|
+
=== Net::LDAP 0.12.1
|
86
|
+
|
87
|
+
* Whitespace formatting cleanup {#236}[https://github.com/ruby-ldap/ruby-net-ldap/pull/236]
|
88
|
+
* Set operation result if LDAP server is not accessible {#232}[https://github.com/ruby-ldap/ruby-net-ldap/pull/232]
|
89
|
+
|
90
|
+
=== Net::LDAP 0.12.0
|
91
|
+
|
92
|
+
* DRY up connection handling logic {#224}[https://github.com/ruby-ldap/ruby-net-ldap/pull/224]
|
93
|
+
* Define auth adapters {#226}[https://github.com/ruby-ldap/ruby-net-ldap/pull/226]
|
94
|
+
* add slash to attribute value filter {#225}[https://github.com/ruby-ldap/ruby-net-ldap/pull/225]
|
95
|
+
* Add the ability to provide a list of hosts for a connection {#223}[https://github.com/ruby-ldap/ruby-net-ldap/pull/223]
|
96
|
+
* Specify the port of LDAP server by giving INTEGRATION_PORT {#221}[https://github.com/ruby-ldap/ruby-net-ldap/pull/221]
|
97
|
+
* Correctly set BerIdentifiedString values to UTF-8 {#212}[https://github.com/ruby-ldap/ruby-net-ldap/pull/212]
|
98
|
+
* Raise Net::LDAP::ConnectionRefusedError when new connection is refused. {#213}[https://github.com/ruby-ldap/ruby-net-ldap/pull/213]
|
99
|
+
* obscure auth password upon #inspect, added test, closes #216 {#217}[https://github.com/ruby-ldap/ruby-net-ldap/pull/217]
|
100
|
+
* Fixing incorrect error class name {#207}[https://github.com/ruby-ldap/ruby-net-ldap/pull/207]
|
101
|
+
* Travis update {#205}[https://github.com/ruby-ldap/ruby-net-ldap/pull/205]
|
102
|
+
* Remove obsolete rbx-19mode from Travis {#204}[https://github.com/ruby-ldap/ruby-net-ldap/pull/204]
|
103
|
+
* mv "sudo" from script/install-openldap to .travis.yml {#199}[https://github.com/ruby-ldap/ruby-net-ldap/pull/199]
|
104
|
+
* Remove meaningless shebang {#200}[https://github.com/ruby-ldap/ruby-net-ldap/pull/200]
|
105
|
+
* Fix Travis CI build {#202}[https://github.com/ruby-ldap/ruby-net-ldap/pull/202]
|
106
|
+
* README.rdoc: fix travis link {#195}[https://github.com/ruby-ldap/ruby-net-ldap/pull/195]
|
107
|
+
|
108
|
+
=== Net::LDAP 0.11
|
109
|
+
* Major enhancements:
|
110
|
+
* #183 Specific errors subclassing Net::LDAP::Error
|
111
|
+
* Bug fixes:
|
112
|
+
* #176 Fix nil tls options
|
113
|
+
* #184 Search guards against nil queued reads. Connection#unescape handles numerics
|
114
|
+
* Code clean-up:
|
115
|
+
* #180 Refactor connection establishment
|
116
|
+
|
117
|
+
=== Net::LDAP 0.10.1
|
118
|
+
* Bug fixes:
|
119
|
+
* Fix Integer BER encoding of signed values
|
120
|
+
|
121
|
+
=== Net::LDAP 0.10.0
|
122
|
+
* Major enhancements:
|
123
|
+
* Accept SimpleTLS/StartTLS encryption options (compatible with `OpenSSL::SSL::SSLContext#set_params`)
|
124
|
+
* Bug fixes:
|
125
|
+
* Parse filter strings with square and curly braces (`[]` and `{}`)
|
126
|
+
* Handle connection timeout errors (`Errno::ETIMEDOUT` raised as `Net::LDAP::LdapError`)
|
127
|
+
* Testing changes:
|
128
|
+
* Add integration tests for StartTLS connections to OpenLDAP
|
129
|
+
* Meta changes:
|
130
|
+
* Update Gem release tooling (remove Hoe, use Rake)
|
131
|
+
* Fix Gem release date
|
132
|
+
|
133
|
+
=== Net::LDAP 0.9.0
|
134
|
+
* Major changes:
|
135
|
+
* Dropped support for ruby 1.8.7, ruby >= 1.9.3 now required
|
136
|
+
* Major enhancements:
|
137
|
+
* Add support for search time limit parameter
|
138
|
+
* Instrument received messages, PDU parsing
|
139
|
+
* Minor enhancments:
|
140
|
+
* Add support for querying ActiveDirectory capabilities from root dse
|
141
|
+
* Bug fixes:
|
142
|
+
* Fix reads for multiple concurrent requests with shared, open connections mixing up the results
|
143
|
+
* Fix search size option
|
144
|
+
* Fix BER encoding bug
|
145
|
+
* Code clean-up:
|
146
|
+
* Added integration test suite
|
147
|
+
* Switch to minitest
|
148
|
+
|
149
|
+
* Details
|
150
|
+
* #150 Support querying ActiveDirectory capabilities when searching root dse
|
151
|
+
* #142 Encode true as xFF
|
152
|
+
* #124, #145, #146, #152 Cleanup gemspec
|
153
|
+
* #138, #144 Track response messages by message id
|
154
|
+
* #141 Magic number/constant cleanup
|
155
|
+
* #119, #129, #130, #132, #133, #137 Integration tests
|
156
|
+
* #115 Search timeout support
|
157
|
+
* #140 Fix search size option
|
158
|
+
* #139 Cleanup and inline documentation for Net::LDAP::Connection#search
|
159
|
+
* #131 Instrumentation
|
160
|
+
* #116 Refactor Connection#write
|
161
|
+
* #126 Update gitignore
|
162
|
+
* #128 Fix whitespace
|
163
|
+
* #113, #121 Switch to minitest
|
164
|
+
* #123 Base64 encoded dn
|
165
|
+
* #114 Separate file for Net::LDAP::Connection
|
166
|
+
* #104 Parse version spec in LDIF datasets
|
167
|
+
* #106 ldap.modify doc fixes
|
168
|
+
* #111 Fix test deprecations
|
169
|
+
|
170
|
+
=== Net::LDAP 0.5.0 / 2013-07-22
|
171
|
+
* Major changes:
|
172
|
+
* Required Ruby version is >=1.9.3
|
173
|
+
* Major enhancements:
|
174
|
+
* Added alias dereferencing (@ngwilson)
|
175
|
+
* BER now unescapes characters that are already escaped in the source string (@jzinn)
|
176
|
+
* BerIdentifiedString will now fall back to ASCII-8 encoding if the source Ruby object cannot be encoded in UTF-8 (@lfu)
|
177
|
+
* Bug fixes:
|
178
|
+
* Fixed nil variable error when following a reference response (@cmdrclueless)
|
179
|
+
* Fixed FilterParser unable to parse multibyte strings (@satoryu)
|
180
|
+
* Return ConverterNotFound when dealing with a potentially corrupt data response (@jamuc)
|
181
|
+
|
1
182
|
=== Net::LDAP 0.3.1 / 2012-02-15
|
2
183
|
* Bug Fixes:
|
3
184
|
* Bundler should now work again
|
data/README.rdoc
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
= Net::LDAP for Ruby
|
1
|
+
= Net::LDAP for Ruby
|
2
|
+
{<img src="https://badge.fury.io/rb/net-ldap.svg" alt="Gem Version" />}[https://badge.fury.io/rb/net-ldap]
|
3
|
+
{<img src="https://travis-ci.org/ruby-ldap/ruby-net-ldap.svg" />}[https://travis-ci.org/ruby-ldap/ruby-net-ldap]
|
2
4
|
|
3
5
|
== Description
|
4
6
|
|
@@ -16,21 +18,16 @@ the most recent LDAP RFCs (4510–4519, plus portions of 4520–4532).
|
|
16
18
|
|
17
19
|
== Where
|
18
20
|
|
19
|
-
* {RubyForge}[http://rubyforge.org/projects/net-ldap]
|
20
21
|
* {GitHub}[https://github.com/ruby-ldap/ruby-net-ldap]
|
21
22
|
* {ruby-ldap@googlegroups.com}[http://groups.google.com/group/ruby-ldap]
|
22
|
-
* {Documentation}[http://net-ldap.rubyforge.org/]
|
23
|
-
|
24
|
-
The Net::LDAP for Ruby documentation, project description, and main downloads
|
25
|
-
can currently be found on {RubyForge}[http://rubyforge.org/projects/net-ldap].
|
26
23
|
|
27
24
|
== Synopsis
|
28
25
|
|
29
|
-
See Net::LDAP for documentation and usage samples.
|
26
|
+
See {Net::LDAP on rubydoc.info}[https://www.rubydoc.info/gems/net-ldap/Net/LDAP] for documentation and usage samples.
|
30
27
|
|
31
28
|
== Requirements
|
32
29
|
|
33
|
-
Net::LDAP requires a Ruby
|
30
|
+
Net::LDAP requires a Ruby 2.0.0 compatible interpreter or better.
|
34
31
|
|
35
32
|
== Install
|
36
33
|
|
@@ -42,10 +39,45 @@ sources.
|
|
42
39
|
|
43
40
|
Simply require either 'net-ldap' or 'net/ldap'.
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
== Extensions
|
43
|
+
|
44
|
+
This library focuses on the core LDAP RFCs referenced in the description.
|
45
|
+
However, we recognize there are commonly used extensions to the spec that are
|
46
|
+
useful. If there is another library which handles it, we list it here.
|
47
|
+
|
48
|
+
* {resolv-srv}[https://rubygems.org/gems/resolv-srv]: Support RFC2782 SRV record lookup and failover
|
49
|
+
|
50
|
+
== Develop
|
51
|
+
|
52
|
+
This task will run the test suite and the
|
53
|
+
{RuboCop}[https://github.com/bbatsov/rubocop] static code analyzer.
|
54
|
+
|
55
|
+
rake rubotest
|
56
|
+
|
57
|
+
CI takes too long? If your local box supports
|
58
|
+
{Docker}[https://www.docker.com/], you can also run integration tests locally.
|
59
|
+
Simply run:
|
60
|
+
|
61
|
+
script/ldap-docker
|
62
|
+
INTEGRATION=openldap rake test
|
63
|
+
|
64
|
+
Or, use {Docker Compose}[https://docs.docker.com/compose/]. See docker-compose.yml for available Ruby versions.
|
65
|
+
|
66
|
+
docker-compose run ci-2.7
|
67
|
+
|
68
|
+
CAVEAT: you need to add the following line to /etc/hosts
|
69
|
+
127.0.0.1 ldap.example.org
|
70
|
+
127.0.0.1 cert.mismatch.example.org
|
71
|
+
|
72
|
+
== Release
|
73
|
+
|
74
|
+
This section is for gem maintainers to cut a new version of the gem.
|
75
|
+
|
76
|
+
* Check out a new branch `release-VERSION`
|
77
|
+
* Update lib/net/ldap/version.rb to next version number X.X.X following {semver}[http://semver.org/].
|
78
|
+
* Update `History.rdoc`. Get latest changes with `script/changelog`
|
79
|
+
* Open a pull request with these changes for review
|
80
|
+
* After merging, on the master branch, run `script/release`
|
49
81
|
|
50
82
|
:include: Contributors.rdoc
|
51
83
|
|
data/lib/net-ldap.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
|
-
|
2
|
+
require_relative 'net/ldap'
|
data/lib/net/ber.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
|
+
require_relative 'ldap/version'
|
3
|
+
|
2
4
|
module Net # :nodoc:
|
3
5
|
##
|
4
6
|
# == Basic Encoding Rules (BER) Support Module
|
@@ -104,9 +106,10 @@ module Net # :nodoc:
|
|
104
106
|
# <tr><th>CHARACTER STRING</th><th>C</th><td>29: 61 (0x3d, 0b00111101)</td></tr>
|
105
107
|
# <tr><th>BMPString</th><th>P</th><td>30: 30 (0x1e, 0b00011110)</td></tr>
|
106
108
|
# <tr><th>BMPString</th><th>C</th><td>30: 62 (0x3e, 0b00111110)</td></tr>
|
109
|
+
# <tr><th>ExtendedResponse</th><th>C</th><td>107: 139 (0x8b, 0b010001011)</td></tr>
|
107
110
|
# </table>
|
108
111
|
module BER
|
109
|
-
VERSION =
|
112
|
+
VERSION = Net::LDAP::VERSION
|
110
113
|
|
111
114
|
##
|
112
115
|
# Used for BER-encoding the length and content bytes of a Fixnum integer
|
@@ -232,7 +235,7 @@ module Net # :nodoc:
|
|
232
235
|
# TODO 20100327 AZ: Should we be allocating an array of 256 values
|
233
236
|
# that will either be +nil+ or an object type symbol, or should we
|
234
237
|
# allocate an empty Hash since unknown values return +nil+ anyway?
|
235
|
-
out = [
|
238
|
+
out = [nil] * 256
|
236
239
|
syntax.each do |tag_class_id, encodings|
|
237
240
|
tag_class = TAG_CLASS[tag_class_id]
|
238
241
|
encodings.each do |encoding_id, classes|
|
@@ -267,7 +270,7 @@ class Net::BER::BerIdentifiedOid
|
|
267
270
|
|
268
271
|
def initialize(oid)
|
269
272
|
if oid.is_a?(String)
|
270
|
-
oid = oid.split(/\./).map
|
273
|
+
oid = oid.split(/\./).map(&:to_i)
|
271
274
|
end
|
272
275
|
@value = oid
|
273
276
|
end
|
@@ -291,12 +294,43 @@ end
|
|
291
294
|
|
292
295
|
##
|
293
296
|
# A String object with a BER identifier attached.
|
297
|
+
#
|
294
298
|
class Net::BER::BerIdentifiedString < String
|
295
299
|
attr_accessor :ber_identifier
|
300
|
+
|
301
|
+
# The binary data provided when parsing the result of the LDAP search
|
302
|
+
# has the encoding 'ASCII-8BIT' (which is basically 'BINARY', or 'unknown').
|
303
|
+
#
|
304
|
+
# This is the kind of a backtrace showing how the binary `data` comes to
|
305
|
+
# BerIdentifiedString.new(data):
|
306
|
+
#
|
307
|
+
# @conn.read_ber(syntax)
|
308
|
+
# -> StringIO.new(self).read_ber(syntax), i.e. included from module
|
309
|
+
# -> Net::BER::BERParser.read_ber(syntax)
|
310
|
+
# -> (private)Net::BER::BERParser.parse_ber_object(syntax, id, data)
|
311
|
+
#
|
312
|
+
# In the `#parse_ber_object` method `data`, according to its OID, is being
|
313
|
+
# 'casted' to one of the Net::BER:BerIdentifiedXXX classes.
|
314
|
+
#
|
315
|
+
# As we are using LDAP v3 we can safely assume that the data is encoded
|
316
|
+
# in UTF-8 and therefore the only thing to be done when instantiating is to
|
317
|
+
# switch the encoding from 'ASCII-8BIT' to 'UTF-8'.
|
318
|
+
#
|
319
|
+
# Unfortunately, there are some ActiveDirectory specific attributes
|
320
|
+
# (like `objectguid`) that should remain binary (do they really?).
|
321
|
+
# Using the `#valid_encoding?` we can trap this cases. Special cases like
|
322
|
+
# Japanese, Korean, etc. encodings might also profit from this. However
|
323
|
+
# I have no clue how this encodings function.
|
296
324
|
def initialize args
|
297
|
-
super
|
298
|
-
#
|
299
|
-
|
325
|
+
super
|
326
|
+
#
|
327
|
+
# Check the encoding of the newly created String and set the encoding
|
328
|
+
# to 'UTF-8' (NOTE: we do NOT change the bytes, but only set the
|
329
|
+
# encoding to 'UTF-8').
|
330
|
+
return unless encoding == Encoding::BINARY
|
331
|
+
current_encoding = encoding
|
332
|
+
force_encoding('UTF-8')
|
333
|
+
force_encoding(current_encoding) unless valid_encoding?
|
300
334
|
end
|
301
335
|
end
|
302
336
|
|
@@ -315,4 +349,4 @@ module Net::BER
|
|
315
349
|
Null = Net::BER::BerIdentifiedNull.new
|
316
350
|
end
|
317
351
|
|
318
|
-
|
352
|
+
require_relative 'ber/core_ext'
|
data/lib/net/ber/ber_parser.rb
CHANGED
@@ -14,7 +14,7 @@ module Net::BER::BERParser
|
|
14
14
|
}
|
15
15
|
constructed = {
|
16
16
|
16 => :array,
|
17
|
-
17 => :array
|
17
|
+
17 => :array,
|
18
18
|
}
|
19
19
|
universal = { :primitive => primitive, :constructed => constructed }
|
20
20
|
|
@@ -41,9 +41,18 @@ module Net::BER::BERParser
|
|
41
41
|
s.ber_identifier = id
|
42
42
|
s
|
43
43
|
elsif object_type == :integer
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
neg = !(data.unpack("C").first & 0x80).zero?
|
45
|
+
int = 0
|
46
|
+
|
47
|
+
data.each_byte do |b|
|
48
|
+
int = (int << 8) + (neg ? 255 - b : b)
|
49
|
+
end
|
50
|
+
|
51
|
+
if neg
|
52
|
+
(int + 1) * -1
|
53
|
+
else
|
54
|
+
int
|
55
|
+
end
|
47
56
|
elsif object_type == :oid
|
48
57
|
# See X.690 pgh 8.19 for an explanation of this algorithm.
|
49
58
|
# This is potentially not good enough. We may need a
|
@@ -148,6 +157,9 @@ module Net::BER::BERParser
|
|
148
157
|
# implemented on the including object and that it returns a Fixnum value.
|
149
158
|
# Also requires #read(bytes) to work.
|
150
159
|
#
|
160
|
+
# Yields the object type `id` and the data `content_length` if a block is
|
161
|
+
# given. This is namely to support instrumentation.
|
162
|
+
#
|
151
163
|
# This does not work with non-blocking I/O.
|
152
164
|
def read_ber(syntax = nil)
|
153
165
|
# TODO: clean this up so it works properly with partial packets coming
|
@@ -157,11 +169,13 @@ module Net::BER::BERParser
|
|
157
169
|
id = getbyte or return nil # don't trash this value, we'll use it later
|
158
170
|
content_length = read_ber_length
|
159
171
|
|
172
|
+
yield id, content_length if block_given?
|
173
|
+
|
160
174
|
if -1 == content_length
|
161
|
-
raise Net::BER::BerError,
|
162
|
-
|
163
|
-
data = read(content_length)
|
175
|
+
raise Net::BER::BerError,
|
176
|
+
"Indeterminite BER content length not implemented."
|
164
177
|
end
|
178
|
+
data = read(content_length)
|
165
179
|
|
166
180
|
parse_ber_object(syntax, id, data)
|
167
181
|
end
|