Remove redundant definition of gss_imp_name_type
[gssweb.git] / json_gssapi / src / commands / GSSImportName.cpp
index 2e6d5c7..6ce0335 100644 (file)
@@ -1,21 +1,41 @@
 /*
- * Copyright (c) 2014 <copyright holder> <email>
- * 
- * For license details, see the LICENSE file in the root of this project.
- * 
+ * Copyright (c) 2014, JANET(UK)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of JANET(UK) nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
  */
 
 #include "GSSImportName.h"
 #include "GSSException.h"
 #include <cache/GSSNameCache.h>
-
-
-typedef OM_uint32 (*gss_imp_name_type)(
-    OM_uint32 *,        /* minor_status */
-    gss_buffer_t,       /* input_name_buffer */
-    gss_OID,            /* input_name_type(used to be const) */
-    gss_name_t *);      /* output_name */
-
+#include <datamodel/GSSDisplayStatus.h>
 
 
 void GSSImportName::execute()
@@ -29,13 +49,17 @@ void GSSImportName::execute()
 
   /* Main */
   retVal = function(&minor_status, inputName.toGss(), inputNameType.toGss(), &name);
-  if ( GSS_ERROR(this->retVal) )
-  {
-    std::string errMsg;
-    errMsg += "Cannot import name: ";
-    errMsg += inputName.toString();
-    throw GSSException(errMsg.c_str(), this->retVal, this->minor_status, inputNameType.toGss());
-  }
+//   if ( GSS_ERROR(this->retVal) )
+//   {
+    JSONObject errors;
+    GSSDisplayStatus ds(retVal, minor_status, inputNameType.toGss());
+    errors.set("major_status_message", ds.getMajorMessage().c_str());
+    errors.set("minor_status_message", ds.getMinorMessage().c_str());
+    values->set("errors", errors);
+//   }
+  
+  
+  
   this->outputName.setValue(name);
   key = GSSNameCache::instance()->store(this->outputName);
 //   std::cout << "Storing key: " << key << std::endl;
@@ -57,8 +81,6 @@ void GSSImportName::execute()
 JSONObject *GSSImportName::toJSON()
 {
   /* Variables */
-  JSONObject *values = new JSONObject();
-  
   /* Error checking */
   
   /* Setup */
@@ -78,8 +100,9 @@ GSSImportName::GSSImportName ( gss_imp_name_type fn )
 {
   // defaults
   function = fn;
-  inputName = "";
-  inputNameType.setValue(GSSBuffer("{ 1 2 840 113554 1 2 1 4 }"));
+  inputName = string("");
+  inputNameType.setValue(GSSBuffer( string("{ 1 2 840 113554 1 2 1 4 }") ));
+  values = new JSONObject();
 }
 
 GSSImportName::GSSImportName(JSONObject *params, gss_imp_name_type fn) : GSSCommand(params)
@@ -88,6 +111,7 @@ GSSImportName::GSSImportName(JSONObject *params, gss_imp_name_type fn) : GSSComm
   /* Error checking */
   /* Setup */
   /* Main */
+  values = new JSONObject();
   loadParameters(params);
   function = fn;
   /* Cleanup */