Class: Rack::Auth::Digest::Nonce

### Home Classes Methods

### In Files

- lib/rack/auth/digest/nonce.rb

### Parent

Object

### Methods

- ::new
- ::parse
- #digest
- #fresh?
- #stale?
- #to_s
- #valid?

### Files

- KNOWN-ISSUES

### Class/Module Index

Quicksearch

- Rack
- Rack::Auth
- Rack::Auth::AbstractHandler
- Rack::Auth::AbstractRequest
- Rack::Auth::Basic
- Rack::Auth::Basic::Request
- Rack::Auth::Digest
- Rack::Auth::Digest::MD5
- Rack::Auth::Digest::Nonce
- Rack::Auth::Digest::Params
- Rack::Auth::Digest::Request
- Rack::BodyProxy
- Rack::Builder
- Rack::Cascade
- Rack::Chunked
- Rack::Chunked::Body
- Rack::CommonLogger
- Rack::ConditionalGet
- Rack::Config
- Rack::ContentLength
- Rack::ContentType
- Rack::Deflater
- Rack::Deflater::DeflateStream
- Rack::Deflater::GzipStream
- Rack::Directory
- Rack::ETag
- Rack::File
- Rack::ForwardRequest
- Rack::Handler
- Rack::Handler::CGI
- Rack::Handler::EventedMongrel
- Rack::Handler::FastCGI
- Rack::Handler::LSWS
- Rack::Handler::Mongrel
- Rack::Handler::SCGI
- Rack::Handler::SwiftipliedMongrel
- Rack::Handler::Thin
- Rack::Handler::WEBrick
- Rack::Head
- Rack::Lint
- Rack::Lobster
- Rack::Lock
- Rack::Logger
- Rack::MethodOverride
- Rack::Mime
- Rack::MockRequest
- Rack::MockRequest::FatalWarner
- Rack::MockRequest::FatalWarning
- Rack::MockResponse
- Rack::Multipart
- Rack::Multipart::Generator
- Rack::Multipart::MultipartLimitError
- Rack::Multipart::Parser
- Rack::Multipart::UploadedFile
- Rack::NullLogger
- Rack::Recursive
- Rack::Reloader
- Rack::Reloader::Stat
- Rack::Request
- Rack::Response
- Rack::Response::Helpers
- Rack::RewindableInput
- Rack::RewindableInput::Tempfile
- Rack::Runtime
- Rack::Sendfile
- Rack::Server
- Rack::Server::Options
- Rack::Session
- Rack::Session::Abstract
- Rack::Session::Abstract::ID
- Rack::Session::Abstract::SessionHash
- Rack::Session::Cookie
- Rack::Session::Cookie::Base64
- Rack::Session::Cookie::Base64::Marshal
- Rack::Session::Cookie::Identity
- Rack::Session::Cookie::Reverse
- Rack::Session::Memcache
- Rack::Session::Pool
- Rack::ShowExceptions
- Rack::ShowStatus
- Rack::Static
- Rack::URLMap
- Rack::Utils
- Rack::Utils::Context
- Rack::Utils::HeaderHash
- Rack::Utils::KeySpaceConstrainedParams
- Rack::Utils::Multipart
- FCGI
- FCGI::Stream
- Object

No matching classes.

# Rack::Auth::Digest::Nonce

Rack::Auth::Digest::Nonce is the default nonce generator for the Rack::Auth::Digest::MD5 authentication handler.

`private_key` needs to set to a constant string.

`time_limit` can be optionally set to an integer (number of seconds), to limit the validity of the generated nonces.

### Attributes

private_key[RW]
time_limit[RW]

### Public Class Methods

new(timestamp = Time.now, given_digest = nil) click to toggle source

    # File lib/rack/auth/digest/nonce.rb, line 24
    def initialize(timestamp = Time.now, given_digest = nil)
      @timestamp, @given_digest = timestamp.to_i, given_digest
    end

parse(string) click to toggle source

    # File lib/rack/auth/digest/nonce.rb, line 20
    def self.parse(string)
      new(*string.unpack("m*").first.split(' ', 2))
    end

### Public Instance Methods

digest() click to toggle source

    # File lib/rack/auth/digest/nonce.rb, line 32
    def digest
      ::Digest::MD5.hexdigest([ @timestamp, self.class.private_key ] * ':')
    end

fresh?() click to toggle source

    # File lib/rack/auth/digest/nonce.rb, line 44
    def fresh?
      !stale?
    end

stale?() click to toggle source

    # File lib/rack/auth/digest/nonce.rb, line 40
    def stale?
      !self.class.time_limit.nil? && (Time.now.to_i - @timestamp) > self.class.time_limit
    end

to_s() click to toggle source

    # File lib/rack/auth/digest/nonce.rb, line 28
    def to_s
      [([ @timestamp, digest ] * ' ')].pack("m*").strip
    end

valid?() click to toggle source

    # File lib/rack/auth/digest/nonce.rb, line 36
    def valid?
      digest == @given_digest
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.