init_creds.c revision 72445
1/* 2 * Copyright (c) 1997 - 2001 Kungliga Tekniska H�gskolan 3 * (Royal Institute of Technology, Stockholm, Sweden). 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * 3. Neither the name of the Institute nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#include "krb5_locl.h" 35 36RCSID("$Id: init_creds.c,v 1.5 2001/01/05 16:27:39 joda Exp $"); 37 38void 39krb5_get_init_creds_opt_init(krb5_get_init_creds_opt *opt) 40{ 41 memset (opt, 0, sizeof(*opt)); 42 opt->flags = 0; 43} 44 45void 46krb5_get_init_creds_opt_set_default_flags(krb5_context context, 47 const char *appname, 48 krb5_realm realm, 49 krb5_get_init_creds_opt *opt) 50{ 51 krb5_boolean b; 52 time_t t; 53 54 krb5_appdefault_boolean(context, appname, realm, "forwardable", FALSE, &b); 55 krb5_get_init_creds_opt_set_forwardable(opt, b); 56 57 krb5_appdefault_boolean(context, appname, realm, "proxiable", FALSE, &b); 58 krb5_get_init_creds_opt_set_proxiable (opt, b); 59 60 krb5_appdefault_time(context, appname, realm, "ticket_life", 0, &t); 61 if(t != 0) 62 krb5_get_init_creds_opt_set_tkt_life(opt, t); 63 64 krb5_appdefault_time(context, appname, realm, "renewable_life", 0, &t); 65 if(t != 0) 66 krb5_get_init_creds_opt_set_renew_life(opt, t); 67 68#if 0 69 krb5_appdefault_boolean(context, appname, realm, "anonymous", FALSE, &b); 70 krb5_get_init_creds_opt_set_anonymous (opt, b); 71 72 krb5_get_init_creds_opt_set_etype_list(opt, enctype, 73 etype_str.num_strings); 74 75 krb5_get_init_creds_opt_set_salt(krb5_get_init_creds_opt *opt, 76 krb5_data *salt); 77 78 krb5_get_init_creds_opt_set_preauth_list(krb5_get_init_creds_opt *opt, 79 krb5_preauthtype *preauth_list, 80 int preauth_list_length); 81 krb5_get_init_creds_opt_set_address_list(krb5_get_init_creds_opt *opt, 82 krb5_addresses *addresses); 83#endif 84} 85 86 87void 88krb5_get_init_creds_opt_set_tkt_life(krb5_get_init_creds_opt *opt, 89 krb5_deltat tkt_life) 90{ 91 opt->flags |= KRB5_GET_INIT_CREDS_OPT_TKT_LIFE; 92 opt->tkt_life = tkt_life; 93} 94 95void 96krb5_get_init_creds_opt_set_renew_life(krb5_get_init_creds_opt *opt, 97 krb5_deltat renew_life) 98{ 99 opt->flags |= KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE; 100 opt->renew_life = renew_life; 101} 102 103void 104krb5_get_init_creds_opt_set_forwardable(krb5_get_init_creds_opt *opt, 105 int forwardable) 106{ 107 opt->flags |= KRB5_GET_INIT_CREDS_OPT_FORWARDABLE; 108 opt->forwardable = forwardable; 109} 110 111void 112krb5_get_init_creds_opt_set_proxiable(krb5_get_init_creds_opt *opt, 113 int proxiable) 114{ 115 opt->flags |= KRB5_GET_INIT_CREDS_OPT_PROXIABLE; 116 opt->proxiable = proxiable; 117} 118 119void 120krb5_get_init_creds_opt_set_etype_list(krb5_get_init_creds_opt *opt, 121 krb5_enctype *etype_list, 122 int etype_list_length) 123{ 124 opt->flags |= KRB5_GET_INIT_CREDS_OPT_ETYPE_LIST; 125 opt->etype_list = etype_list; 126 opt->etype_list_length = etype_list_length; 127} 128 129void 130krb5_get_init_creds_opt_set_address_list(krb5_get_init_creds_opt *opt, 131 krb5_addresses *addresses) 132{ 133 opt->flags |= KRB5_GET_INIT_CREDS_OPT_ADDRESS_LIST; 134 opt->address_list = addresses; 135} 136 137void 138krb5_get_init_creds_opt_set_preauth_list(krb5_get_init_creds_opt *opt, 139 krb5_preauthtype *preauth_list, 140 int preauth_list_length) 141{ 142 opt->flags |= KRB5_GET_INIT_CREDS_OPT_PREAUTH_LIST; 143 opt->preauth_list_length = preauth_list_length; 144 opt->preauth_list = preauth_list; 145} 146 147void 148krb5_get_init_creds_opt_set_salt(krb5_get_init_creds_opt *opt, 149 krb5_data *salt) 150{ 151 opt->flags |= KRB5_GET_INIT_CREDS_OPT_SALT; 152 opt->salt = salt; 153} 154 155void 156krb5_get_init_creds_opt_set_anonymous(krb5_get_init_creds_opt *opt, 157 int anonymous) 158{ 159 opt->flags |= KRB5_GET_INIT_CREDS_OPT_ANONYMOUS; 160 opt->anonymous = anonymous; 161} 162