2 * Copyright (c) 2014 <copyright holder> <email>
4 * For license details, see the LICENSE file in the root of this project.
8 #include "GSSContext.h"
9 #include "GSSException.h"
11 #include <gssapi/gssapi.h>
13 GSSContext::GSSContext()
16 context = GSS_C_NO_CONTEXT;
19 GSSContext::GSSContext ( const GSSContext& other )
26 this->context = other.context;
32 GSSContext::~GSSContext()
42 // Would love to do something useful with outputToken, but in a destructor that's
43 // not particularly meaningful.
47 void GSSContext::setContext ( gss_ctx_id_t ctxt, bool skipRelease )
50 this->skipRelease = skipRelease;
54 GSSContext& GSSContext::operator= ( const GSSContext& other )
56 this->context = other.context;
57 this->skipRelease = true;
62 void GSSContext::release(GSSBuffer *output)
65 gss_buffer_desc outputToken;
66 OM_uint32 major, minor;
69 if (GSS_C_NO_CONTEXT == context || skipRelease)
75 major = gss_delete_sec_context(&minor, &context, &outputToken);
78 throw GSSException("Error in releasing a GSS context", major, minor);
81 output->setValue(&outputToken);