MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
auth.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/auth.h,v 1.20 2017/01/12 14:46:08 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 #ifndef AUTH_H
33 #define AUTH_H
34 
35 #include <unistd.h>
36 #include <string.h>
37 
38 class AuthMethod {
39 public:
40  enum AuthRes {
45  };
46 
47 public:
48  virtual ~AuthMethod(void) {};
49 
50  virtual AuthMethod::AuthRes Auth(const char *user, const char *cred) const = 0;
51  virtual AuthMethod::AuthRes Auth(int sock) const = 0;
52 };
53 
54 /* NoAuth - begin */
55 
56 /* always OK */
57 
58 class NoAuth : public AuthMethod {
59 public:
60  AuthMethod::AuthRes Auth(const char * /* user */ , const char * /* cred */ ) const;
61  AuthMethod::AuthRes Auth(int sock) const;
62 };
63 
64 /* NoAuth - end */
65 
66 
67 /* PasswordAuth - begin */
68 
69 /* simple password comparison */
70 
71 #ifdef HAVE_CRYPT
72 
73 class PasswordAuth: public AuthMethod {
74 protected:
75  char User[33];
76  char Cred[33];
77 
78 public:
79  PasswordAuth(const char *u, const char *c, const char *salt_format = NULL);
80 
81  AuthMethod::AuthRes Auth(const char *user, const char *cred) const;
82  AuthMethod::AuthRes Auth(int sock) const;
83 };
84 
85 #endif /* HAVE_CRYPT */
86 
87 /* PasswordAuth - end */
88 
89 
90 /* PAM_Auth - begin */
91 
92 /* pam authentication */
93 
94 #ifdef USE_PAM
95 
96 class PAM_Auth: public AuthMethod {
97 protected:
98  char* User;
99 
100 public:
101  PAM_Auth(const char *u = NULL);
102 
103  AuthMethod::AuthRes Auth(const char *user, const char *cred) const;
104  AuthMethod::AuthRes Auth(int sock) const;
105 };
106 
107 #endif /* USE_PAM */
108 
109 /* PAM_Auth - end */
110 
111 /* SASL2_Auth - begin */
112 
113 /* SASL2 authentication (obsoletes everything else) */
114 
115 #ifdef HAVE_SASL2
116 
117 #if defined(HAVE_SASL_SASL_H)
118 #include <sasl/sasl.h>
119 #elif defined(HAVE_SASL_H)
120 #include <sasl.h>
121 #endif /* HAVE_SASL_SASL_H || HAVE_SASL_H */
122 #include "mbsasl.h"
123 
124 class SASL2_Auth: public AuthMethod {
125 protected:
126  mutable mbdyn_sasl_t mbdyn_sasl;
127 
128 public:
129  SASL2_Auth(const mbdyn_sasl_t *ms);
130 
131  AuthMethod::AuthRes Auth(const char *user, const char *cred) const;
132  AuthMethod::AuthRes Auth(int sock) const;
133 };
134 
135 #endif /* HAVE_SASL2 */
136 
137 /* PAM_Auth - end */
138 
139 class DataManager;
140 class MBDynParser;
141 
143 
144 #endif /* AUTH_H */
virtual AuthMethod::AuthRes Auth(const char *user, const char *cred) const =0
AuthMethod::AuthRes Auth(const char *, const char *) const
Definition: auth.cc:49
AuthRes
Definition: auth.h:40
Definition: auth.h:58
DataManager * pDM
Definition: mbpar.h:252
virtual ~AuthMethod(void)
Definition: auth.h:48
static std::stack< cleanup * > c
Definition: cleanup.cc:59
AuthMethod * ReadAuthMethod(const DataManager *pDM, MBDynParser &HP)
Definition: auth.cc:451