@@ -539,7 +539,7 @@ def initialize(args = {})
539
539
@auth = args [ :auth ] || DefaultAuth
540
540
@base = args [ :base ] || DefaultTreebase
541
541
@force_no_page = args [ :force_no_page ] || DefaultForceNoPage
542
- @encryption = args [ :encryption ] # may be nil
542
+ @encryption = normalize_encryption ( args [ :encryption ] ) # may be nil
543
543
@connect_timeout = args [ :connect_timeout ]
544
544
545
545
if pr = @auth [ :password ] and pr . respond_to? ( :call )
@@ -609,13 +609,7 @@ def authenticate(username, password)
609
609
def encryption ( args )
610
610
warn "Deprecation warning: please give :encryption option as a Hash to Net::LDAP.new"
611
611
return if args . nil?
612
- return @encryption = args if args . is_a? Hash
613
-
614
- case method = args . to_sym
615
- when :simple_tls , :start_tls
616
- args = { :method => method , :tls_options => { } }
617
- end
618
- @encryption = args
612
+ @encryption = normalize_encryption ( args )
619
613
end
620
614
621
615
# #open takes the same parameters as #new. #open makes a network
@@ -1323,4 +1317,17 @@ def new_connection
1323
1317
}
1324
1318
raise e
1325
1319
end
1320
+
1321
+ # Normalize encryption parameter the constructor accepts, expands a few
1322
+ # convenience symbols into recognizable hashes
1323
+ def normalize_encryption ( args )
1324
+ return if args . nil?
1325
+ return args if args . is_a? Hash
1326
+
1327
+ case method = args . to_sym
1328
+ when :simple_tls , :start_tls
1329
+ { :method => method , :tls_options => { } }
1330
+ end
1331
+ end
1332
+
1326
1333
end # class LDAP
0 commit comments