2 * Copyright (c) 2014 <copyright holder> <email>
4 * For license details, see the LICENSE file in the root of this project.
9 #include "../GSSException.h"
11 void GSSName::init(const GSSBuffer namestr, GSSOID name_type, bool skipRelease, gss_imp_name_type fn)
17 this->major_status = fn(&(this->minor_status), namestr.toGss(), name_type.toGss(), &name);
18 if ( GSS_ERROR(this->major_status) )
21 errMsg += "Cannot import name: ";
22 errMsg += namestr.toString();
23 throw GSSException(errMsg.c_str(), this->major_status, this->minor_status, name_type.toGss());
25 this->skipRelease = skipRelease;
32 GSSName::GSSName ( gss_name_t gss_name, bool skipRelease )
35 this->skipRelease = skipRelease;
40 void GSSName::release()
43 OM_uint32 major, minor;
46 if (GSS_C_NO_NAME == name || skipRelease)
51 // if (hashKey.length() > 0)
52 // std::cout << std::endl << "About to release name for key " << hashKey << std::endl;
54 major = gss_release_name(&minor, &name);
57 if ( GSS_ERROR(major) && !( major & GSS_S_BAD_NAME ) )
59 throw GSSException("Cannot free memory for a GSS name.", major, minor);
66 GSSName::GSSName ( const GSSName& n )
68 this->hashKey = n.hashKey;
69 if (GSS_C_NO_NAME == n.name)
77 this->major_status = gss_duplicate_name(&minor_status, n.name, &name);
78 if ( GSS_ERROR(major_status) )
80 throw GSSException("Cannot copy a GSS name.", major_status, minor_status);
83 this->skipRelease = false;
91 GSSName& GSSName::operator= ( const GSSName& rhs )
93 if (rhs.toGss() != this->toGss())
95 this->function = rhs.function;
96 if (GSS_C_NO_NAME == rhs.name)
100 name = GSS_C_NO_NAME;
104 this->major_status = gss_duplicate_name(&minor_status, rhs.name, &name);
105 if ( GSS_ERROR(major_status) )
107 throw GSSException("Cannot copy a GSS name.", major_status, minor_status);
111 this->skipRelease = rhs.skipRelease;
117 std::string GSSName::toString() const
120 OM_uint32 major, minor;
127 major = gss_display_name(&minor, (this->name), buf.toGss(), &oid);
128 if ( GSS_ERROR(major) )
130 throw GSSException("Cannot convert a GSS name to a string.", major, minor);
135 return buf.toString();
138 bool GSSName::setValue ( gss_name_t newName, bool skipRelease )
141 this->name = newName;
142 this->skipRelease = skipRelease;