Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace :old do
end
end

desc "Run a full set of integration and unit tests"
desc "Run a full set of integration and unit tests"
task :cruise => [:test, :spec]

# vim: syntax=ruby
10 changes: 5 additions & 5 deletions lib/net/ber/core_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@ class String

require 'net/ber/core_ext/array'
# :stopdoc:
class Array
class Array
include Net::BER::Extensions::Array
end
# :startdoc:

require 'net/ber/core_ext/bignum'
# :stopdoc:
class Bignum
class Bignum
include Net::BER::Extensions::Bignum
end
# :startdoc:

require 'net/ber/core_ext/fixnum'
# :stopdoc:
class Fixnum
class Fixnum
include Net::BER::Extensions::Fixnum
end
# :startdoc:

require 'net/ber/core_ext/true_class'
# :stopdoc:
class TrueClass
class TrueClass
include Net::BER::Extensions::TrueClass
end
# :startdoc:

require 'net/ber/core_ext/false_class'
# :stopdoc:
class FalseClass
class FalseClass
include Net::BER::Extensions::FalseClass
end
# :startdoc:
14 changes: 7 additions & 7 deletions lib/net/ber/core_ext/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def to_ber(code = 0x04)
[code].pack('C') + raw_string.length.to_ber_length_encoding + raw_string
end

##
# Converts a string to a BER string but does *not* encode to UTF-8 first.
# This is required for proper representation of binary data for Microsoft
# Active Directory
def to_ber_bin(code = 0x04)
[code].pack('C') + length.to_ber_length_encoding + self
end
##
# Converts a string to a BER string but does *not* encode to UTF-8 first.
# This is required for proper representation of binary data for Microsoft
# Active Directory
def to_ber_bin(code = 0x04)
[code].pack('C') + length.to_ber_length_encoding + self
end

def raw_utf8_encoded
if self.respond_to?(:encode)
Expand Down
14 changes: 7 additions & 7 deletions lib/net/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class LdapError < StandardError; end
DefaultPort = 389
DefaultAuth = { :method => :anonymous }
DefaultTreebase = "dc=com"
DefaultForceNoPage = false
DefaultForceNoPage = false

StartTlsOid = "1.3.6.1.4.1.1466.20037"

Expand Down Expand Up @@ -398,7 +398,7 @@ def initialize(args = {})
@verbose = false # Make this configurable with a switch on the class.
@auth = args[:auth] || DefaultAuth
@base = args[:base] || DefaultTreebase
@force_no_page = args[:force_no_page] || DefaultForceNoPage
@force_no_page = args[:force_no_page] || DefaultForceNoPage
encryption args[:encryption] # may be nil

if pr = @auth[:password] and pr.respond_to?(:call)
Expand Down Expand Up @@ -486,7 +486,7 @@ def authenticate(username, password)
# standard port for simple-TLS encrypted connections is 636. Be sure you
# are using the correct port.
#
# The :start_tls like the :simple_tls encryption method also encrypts all
# The :start_tls like the :simple_tls encryption method also encrypts all
# communcations with the LDAP server. With the exception that it operates
# over the standard TCP port.
def encryption(args)
Expand Down Expand Up @@ -1168,10 +1168,10 @@ def search_subschema_entry
# MUST refactor the root_dse call out.
#++
def paged_searches_supported?
# active directory returns that it supports paged results. However
# it returns binary data in the rfc2696_cookie which throws an
# encoding exception breaking searching.
return false if @force_no_page
# active directory returns that it supports paged results. However
# it returns binary data in the rfc2696_cookie which throws an
# encoding exception breaking searching.
return false if @force_no_page
@server_caps ||= search_root_dse
@server_caps[:supportedcontrol].include?(Net::LDAP::LDAPControls::PAGED_RESULTS)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/net/ldap/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def [](name)

##
# Read the first value for the provided attribute. The attribute name
# is canonicalized prior to reading. Returns nil if the attribute does
# is canonicalized prior to reading. Returns nil if the attribute does
# not exist.
def first(name)
self[name].first
Expand Down
14 changes: 7 additions & 7 deletions lib/net/ldap/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def present?(attribute)

# http://tools.ietf.org/html/rfc4515 lists these exceptions from UTF1
# charset for filters. All of the following must be escaped in any normal
# string using a single backslash ('\') as escape.
# string using a single backslash ('\') as escape.
#
ESCAPES = {
"\0" => '00', # NUL = %x00 ; null character
Expand All @@ -251,10 +251,10 @@ def present?(attribute)
')' => '29', # RPARENS = %x29 ; right parenthesis (")")
'\\' => '5C', # ESC = %x5C ; esc (or backslash) ("\")
}
# Compiled character class regexp using the keys from the above hash.
# Compiled character class regexp using the keys from the above hash.
ESCAPE_RE = Regexp.new(
"[" +
ESCAPES.keys.map { |e| Regexp.escape(e) }.join +
"[" +
ESCAPES.keys.map { |e| Regexp.escape(e) }.join +
"]")

##
Expand Down Expand Up @@ -310,8 +310,8 @@ def parse_ber(ber)
present?(ber.to_s)
when 0xa9 # context-specific constructed 9, "extensible comparison"
raise Net::LDAP::LdapError, "Invalid extensible search filter, should be at least two elements" if ber.size<2
# Reassembles the extensible filter parts

# Reassembles the extensible filter parts
# (["sn", "2.4.6.8.10", "Barbara Jones", '1'])
type = value = dn = rule = nil
ber.each do |element|
Expand All @@ -327,7 +327,7 @@ def parse_ber(ber)
attribute << type if type
attribute << ":#{dn}" if dn
attribute << ":#{rule}" if rule

ex(attribute, value)
else
raise Net::LDAP::LdapError, "Invalid BER tag-value (#{ber.ber_identifier}) in search filter."
Expand Down
22 changes: 11 additions & 11 deletions lib/net/ldap/password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class << self
#
attribute_value = ""
def generate(type, str)
case type
when :md5
attribute_value = '{MD5}' + Base64.encode64(Digest::MD5.digest(str)).chomp!
when :sha
attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp!
when :ssha
salt = SecureRandom.random_bytes(16)
attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp!
else
raise Net::LDAP::LdapError, "Unsupported password-hash type (#{type})"
end
case type
when :md5
attribute_value = '{MD5}' + Base64.encode64(Digest::MD5.digest(str)).chomp!
when :sha
attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp!
when :ssha
salt = SecureRandom.random_bytes(16)
attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp!
else
raise Net::LDAP::LdapError, "Unsupported password-hash type (#{type})"
end
return attribute_value
end
end
Expand Down
Loading