File: sbuild-auth-pam-conv.h

package info (click to toggle)
schroot 1.6.4-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,684 kB
  • sloc: cpp: 21,427; sh: 12,516; makefile: 829; ansic: 231; sed: 16
file content (153 lines) | stat: -rw-r--r-- 4,238 bytes parent folder | download | duplicates (5)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* Copyright © 2005-2007  Roger Leigh <rleigh@debian.org>
 *
 * schroot is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * schroot is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 *********************************************************************/

#ifndef SBUILD_AUTH_PAM_CONV_H
#define SBUILD_AUTH_PAM_CONV_H

#include <sbuild/sbuild-auth-pam-message.h>
#include <sbuild/sbuild-error.h>
#include <sbuild/sbuild-tr1types.h>

#include <vector>

#include <security/pam_appl.h>

namespace sbuild
{

  class auth_pam;

  /**
   * Authentication conversation handler interface.
   *
   * This interface should be implemented by objects which handle
   * interaction with the user during authentication.
   *
   * This is a wrapper around the struct pam_conv PAM conversation
   * interface, and is used by auth when interacting with the user
   * during authentication.
   *
   * A simple implementation is provided in the form of
   * auth_pam_conv_tty.  However, more complex implementations might
   * hook into the event loop of a GUI widget system, for example.
   *
   * The interface allows the setting of optional warning timeout and
   * fatal timeout values, which should default to 0 (not enabled).
   * This is an absolute time after which a warning is displayed or
   * the conversation ends with an error.
   *
   * Note that the auth object must be specified, and must never be
   * void while the conversation is in progress.
   */
  class auth_pam_conv
  {
  public:
    /// A list of messages.
    typedef std::vector<auth_pam_message> message_list;
    /// A shared pointer to an auth_pam object.
    typedef std::shared_ptr<auth_pam> auth_ptr;
    /// A weak pointer to an auth_pam object.
    typedef std::weak_ptr<auth_pam> weak_auth_ptr;
    /// A shared_ptr to an auth_pam_conv object.
    typedef std::shared_ptr<auth_pam_conv> ptr;

  protected:
    /// The constructor.
    auth_pam_conv ();

  public:
    /// The destructor.
    virtual ~auth_pam_conv ();

    /**
     * Get the auth object.
     *
     * @returns the auth object.
     */
    virtual auth_ptr
    get_auth () = 0;

    /**
     * Set the auth object.
     *
     * @param auth the auth object.
     */
    virtual void
    set_auth (auth_ptr auth) = 0;

    /**
     * Get the time at which the user will be warned.
     *
     * @returns the time.
     */
    virtual time_t
    get_warning_timeout () = 0;

    /**
     * Set the time at which the user will be warned.
     *
     * @param timeout the time to set.
     */
    virtual void
    set_warning_timeout (time_t timeout) = 0;

    /**
     * Get the time at which the conversation will be terminated with
     * an error.
     *
     * @returns the time.
     */
    virtual time_t
    get_fatal_timeout () = 0;

    /**
     * Set the time at which the conversation will be terminated with
     * an error.
     *
     * @param timeout the time to set.
     */
    virtual void
    set_fatal_timeout (time_t timeout) = 0;

    /**
     * Hold a conversation with the user.
     *
     * Each of the messages detailed in messages should be displayed
     * to the user, asking for input where required.  The type of
     * message is indicated in the auth_pam_message::type field of the
     * auth_pam_message.  The auth_pam_message::response field of the
     * auth_pam_message should be filled in if input is required.
     *
     * On error, an exception will be thrown.
     *
     * @param messages the messages to display to the user, and
     * responses to return to the caller.
     */
    virtual void
    conversation (message_list& messages) = 0;
  };

}

#endif /* SBUILD_AUTH_PAM_CONV_H */

/*
 * Local Variables:
 * mode:C++
 * End:
 */