class HTAuth::ENTRY_KLASS

Object version of a single record from an htdigest file

Object version of a single entry from a htpasswd file

Attributes

algorithm[R]

the algorithm used to create the digest of this entry

algorithm_args[R]

the algorithm arguments used to create the digest of this entry

digest[RW]

the password digest of this entry

realm[RW]
user[RW]

the user of this entry

Public Class Methods

from_line

Create an instance of this class from a line of text

line

a line of text from a htpasswd file

Returns

Returns an instance of PasswdEntry

is_entry!

test if the given line is valid for this Entry class

A valid entry is a single line composed of two parts; a username and a password separated by a ':' character. Neither the username nor the password may contain a ':' character

line

a line of text from a file

Returns

Returns the individual parts of the line

Raises InvalidPasswdEntry if it is not an valid entry

is_entry?

Returns

Returns whether or not the line is a valid entry

Returns true or false

new

Create a new Entry with the given user, password, and algorithm

Public Instance Methods

authenticated?

Check if the given password is the password of this entry check the password and make sure it works, in the case that the algorithm is unknown it tries all of the ones that it thinks it could be, and marks the algorithm if it matches when looking for a matche, we always compare all of them, no short circuiting

calc_digest

calculate the new digest of the given password

key

Returns

Returns the key of this entry

password=

Update the password of the entry with its new value

If we have an array of algorithms, then we set it to CRYPT

to_s

Returns

Returns the file line for this entry

Private Instance Methods

algorithm=(alg) click to toggle source

set the algorithm for the entry

# File lib/htauth/passwd_entry.rb, line 71
def algorithm=(alg)
  return @algorithm if Algorithm::EXISTING == alg
  case alg
  when String
    @algorithm = Algorithm.algorithm_from_name(alg)
  when ::HTAuth::Algorithm
    @algorithm = alg
  else
    raise InvalidAlgorithmError, "Unable to assign #{alg} to algorithm"
  end
  return @algorithm
end
algorithm_args=(args) click to toggle source

set fields on the algorithm

# File lib/htauth/passwd_entry.rb, line 85
def algorithm_args=(args)
  args.each do |key, value|
    method = "#{key}="
    @algorithm.send(method, value) if @algorithm.respond_to?(method)
  end
end

Public

↑ top

Internal

↑ top