2 * Copyright (c) 2011, PADL Software Pty Ltd.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of PADL Software nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include "mech_locl.h"
36 gss_acquire_cred_with_password(OM_uint32
*minor_status
,
37 const gss_name_t desired_name
,
38 const gss_buffer_t password
,
40 const gss_OID_set desired_mechs
,
41 gss_cred_usage_t cred_usage
,
42 gss_cred_id_t
*output_cred_handle
,
43 gss_OID_set
*actual_mechs
,
46 OM_uint32 major_status
, tmp_minor
;
48 if (desired_mechs
== GSS_C_NO_OID_SET
) {
49 major_status
= gss_acquire_cred_ext(minor_status
,
57 if (GSS_ERROR(major_status
))
61 struct _gss_cred
*new_cred
;
63 new_cred
= calloc(1, sizeof(*new_cred
));
64 if (new_cred
== NULL
) {
65 *minor_status
= ENOMEM
;
68 HEIM_SLIST_INIT(&new_cred
->gc_mc
);
70 for (i
= 0; i
< desired_mechs
->count
; i
++) {
71 struct _gss_cred
*tmp_cred
= NULL
;
72 struct _gss_mechanism_cred
*mc
;
74 major_status
= gss_acquire_cred_ext(minor_status
,
79 &desired_mechs
->elements
[i
],
81 (gss_cred_id_t
*)&tmp_cred
);
82 if (GSS_ERROR(major_status
))
85 mc
= HEIM_SLIST_FIRST(&tmp_cred
->gc_mc
);
87 HEIM_SLIST_REMOVE_HEAD(&tmp_cred
->gc_mc
, gmc_link
);
88 HEIM_SLIST_INSERT_HEAD(&new_cred
->gc_mc
, mc
, gmc_link
);
91 gss_release_cred(&tmp_minor
, (gss_cred_id_t
*)&tmp_cred
);
94 if (!HEIM_SLIST_FIRST(&new_cred
->gc_mc
)) {
100 *output_cred_handle
= (gss_cred_id_t
)new_cred
;
103 if (actual_mechs
!= NULL
|| time_rec
!= NULL
) {
104 major_status
= gss_inquire_cred(minor_status
,
110 if (GSS_ERROR(major_status
)) {
111 gss_release_cred(&tmp_minor
, output_cred_handle
);
117 return GSS_S_COMPLETE
;