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"
13 GSSOIDSet::GSSOIDSet( )
18 void GSSOIDSet::init()
21 OM_uint32 major, minor;
26 major = gss_create_empty_oid_set(&minor, &(this->set));
28 // How the heck would this happen, anyway?
30 throw GSSException("Could not create an empty OID set.", major, minor);
36 GSSOIDSet::~GSSOIDSet()
38 this->releaseOIDSet();
41 void GSSOIDSet::releaseOIDSet()
44 OM_uint32 major, minor;
49 major = gss_release_oid_set(&minor, &(this->set));
51 throw GSSException("Error in releasing memory for an OID set", major, minor);
56 GSSOIDSet& GSSOIDSet::operator= ( const gss_OID_set other )
65 this->releaseOIDSet();
67 for(i = 0; i < other->count; i++)
69 element = other->elements + i;
70 this->addOID(element);
78 void GSSOIDSet::addOID ( const GSSOID other )
80 this->addOID(other.toGss());
83 void GSSOIDSet::addOID( const gss_OID other )
86 OM_uint32 major, minor;
90 major = gss_add_oid_set_member(&minor, other, &(this->set) );
92 throw GSSException("Error encountered while trying to add another OID to a set", major, minor);
99 bool GSSOIDSet::includes ( const gss_OID oid ) const
102 OM_uint32 major, minor;
108 major = gss_test_oid_set_member(&minor, oid, this->set, &present);
109 if (GSS_ERROR(major))
111 throw GSSException("Cannot check if an OID is included in a set.", major, minor);
115 return (present == 1);
118 bool GSSOIDSet::includes ( const GSSOID &oid ) const
120 return(this->includes( oid.toGss() ) );
124 * Desired JSON Output:
132 JSONObject* GSSOIDSet::toJSONValue() const
135 JSONObject jsonArray = JSONObject::array();
136 JSONObject *ret, *temp;
142 for (index = 0; index < set->count; index++)
144 GSSOID m( set->elements + index );
145 temp = m.toJSONValue();
146 jsonArray.append( *temp );
149 ret = new JSONObject(jsonArray);