1b528cefcSMark Murray /* 25e9cd1aeSAssar Westerlund * Copyright (c) 1997 - 2001 Kungliga Tekniska H�gskolan 3b528cefcSMark Murray * (Royal Institute of Technology, Stockholm, Sweden). 4b528cefcSMark Murray * All rights reserved. 5b528cefcSMark Murray * 6b528cefcSMark Murray * Redistribution and use in source and binary forms, with or without 7b528cefcSMark Murray * modification, are permitted provided that the following conditions 8b528cefcSMark Murray * are met: 9b528cefcSMark Murray * 10b528cefcSMark Murray * 1. Redistributions of source code must retain the above copyright 11b528cefcSMark Murray * notice, this list of conditions and the following disclaimer. 12b528cefcSMark Murray * 13b528cefcSMark Murray * 2. Redistributions in binary form must reproduce the above copyright 14b528cefcSMark Murray * notice, this list of conditions and the following disclaimer in the 15b528cefcSMark Murray * documentation and/or other materials provided with the distribution. 16b528cefcSMark Murray * 17b528cefcSMark Murray * 3. Neither the name of the Institute nor the names of its contributors 18b528cefcSMark Murray * may be used to endorse or promote products derived from this software 19b528cefcSMark Murray * without specific prior written permission. 20b528cefcSMark Murray * 21b528cefcSMark Murray * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22b528cefcSMark Murray * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23b528cefcSMark Murray * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24b528cefcSMark Murray * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25b528cefcSMark Murray * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26b528cefcSMark Murray * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27b528cefcSMark Murray * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28b528cefcSMark Murray * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29b528cefcSMark Murray * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30b528cefcSMark Murray * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31b528cefcSMark Murray * SUCH DAMAGE. 32b528cefcSMark Murray */ 33b528cefcSMark Murray 34b528cefcSMark Murray #include "krb5_locl.h" 35b528cefcSMark Murray 365e9cd1aeSAssar Westerlund RCSID("$Id: init_creds.c,v 1.5 2001/01/05 16:27:39 joda Exp $"); 37b528cefcSMark Murray 38b528cefcSMark Murray void 39b528cefcSMark Murray krb5_get_init_creds_opt_init(krb5_get_init_creds_opt *opt) 40b528cefcSMark Murray { 41b528cefcSMark Murray memset (opt, 0, sizeof(*opt)); 42b528cefcSMark Murray opt->flags = 0; 43b528cefcSMark Murray } 44b528cefcSMark Murray 45b528cefcSMark Murray void 465e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_default_flags(krb5_context context, 475e9cd1aeSAssar Westerlund const char *appname, 485e9cd1aeSAssar Westerlund krb5_realm realm, 495e9cd1aeSAssar Westerlund krb5_get_init_creds_opt *opt) 505e9cd1aeSAssar Westerlund { 515e9cd1aeSAssar Westerlund krb5_boolean b; 525e9cd1aeSAssar Westerlund time_t t; 535e9cd1aeSAssar Westerlund 545e9cd1aeSAssar Westerlund krb5_appdefault_boolean(context, appname, realm, "forwardable", FALSE, &b); 555e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_forwardable(opt, b); 565e9cd1aeSAssar Westerlund 575e9cd1aeSAssar Westerlund krb5_appdefault_boolean(context, appname, realm, "proxiable", FALSE, &b); 585e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_proxiable (opt, b); 595e9cd1aeSAssar Westerlund 605e9cd1aeSAssar Westerlund krb5_appdefault_time(context, appname, realm, "ticket_life", 0, &t); 615e9cd1aeSAssar Westerlund if(t != 0) 625e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_tkt_life(opt, t); 635e9cd1aeSAssar Westerlund 645e9cd1aeSAssar Westerlund krb5_appdefault_time(context, appname, realm, "renewable_life", 0, &t); 655e9cd1aeSAssar Westerlund if(t != 0) 665e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_renew_life(opt, t); 675e9cd1aeSAssar Westerlund 685e9cd1aeSAssar Westerlund #if 0 695e9cd1aeSAssar Westerlund krb5_appdefault_boolean(context, appname, realm, "anonymous", FALSE, &b); 705e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_anonymous (opt, b); 715e9cd1aeSAssar Westerlund 725e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_etype_list(opt, enctype, 735e9cd1aeSAssar Westerlund etype_str.num_strings); 745e9cd1aeSAssar Westerlund 755e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_salt(krb5_get_init_creds_opt *opt, 765e9cd1aeSAssar Westerlund krb5_data *salt); 775e9cd1aeSAssar Westerlund 785e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_preauth_list(krb5_get_init_creds_opt *opt, 795e9cd1aeSAssar Westerlund krb5_preauthtype *preauth_list, 805e9cd1aeSAssar Westerlund int preauth_list_length); 815e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_address_list(krb5_get_init_creds_opt *opt, 825e9cd1aeSAssar Westerlund krb5_addresses *addresses); 835e9cd1aeSAssar Westerlund #endif 845e9cd1aeSAssar Westerlund } 855e9cd1aeSAssar Westerlund 865e9cd1aeSAssar Westerlund 875e9cd1aeSAssar Westerlund void 88b528cefcSMark Murray krb5_get_init_creds_opt_set_tkt_life(krb5_get_init_creds_opt *opt, 89b528cefcSMark Murray krb5_deltat tkt_life) 90b528cefcSMark Murray { 91b528cefcSMark Murray opt->flags |= KRB5_GET_INIT_CREDS_OPT_TKT_LIFE; 92b528cefcSMark Murray opt->tkt_life = tkt_life; 93b528cefcSMark Murray } 94b528cefcSMark Murray 95b528cefcSMark Murray void 96b528cefcSMark Murray krb5_get_init_creds_opt_set_renew_life(krb5_get_init_creds_opt *opt, 97b528cefcSMark Murray krb5_deltat renew_life) 98b528cefcSMark Murray { 99b528cefcSMark Murray opt->flags |= KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE; 100b528cefcSMark Murray opt->renew_life = renew_life; 101b528cefcSMark Murray } 102b528cefcSMark Murray 103b528cefcSMark Murray void 104b528cefcSMark Murray krb5_get_init_creds_opt_set_forwardable(krb5_get_init_creds_opt *opt, 105b528cefcSMark Murray int forwardable) 106b528cefcSMark Murray { 107b528cefcSMark Murray opt->flags |= KRB5_GET_INIT_CREDS_OPT_FORWARDABLE; 108b528cefcSMark Murray opt->forwardable = forwardable; 109b528cefcSMark Murray } 110b528cefcSMark Murray 111b528cefcSMark Murray void 112b528cefcSMark Murray krb5_get_init_creds_opt_set_proxiable(krb5_get_init_creds_opt *opt, 113b528cefcSMark Murray int proxiable) 114b528cefcSMark Murray { 115b528cefcSMark Murray opt->flags |= KRB5_GET_INIT_CREDS_OPT_PROXIABLE; 116b528cefcSMark Murray opt->proxiable = proxiable; 117b528cefcSMark Murray } 118b528cefcSMark Murray 119b528cefcSMark Murray void 120b528cefcSMark Murray krb5_get_init_creds_opt_set_etype_list(krb5_get_init_creds_opt *opt, 121b528cefcSMark Murray krb5_enctype *etype_list, 122b528cefcSMark Murray int etype_list_length) 123b528cefcSMark Murray { 124b528cefcSMark Murray opt->flags |= KRB5_GET_INIT_CREDS_OPT_ETYPE_LIST; 125b528cefcSMark Murray opt->etype_list = etype_list; 126b528cefcSMark Murray opt->etype_list_length = etype_list_length; 127b528cefcSMark Murray } 128b528cefcSMark Murray 129b528cefcSMark Murray void 130b528cefcSMark Murray krb5_get_init_creds_opt_set_address_list(krb5_get_init_creds_opt *opt, 131b528cefcSMark Murray krb5_addresses *addresses) 132b528cefcSMark Murray { 133b528cefcSMark Murray opt->flags |= KRB5_GET_INIT_CREDS_OPT_ADDRESS_LIST; 134b528cefcSMark Murray opt->address_list = addresses; 135b528cefcSMark Murray } 136b528cefcSMark Murray 137b528cefcSMark Murray void 138b528cefcSMark Murray krb5_get_init_creds_opt_set_preauth_list(krb5_get_init_creds_opt *opt, 139b528cefcSMark Murray krb5_preauthtype *preauth_list, 140b528cefcSMark Murray int preauth_list_length) 141b528cefcSMark Murray { 142b528cefcSMark Murray opt->flags |= KRB5_GET_INIT_CREDS_OPT_PREAUTH_LIST; 143b528cefcSMark Murray opt->preauth_list_length = preauth_list_length; 144b528cefcSMark Murray opt->preauth_list = preauth_list; 145b528cefcSMark Murray } 146b528cefcSMark Murray 147b528cefcSMark Murray void 148b528cefcSMark Murray krb5_get_init_creds_opt_set_salt(krb5_get_init_creds_opt *opt, 149b528cefcSMark Murray krb5_data *salt) 150b528cefcSMark Murray { 151b528cefcSMark Murray opt->flags |= KRB5_GET_INIT_CREDS_OPT_SALT; 152b528cefcSMark Murray opt->salt = salt; 153b528cefcSMark Murray } 1545e9cd1aeSAssar Westerlund 1555e9cd1aeSAssar Westerlund void 1565e9cd1aeSAssar Westerlund krb5_get_init_creds_opt_set_anonymous(krb5_get_init_creds_opt *opt, 1575e9cd1aeSAssar Westerlund int anonymous) 1585e9cd1aeSAssar Westerlund { 1595e9cd1aeSAssar Westerlund opt->flags |= KRB5_GET_INIT_CREDS_OPT_ANONYMOUS; 1605e9cd1aeSAssar Westerlund opt->anonymous = anonymous; 1615e9cd1aeSAssar Westerlund } 162