1 /*
2 * Copyright 1999-2006 University of Chicago
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
18 /**
19 * @file globus_gsi_gssapi_error.h
20 * @author Sam Lang, Sam Meder
21 *
22 * $RCSfile: globus_gsi_gss_error.c,v $
23 * $Revision: 1.9 $
24 * $Date: 2006/01/19 05:56:09 $
25 */
26 #endif
27
28 #include "globus_i_gsi_gss_utils.h"
29 #include "globus_gsi_gss_constants.h"
30 #include "globus_error_openssl.h"
31
32 char *
33 globus_l_gsi_gssapi_error_strings[GLOBUS_GSI_GSSAPI_ERROR_LAST] =
34 {
35 /* 0 */ "SSLv3 handshake problems",
36 /* 1 */ "globusid not found",
37 /* 2 */ "getting cert subject name",
38 /* 3 */ "Mutual authentication failed",
39 /* 4 */ "internal problem with SSL BIO",
40 /* 5 */ "Peer is using (limited) proxy",
41 /* 6 */ "Failed to receive proxy request",
42 /* 7 */ "Bad argument",
43 /* 8 */ "Internal SSL problem",
44 /* 9 */ "Cipher not available",
45 /* 10 */ "Token is wrong length",
46 /* 11 */ "Error with gss credential handle",
47 /* 12 */ "Unable to marshal credential for export",
48 /* 13 */ "Unable to read credential for import",
49 /* 14 */ "Input Error",
50 /* 15 */ "Output Error",
51 /* 16 */ "Error with gss context",
52 /* 17 */ "Not in expected Format",
53 /* 18 */ "Error with GSI proxy",
54 /* 19 */ "Error with GSS credential",
55 /* 20 */ "Cannot verify message date",
56 /* 21 */ "Requested mechanism not supported",
57 /* 22 */ "Unable to add extension",
58 /* 23 */ "Unable to verify remote side's credentials",
59 /* 24 */ "Out of memory",
60 /* 25 */ "Bad GSS name",
61 /* 26 */ "Cert chain not in signing order",
62 /* 27 */ "Error with GSI credential",
63 /* 28 */ "Error with openssl",
64 /* 29 */ "Error with GSS token",
65 /* 30 */ "Error during delegation",
66 /* 31 */ "Error with OID",
67 /* 32 */ "Credential has expired",
68 /* 33 */ "Error with MIC (Message Integrity Check)",
69 /* 34 */ "Error could not encrypt message",
70 /* 35 */ "Error with buffer",
71 /* 36 */ "Error getting peer credential",
72 /* 37 */ "Error unknown option",
73 /* 38 */ "Error creating error object",
74 /* 39 */ "Host lookup failed",
75 /* 40 */ "Function not supported on the current platform",
76 /* 41 */ "Authorization denied"
77 };
78
79 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
80
81 /**
82 * @defgroup globus_i_gsi_gssapi_error Internal GSS-API Error Functions
83 */
84 globus_result_t
85 globus_i_gsi_gssapi_openssl_error_result(
86 int error_type,
87 const char * filename,
88 const char * function_name,
89 int line_number,
90 const char * short_desc,
91 const char * long_desc)
92 16 {
93 globus_object_t * error_object;
94 globus_result_t result;
95
96 static char * _function_name_ =
97 "globus_i_gsi_gssapi_openssl_error_result";
98
99 16 GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER;
100
101 16 error_object =
102 globus_error_wrap_openssl_error(
103 GLOBUS_GSI_GSSAPI_MODULE,
104 error_type,
105 filename,
106 function_name,
107 line_number,
108 "%s%s%s",
109 _GGSL(globus_l_gsi_gssapi_error_strings[error_type]),
110 short_desc ? ": " : "",
111 short_desc ? short_desc : "");
112
113 16 if(long_desc)
114 {
115 0 globus_error_set_long_desc(error_object, long_desc);
116 }
117
118 16 result = globus_error_put(error_object);
119
120 16 GLOBUS_I_GSI_GSSAPI_INTERNAL_DEBUG_EXIT;
121 16 return result;
122 }
123
124 globus_result_t
125 globus_i_gsi_gssapi_error_result(
126 const OM_uint32 minor_status,
127 const char * filename,
128 const char * function_name,
129 int line_number,
130 const char * short_desc,
131 const char * long_desc)
132 0 {
133 globus_object_t * error_object;
134 globus_result_t result;
135
136 static char * _function_name_ =
137 "globus_i_gsi_gssapi_error_result";
138
139 0 GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER;
140
141 0 error_object =
142 globus_error_construct_error(
143 GLOBUS_GSI_GSSAPI_MODULE,
144 NULL,
145 GLOBUS_GSI_GSSAPI_ERROR_MINOR_STATUS(minor_status),
146 filename,
147 function_name,
148 line_number,
149 "%s%s%s",
150 globus_l_gsi_gssapi_error_strings[minor_status],
151 short_desc ? ": " : "",
152 short_desc ? short_desc : "");
153
154 0 if(long_desc)
155 {
156 0 globus_error_set_long_desc(error_object, long_desc);
157 }
158
159 0 result = globus_error_put(error_object);
160
161 0 GLOBUS_I_GSI_GSSAPI_INTERNAL_DEBUG_EXIT;
162 0 return result;
163 }
164
165 globus_result_t
166 globus_i_gsi_gssapi_error_chain_result(
167 globus_result_t chain_result,
168 int error_type,
169 const char * filename,
170 const char * function_name,
171 int line_number,
172 const char * short_desc,
173 const char * long_desc)
174 192 {
175 globus_result_t result;
176 globus_object_t * error_object;
177
178 static char * _function_name_ =
179 "globus_i_gsi_gssapi_error_chain_result";
180
181 192 GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER;
182
183 192 error_object =
184 globus_error_construct_error(
185 GLOBUS_GSI_GSSAPI_MODULE,
186 globus_error_get(chain_result),
187 error_type,
188 filename,
189 function_name,
190 line_number,
191 "%s%s%s",
192 _GGSL(globus_l_gsi_gssapi_error_strings[error_type]),
193 short_desc ? ": " : "",
194 short_desc ? short_desc : "");
195
196 192 if(long_desc)
197 {
198 0 globus_error_set_long_desc(error_object, long_desc);
199 }
200
201 192 result = globus_error_put(error_object);
202
203 192 GLOBUS_I_GSI_GSSAPI_INTERNAL_DEBUG_EXIT;
204 192 return result;
205 }
206
207 globus_result_t
208 globus_i_gsi_gssapi_error_join_chains_result(
209 globus_result_t outter_error,
210 globus_result_t inner_error)
211 12 {
212 globus_result_t result;
213 12 globus_object_t * result_error_obj = NULL;
214 12 globus_object_t * outter_error_obj = NULL;
215 12 globus_object_t * inner_error_obj = NULL;
216 12 globus_object_t * temp_error_obj = NULL;
217 static char * _function_name_ =
218 "globus_i_gsi_gssapi_error_join_chains";
219 12 GLOBUS_I_GSI_GSSAPI_DEBUG_ENTER;
220
221 12 outter_error_obj = globus_error_get(outter_error);
222 12 inner_error_obj = globus_error_get(inner_error);
223 24 if(outter_error_obj && inner_error_obj)
224 {
225 12 temp_error_obj = outter_error_obj;
226 36 while(globus_error_get_cause(temp_error_obj))
227 {
228 12 temp_error_obj = globus_error_get_cause(temp_error_obj);
229 }
230
231 12 temp_error_obj = globus_error_initialize_base(temp_error_obj,
232 globus_error_get_source(temp_error_obj),
233 inner_error_obj);
234 12 result_error_obj = outter_error_obj;
235 }
236 0 else if(inner_error_obj)
237 {
238 0 result_error_obj = inner_error_obj;
239 }
240 else
241 {
242 0 result_error_obj =
243 globus_error_construct_error(
244 GLOBUS_GSI_GSSAPI_MODULE,
245 NULL,
246 GLOBUS_GSI_GSSAPI_ERROR_CREATING_ERROR_OBJ,
247 __FILE__,
248 _function_name_,
249 __LINE__,
250 "Couldn't join inner and outter error chains");
251 }
252
253 12 result = globus_error_put(result_error_obj);
254
255 12 GLOBUS_I_GSI_GSSAPI_INTERNAL_DEBUG_EXIT;
256 12 return result;
257 }
258