~ubuntu-branches/ubuntu/raring/ruby-net-ldap/raring

« back to all changes in this revision

Viewing changes to lib/net/ldap/psw.rb

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-05-14 17:25:45 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120514172545-m08z3m92de2n2pfn
Tags: 0.3.1-1
* Upstream update.
* debian/watch: refer to latest net-ldap project.
* debian/copyright:
  + license changed to Expat, with permission from Ondřej Surý for the
    debian/* part.
  + format 1.0
  + add a lintian-override because Comment mentions old GPL license.
* debian/control:
  + Standards-Version 3.9.3 (no changes required)
  + Use anonscm.d.o in Vcs-* fields.
  + Update Homepage url.
  + XS-Ruby-Versions: all, this module is fine with ruby 1.8 and 1.9.
* debian/patches:
  + Unapply unneeded patches
  + 0003-fix_require_in_tests.patch: tests are called from CURDIR.
* Update debian/ruby-test-files.yaml

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: psw.rb 73 2006-04-24 21:59:35Z blackhedd $
2
 
#
3
 
#
4
 
#----------------------------------------------------------------------------
5
 
#
6
 
# Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
7
 
#
8
 
# Gmail: garbagecat10
9
 
#
10
 
# This program is free software; you can redistribute it and/or modify
11
 
# it under the terms of the GNU General Public License as published by
12
 
# the Free Software Foundation; either version 2 of the License, or
13
 
# (at your option) any later version.
14
 
#
15
 
# This program is distributed in the hope that it will be useful,
16
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
# GNU General Public License for more details.
19
 
#
20
 
# You should have received a copy of the GNU General Public License
21
 
# along with this program; if not, write to the Free Software
22
 
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23
 
#
24
 
#---------------------------------------------------------------------------
25
 
#
26
 
#
27
 
 
28
 
 
29
 
module Net
30
 
class LDAP
31
 
 
32
 
 
33
 
class Password
34
 
  class << self
35
 
 
36
 
  # Generate a password-hash suitable for inclusion in an LDAP attribute.
37
 
  # Pass a hash type (currently supported: :md5 and :sha) and a plaintext
38
 
  # password. This function will return a hashed representation.
39
 
  # STUB: This is here to fulfill the requirements of an RFC, which one?
40
 
  # TODO, gotta do salted-sha and (maybe) salted-md5.
41
 
  # Should we provide sha1 as a synonym for sha1? I vote no because then
42
 
  # should you also provide ssha1 for symmetry?
43
 
  def generate( type, str )
44
 
    case type
45
 
    when :md5
46
 
      require 'md5'
47
 
      "{MD5}#{ [MD5.new( str.to_s ).digest].pack("m").chomp }"
48
 
    when :sha
49
 
      require 'sha1'
50
 
      "{SHA}#{ [SHA1.new( str.to_s ).digest].pack("m").chomp }"
51
 
    # when ssha
52
 
    else
53
 
      raise Net::LDAP::LdapError.new( "unsupported password-hash type (#{type})" )
54
 
    end
55
 
  end
56
 
 
57
 
  end
58
 
end
59
 
 
60
 
 
61
 
end # class LDAP
62
 
end # module Net
63
 
 
64