summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/client_request.rb
blob: 16a9d99931617a0039383b039dac2d5605972fe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module Puppet::Network # :nodoc:
    # A struct-like class for passing around a client request.  It's mostly
    # just used for validation and authorization.
    class ClientRequest
        attr_accessor :name, :ip, :authenticated, :handler, :method

        def authenticated?
            self.authenticated
        end

        # A common way of talking about the full call.  Individual servers
        # are responsible for setting the values correctly, but this common
        # format makes it possible to check rights.
        def call
            unless handler and method
                raise ArgumentError, "Request is not set up; cannot build call"
            end

            [handler, method].join(".")
        end

        def initialize(name, ip, authenticated)
            @name, @ip, @authenticated = name, ip, authenticated
        end

        def to_s
            "%s(%s)" % [self.name, self.ip]
        end
    end
end

# $Id$