74eccbc5c2c47c14d67d00e526cd68465200779b
[gssweb.git] / json_gssapi / src / datamodel / GSSName.h
1 /*
2  * Copyright (c) 2014 <copyright holder> <email>
3  * 
4  * For license details, see the LICENSE file in the root of this project.
5  * 
6  */
7
8 #include <string>
9 #include "GSSBuffer.h"
10 #include "GSSOID.h"
11
12 #ifndef GSSNAME_H
13 #define GSSNAME_H
14
15
16 typedef OM_uint32 (KRB5_CALLCONV *gss_imp_name_type)(
17     OM_uint32 *,        /* minor_status */
18     gss_buffer_t,       /* input_name_buffer */
19     gss_OID,            /* input_name_type(used to be const) */
20     gss_name_t *);      /* output_name */
21
22
23 class GSSName {
24 public:
25   GSSName() { name = GSS_C_NO_NAME; skipRelease = false; };
26   GSSName(const GSSName& n);
27   GSSName(gss_name_t gss_name, bool skipRelease = false);
28
29   ~GSSName();
30   
31   GSSName& operator=(const GSSName& rhs);
32   
33   gss_name_t toGss() const { return(name); }
34   std::string toString() const;
35   
36   bool setValue(gss_name_t newName, bool skipRelease = false);
37   void setKey(std::string key) { this->hashKey = key; }
38   std::string getKey() const { return this->hashKey; }
39   
40   OM_uint32 getMajorStatus() const { return this->major_status; }
41   OM_uint32 getMinorStatus() const { return this->minor_status; }
42   
43 private:
44   OM_uint32 major_status, minor_status;
45   gss_name_t name;
46   gss_imp_name_type function;
47   std::string hashKey;
48   bool skipRelease;
49   
50   void init(const GSSBuffer namestr, GSSOID name_type, bool skipRelease, gss_imp_name_type fn);
51   void release();
52 };
53
54
55 #endif // GSSNAME_H