2cf6a420b4b9e2230239c9cce4b379c30a85ae65
[gssweb.git] / json_gssapi / src / GSSImportName.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 "GSSImportName.h"
9 #include "GSSException.h"
10
11 void GSSImportName::execute()
12 {
13   this->outputName = GSSName(inputName, inputNameType, function);
14   this->retVal = this->outputName.getMajorStatus();
15   this->minor_status = this->outputName.getMinorStatus();
16   this->outputName.setKey("constant for now");
17 }
18
19 JSONObject *GSSImportName::toJSON()
20 {
21   /* Variables */
22   JSONObject *ret = new JSONObject();
23   JSONObject *values = new JSONObject();
24   
25   /* Error checking */
26   
27   /* Setup */
28   
29   /* Main */
30   values->set("major_status", this->retVal);
31   values->set("minor_status", this->minor_status);
32   values->set("gss_name", this->outputName.getKey().c_str() );
33   ret->set("command", "gss_import_name");
34   ret->set("return_values", *values);
35   
36   /* Cleanup */
37   
38   /* Return */
39   return(ret);
40 }
41
42 GSSImportName::GSSImportName(JSONObject *params, gss_imp_name_type fn) : GSSCommand(params)
43 {
44   /* Variables */
45   /* Error checking */
46   /* Setup */
47   /* Main */
48   loadParameters(params);
49   function = fn;
50   /* Cleanup */
51   /* Return */
52   
53 }
54
55 bool GSSImportName::loadParameters(JSONObject *params)
56 {
57   /* Variables */
58   /* Error checking */
59   /* Setup */
60   // Should I zeroOut?
61   
62   /* Main processing */
63   // Easy stuff(*params)
64   std::string input_name = (*params)["arguments"]["input_name"].string();
65   std::string input_name_type = (*params)["arguments"]["input_name_type"].string();
66   
67   this->inputName.setValue( input_name );
68   this->inputNameType.setValue( input_name_type );
69   
70   /* Cleanup */
71   /* Return */
72   return true;
73 }
74
75
76 /* Variables */
77 /* Error checking */
78 /* Setup */
79 /* Main */
80 /* Cleanup */
81 /* Return */