GSS Acquire Cred calling out correctly; slight reorginzation
[gssweb.git] / json_gssapi / src / datamodel / GSSOIDSet.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 "GSSOIDSet.h"
9 #include "../GSSException.h"
10
11 #include <cstring>
12
13 GSSOIDSet::GSSOIDSet( )
14 {
15   init();
16 }
17
18 void GSSOIDSet::init()
19 {
20   /* Variables */
21   OM_uint32 major, minor;
22   
23   /* Error checking */
24   /* Setup */
25   /* Main */
26   major = gss_create_empty_oid_set(&minor, &(this->set));
27   
28   // How the heck would this happen, anyway?
29   if (GSS_ERROR(major))
30     throw GSSException("Could not create an empty OID set.", major, minor);
31   
32   /* Cleanup */
33   /* return */
34 }
35
36 GSSOIDSet::~GSSOIDSet()
37 {
38   this->releaseOIDSet();
39 }
40
41 void GSSOIDSet::releaseOIDSet()
42 {
43   /* Variables */
44   OM_uint32 major, minor;
45   
46   /* Error checking */
47   /* Setup */
48   /* Main */
49   major = gss_release_oid_set(&minor, &(this->set));
50   if (GSS_ERROR(major))
51     throw GSSException("Error in releasing memory for an OID set", major, minor);
52   /* Cleanup */
53   /* return */
54 }
55
56 GSSOIDSet& GSSOIDSet::operator= ( const gss_OID_set other )
57 {
58   /* Variables */
59   OM_uint32 i;
60   gss_OID   element;
61   
62   /* Error checking */
63   /* Setup */
64   /* Main */
65   this->releaseOIDSet();
66   this->init();
67   for(i = 0; i < other->count; i++)
68   {
69     element = other->elements + i;
70     this->addOID(element);
71   }
72   
73   /* Cleanup */
74   /* return */
75   return(*this);
76 }
77
78 void GSSOIDSet::addOID ( const GSSOID other )
79 {
80   this->addOID(other.toGss());
81 }
82
83 void GSSOIDSet::addOID( const gss_OID other )
84 {
85   /* Variables */
86   OM_uint32 major, minor;
87   
88   /* Error checking */
89   /* Setup */
90   major = gss_add_oid_set_member(&minor, other, &(this->set) );
91   if (GSS_ERROR(major))
92     throw GSSException("Error encountered while trying to add another OID to a set", major, minor);
93
94   /* Cleanup */
95   /* return */
96 }
97
98
99
100   /* Variables */
101   /* Error checking */
102   /* Setup */
103   /* Main */
104   /* Cleanup */
105   /* return */
106