GSS Acquire Cred calling out correctly; slight reorginzation
[gssweb.git] / json_gssapi / src / GSSAcquireCred.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 "GSSAcquireCred.h"
9 #include "GSSException.h"
10
11 GSSAcquireCred::GSSAcquireCred(gss_acq_cred_type fn) : function(fn)
12 {
13
14 }
15
16 GSSAcquireCred::GSSAcquireCred ( const GSSAcquireCred& other )
17 {
18
19 }
20
21 GSSAcquireCred::~GSSAcquireCred()
22 {
23
24 }
25
26 GSSAcquireCred& GSSAcquireCred::operator= ( const GSSAcquireCred& other )
27 {
28   return(*this);
29 }
30
31 GSSAcquireCred::GSSAcquireCred ( JSONObject params ) : GSSCommand ( params )
32 {
33
34 }
35
36
37 void GSSAcquireCred::execute()
38 {
39   /* Variables */
40   gss_cred_id_t output_cred_handle;
41   gss_OID_set   actual_mechs;
42   
43   /* Error checking */
44   /* Setup */
45   /* Main */
46   this->retVal = function(
47     &this->minor_status,
48     this->desired_name.toGss(),
49     this->time_req,
50     this->desiredMechs.toGss(),
51     this->cred_usage,
52     &output_cred_handle,
53     &actual_mechs,
54     &this->time_rec
55   );
56   
57   if (GSS_ERROR(this->retVal) )
58   {
59     std::string err("Error acquiring credential for user '");
60     err += desired_name.toString();
61     err += "'.";
62     throw GSSException(err, this->retVal, this->minor_status);
63   }
64   
65   this->cred.setValue(output_cred_handle);
66   this->actualMechs = actual_mechs;
67   
68   /* Cleanup */
69   /* Return */
70 }
71
72 JSONObject *GSSAcquireCred::toJSON()
73 {
74   return new JSONObject();
75 }