8387334470cb921dbad99a667f634739d40530eb
[gssweb.git] / json_gssapi / src / datamodel / GSSCredential.cpp
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 "GSSCredential.h"
9 #include "../GSSException.h"
10
11 GSSCredential::GSSCredential()
12 {
13   this->credential = GSS_C_NO_CREDENTIAL;
14 }
15
16 GSSCredential::GSSCredential ( const GSSCredential& other )
17 {
18   this->credential = other.credential;
19 }
20
21 GSSCredential& GSSCredential::operator= ( const GSSCredential& gsscred )
22 {
23   this->credential = gsscred.credential;
24   return(*this);
25 }
26
27 GSSCredential::~GSSCredential()
28 {
29   /* Variables */
30   OM_uint32 major, minor;
31     
32   /* Error checking */
33   if (this->credential == GSS_C_NO_CREDENTIAL)
34     return;
35   
36   /* Setup */
37   
38   /* Main */
39   major = gss_release_cred(&minor, &(this->credential));
40   
41   /* Cleanup */
42   if (GSS_ERROR(major))
43     throw GSSException("Could not free the GSS credential", major, minor);
44   
45   /* Return */
46 }
47