Branch data Line data Source code
1 : : // Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
2 : : //
3 : : // Permission to use, copy, modify, and/or distribute this software for any
4 : : // purpose with or without fee is hereby granted, provided that the above
5 : : // copyright notice and this permission notice appear in all copies.
6 : : //
7 : : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
8 : : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9 : : // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
10 : : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11 : : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
12 : : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13 : : // PERFORMANCE OF THIS SOFTWARE.
14 : :
15 : : #ifndef __DNSNAME_CHECK_H
16 : : #define __DNSNAME_CHECK_H 1
17 : :
18 : : #include <dns/name.h>
19 : :
20 : : #include <acl/check.h>
21 : :
22 : : namespace isc {
23 : : namespace acl {
24 : : namespace dns {
25 : :
26 : : /// ACL check for DNS names
27 : : ///
28 : : /// This class is intended to perform a match between a domain name
29 : : /// specified in an ACL and a given name. The primary usage of this class
30 : : /// is an ACL match for TSIG keys, where an ACL would contain a list of
31 : : /// acceptable key names and the \c match() method would compare the owner
32 : : /// name of a TSIG record against the specified names.
33 : : ///
34 : : /// This class could be used for other kinds of names such as the query name
35 : : /// of normal DNS queries.
36 : : ///
37 : : /// The class is templated on the type of a context structure passed to the
38 : : /// matches() method, and a template specialisation for that method must be
39 : : /// supplied for the class to be used.
40 : : template <typename Context>
41 : : class NameCheck : public Check<Context> {
42 : : public:
43 : : /// The constructor
44 : : ///
45 : : /// \exception std::bad_alloc Resource allocation fails in copying the
46 : : /// name
47 : : ///
48 : : /// \param name The domain name to be matched in \c matches().
49 : 57 : NameCheck(const isc::dns::Name& name) : name_(name) {}
50 : :
51 : : /// Destructor
52 : 87 : virtual ~NameCheck() {}
53 : :
54 : : /// The check method
55 : : ///
56 : : /// Matches the passed argument to the condition stored here. Different
57 : : /// specializations must be provided for different argument types, and the
58 : : /// program will fail to compile if a required specialisation is not
59 : : /// provided.
60 : : ///
61 : : /// \param context Information to be matched
62 : : virtual bool matches(const Context& context) const;
63 : :
64 : : /// Returns the name specified on construction.
65 : : ///
66 : : /// This is mainly for testing purposes.
67 : : ///
68 : : /// \exception None
69 : : const isc::dns::Name& getName() const { return (name_); }
70 : :
71 : : private:
72 : : const isc::dns::Name name_;
73 : : };
74 : :
75 : : } // namespace dns
76 : : } // namespace acl
77 : : } // namespace isc
78 : :
79 : : #endif // __DNSNAME_CHECK_H
80 : :
81 : : // Local Variables:
82 : : // mode: c++
83 : : // End:
|