PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
psasl.h
Go to the documentation of this file.
1 /*
2  * sasl.h
3  *
4  * Simple Authentication Security Layer interface classes
5  *
6  * Portable Windows Library
7  *
8  * Copyright (c) 2004 Reitek S.p.A.
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Portable Windows Library.
21  *
22  * The Initial Developer of the Original Code is Post Increment
23  *
24  * Contributor(s): ______________________________________.
25  *
26  * $Revision: 26545 $
27  * $Author: rjongbloed $
28  * $Date: 2011-10-06 11:55:01 +1100 (Thu, 06 Oct 2011) $
29  */
30 
31 #ifndef PTLIB_PSASL_H
32 #define PTLIB_PSASL_H
33 
34 #if P_SASL
35 
36 #ifdef P_USE_PRAGMA
37 #pragma interface
38 #endif
39 
40 #include <ptlib.h>
41 
42 class PSASLClient : public PObject
43 {
44  PCLASSINFO(PSASLClient, PObject);
45 
46 public:
47  enum PSASLResult {
48  Continue = 1,
49  OK = 0,
50  Fail = -1
51  };
52 
53 protected:
54  static PString s_Realm;
55  static PString s_Path;
56 
57  struct sasl_callback * m_CallBacks;
58  struct sasl_conn * m_ConnState;
59 
64 
65  PBoolean Start(const PString& mechanism, const char ** output, unsigned& len);
66  PSASLResult Negotiate(const char * input, const char ** output);
67 
68 public:
69  PSASLClient(const PString& service, const PString& uid, const PString& auth, const PString& pwd);
70  ~PSASLClient();
71 
72  static void SetRealm(const PString& realm) { s_Realm = realm; }
73  static void SetPath(const PString& path) { s_Path = path; }
74 
75  static const PString& GetRealm() { return s_Realm; }
76  static const PString& GetPath() { return s_Path; }
77 
78  const PString& GetService() const { return m_Service; }
79  const PString& GetUserID() const { return m_UserID; }
80  const PString& GetAuthID() const { return m_AuthID; }
81  const PString& GetPassword() const { return m_Password; }
82 
83  PBoolean Init(const PString& fqdn, PStringSet& supportedMechanisms);
84  PBoolean Start(const PString& mechanism, PString& output);
85  PSASLResult Negotiate(const PString& input, PString& output);
86  PBoolean End();
87 };
88 
89 #endif // P_SASL
90 
91 #endif // PTLIB_PSASL_H
92 
93 
94 // End of File ///////////////////////////////////////////////////////////////