activeldap 6.0.1 → 6.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a46a7f1f206eab425b0a3ec483c44c66622a65958fc34fe658313e152563e9b
4
- data.tar.gz: e7fafc57db50aaaf81dc7f087328b87b8d5a78ed96b552c91bb7bd4234876eb5
3
+ metadata.gz: 6e102a4e1e1913dcbc4ba91e6efdcf1c810273ab0df7843dda96e7a25448115e
4
+ data.tar.gz: 641ed3e13f779e61a8ca2bb7b7451a2a262e6118cf3ebae09e05bca731ed3531
5
5
  SHA512:
6
- metadata.gz: d89e9298c051c069236b7949d7597d61c57da5e69bee171bf51cbe24607edc2a319ed65604d34bd5928da4674a3558a0e75e9fe3e874a1f812a8a40bf97877db
7
- data.tar.gz: 0ea20f5c3f37691493ee5a05324d94645de90520cf15a44ba35e7f9692b8f26b113639a4d34df6679a76a84a6a44a7a86b87faa62d59c3c9176ec678750a9d8d
6
+ metadata.gz: 8cdb1be2238d42a244c1e4bfd1d02741b3944f16bbfdd4b787fa07d7b16fb9c054f91316b540eec1e27660a16fe84a6fed30cdbb103d04bab565f4f1ed366026
7
+ data.tar.gz: bd5abb24368bc0e966398d8352b323f665ee6c9ff7ccb3d7cbaea556b87c0c9885458dcaba804176ba8992ad513e812a4e3a357c380fa14801e2b7838cbbc790
@@ -1,5 +1,19 @@
1
1
  # News
2
2
 
3
+ ## 6.0.2: 2020-05-19 {#release-6-0-2}
4
+
5
+ ### Improvements
6
+
7
+ * Added `options` to {ActiveLdap::Persistance#reload}.
8
+ [GitHub#176][Reported by Kevin McCormack]
9
+
10
+ * jndi: Improved DN escaping.
11
+ [GitHub#178][Patch by Kevin McCormack]
12
+
13
+ ### Thanks
14
+
15
+ * Kevin McCormack
16
+
3
17
  ## 6.0.1: 2020-04-21 {#release-6-0-1}
4
18
 
5
19
  ### Improvements
@@ -136,6 +136,7 @@ module ActiveLdap
136
136
  end
137
137
 
138
138
  escaped_base = escape_dn(base)
139
+
139
140
  loop do
140
141
  @context.search(escaped_base, filter, controls).each do |search_result|
141
142
  yield(build_raw_search_result(search_result))
@@ -166,26 +167,23 @@ module ActiveLdap
166
167
  records.each do |record|
167
168
  attributes.put(record.to_java_attribute)
168
169
  end
169
- escaped_dn = escape_dn(dn)
170
170
  @context.set_request_controls([])
171
- @context.create_subcontext(escaped_dn, attributes)
171
+ @context.create_subcontext(escape_dn(dn), attributes)
172
172
  end
173
173
 
174
174
  def modify(dn, records)
175
- escaped_dn = escape_dn(dn)
176
175
  items = records.collect(&:to_java_modification_item)
177
176
  @context.set_request_controls([])
178
- @context.modify_attributes(escaped_dn, items.to_java(ModificationItem))
177
+ @context.modify_attributes(escape_dn(dn), items.to_java(ModificationItem))
179
178
  end
180
179
 
181
180
  def modify_rdn(dn, new_rdn, delete_old_rdn)
182
- escaped_dn = escape_dn(dn)
183
181
  # should use mutex
184
182
  delete_rdn_key = "java.naming.ldap.deleteRDN"
185
183
  @context.set_request_controls([])
186
184
  begin
187
185
  @context.add_to_environment(delete_rdn_key, delete_old_rdn.to_s)
188
- @context.rename(escaped_dn, new_rdn)
186
+ @context.rename(escape_dn(dn), escape_dn(new_rdn))
189
187
  ensure
190
188
  @context.remove_from_environment(delete_rdn_key)
191
189
  end
@@ -230,34 +228,9 @@ module ActiveLdap
230
228
  end
231
229
 
232
230
  def escape_dn(dn)
233
- parsed_dn = nil
234
- begin
235
- parsed_dn = DN.parse(dn)
236
- rescue DistinguishedNameInvalid
237
- return dn
238
- end
239
-
240
- escaped_rdns = parsed_dn.rdns.collect do |rdn|
241
- escaped_rdn_strings = rdn.collect do |key, value|
242
- escaped_value = DN.escape_value(value)
243
- # We may need to escape the followings too:
244
- # * ,
245
- # * =
246
- # * +
247
- # * <
248
- # * >
249
- # * #
250
- # * ;
251
- #
252
- # See javax.naming.ldap.Rdn.unescapeValue()
253
- escaped_value = escaped_value.gsub(/\\\\/) do
254
- "\\5C"
255
- end
256
- "#{key}=#{escaped_value}"
257
- end
258
- escaped_rdn_strings.join("+")
259
- end
260
- escaped_rdns.join(",")
231
+ javax.naming.ldap.LdapName.new(dn)
232
+ rescue Java::JavaLang::IllegalArgumentException, Java::JavaxNaming::InvalidNameException
233
+ dn
261
234
  end
262
235
 
263
236
  def build_paged_results_control(page_size, page_cookie=nil)
@@ -81,9 +81,10 @@ module ActiveLdap
81
81
  end
82
82
  end
83
83
 
84
- def reload
84
+ def reload(options={})
85
85
  clear_association_cache
86
- _, attributes = search(:value => id).find do |_dn, _attributes|
86
+ search_options = options.merge(value: id)
87
+ _, attributes = search(search_options).find do |_dn, _attributes|
87
88
  dn == _dn
88
89
  end
89
90
  if attributes.nil?
@@ -1,3 +1,3 @@
1
1
  module ActiveLdap
2
- VERSION = "6.0.1"
2
+ VERSION = "6.0.2"
3
3
  end
@@ -383,6 +383,19 @@ class TestBase < Test::Unit::TestCase
383
383
  end
384
384
  end
385
385
 
386
+ def test_set_dn_with_unnormalized_dn_attribute_with_forward_slash
387
+ make_temporary_user do |user,|
388
+ new_dn = "uid=temp/user1,#{user.class.base}"
389
+ assert_not_equal(user.dn.to_s, new_dn)
390
+
391
+ user.uid = 'temp/user1'
392
+ assert_equal(user.dn.to_s, new_dn)
393
+
394
+ assert_true(user.save!)
395
+ assert_true(user.class.find(user.uid).update_attributes!(gidNumber: 100069))
396
+ end
397
+ end
398
+
386
399
  def test_destroy_with_empty_base_and_prefix_of_class
387
400
  make_temporary_user do |user,|
388
401
  base = user.class.base
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeldap
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 6.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Drewry
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-20 00:00:00.000000000 Z
12
+ date: 2020-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel