04c8d62813cdd8d3d632f0279400b9ab6549bc58
[gssweb.git] / json_gssapi / src / datamodel / GSSDisplayStatus.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 "GSSDisplayStatus.h"
9
10 #include <sstream>
11
12 static void disp_status(OM_uint32 status, int status_type, gss_OID mech, std::ostream &output_stream)
13 {
14   OM_uint32 disp_major, disp_minor, disp_context;
15   gss_buffer_desc disp_buf;
16
17   disp_context = 0;
18   do
19   {
20     disp_major = gss_display_status(&disp_minor, 
21                                     status, 
22                                     status_type,
23                                     mech, 
24                                     &disp_context, 
25                                     &disp_buf);
26     if (GSS_ERROR(disp_major))
27     {
28       output_stream << "Internal, unknown GSS error";
29       break; // Get out of this loop.
30     } else
31       output_stream << (char *)disp_buf.value;
32   } while (disp_context != 0);
33 }
34
35
36 GSSDisplayStatus::GSSDisplayStatus(OM_uint32 major, 
37                      OM_uint32 minor,
38                      gss_OID   mech  )
39 {
40   std::stringstream major_stream;
41   std::stringstream minor_stream;
42   /* Setup */
43   
44   /* Main */
45   disp_status(major, GSS_C_GSS_CODE, mech, major_stream);
46   majorMessage = major_stream.str();
47   
48   disp_status(minor, GSS_C_MECH_CODE, mech, minor_stream);
49   minorMessage = minor_stream.str();
50 }
51
52 GSSDisplayStatus::~GSSDisplayStatus()
53 {
54
55 }
56