/*1* Copyright (c) 2007 Kungliga Tekniska Högskolan2* (Royal Institute of Technology, Stockholm, Sweden).3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8*9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* 3. Neither the name of the Institute nor the names of its contributors17* may be used to endorse or promote products derived from this software18* without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#include "kdc_locl.h"3435static krb5plugin_windc_ftable *windcft;36static void *windcctx;3738/*39* Pick the first WINDC module that we find.40*/4142krb5_error_code43krb5_kdc_windc_init(krb5_context context)44{45struct krb5_plugin *list = NULL, *e;46krb5_error_code ret;4748ret = _krb5_plugin_find(context, PLUGIN_TYPE_DATA, "windc", &list);49if(ret != 0 || list == NULL)50return 0;5152for (e = list; e != NULL; e = _krb5_plugin_get_next(e)) {5354windcft = _krb5_plugin_get_symbol(e);55if (windcft->minor_version < KRB5_WINDC_PLUGIN_MINOR)56continue;5758(*windcft->init)(context, &windcctx);59break;60}61_krb5_plugin_free(list);62if (e == NULL) {63krb5_set_error_message(context, ENOENT, "Did not find any WINDC plugin");64windcft = NULL;65return ENOENT;66}6768return 0;69}707172krb5_error_code73_kdc_pac_generate(krb5_context context,74hdb_entry_ex *client,75krb5_pac *pac)76{77*pac = NULL;78if (windcft == NULL)79return 0;80return (windcft->pac_generate)(windcctx, context, client, pac);81}8283krb5_error_code84_kdc_pac_verify(krb5_context context,85const krb5_principal client_principal,86const krb5_principal delegated_proxy_principal,87hdb_entry_ex *client,88hdb_entry_ex *server,89hdb_entry_ex *krbtgt,90krb5_pac *pac,91int *verified)92{93krb5_error_code ret;9495if (windcft == NULL)96return 0;9798ret = windcft->pac_verify(windcctx, context,99client_principal,100delegated_proxy_principal,101client, server, krbtgt, pac);102if (ret == 0)103*verified = 1;104return ret;105}106107krb5_error_code108_kdc_check_access(krb5_context context,109krb5_kdc_configuration *config,110hdb_entry_ex *client_ex, const char *client_name,111hdb_entry_ex *server_ex, const char *server_name,112KDC_REQ *req,113krb5_data *e_data)114{115if (windcft == NULL)116return kdc_check_flags(context, config,117client_ex, client_name,118server_ex, server_name,119req->msg_type == krb_as_req);120121return (windcft->client_access)(windcctx,122context, config,123client_ex, client_name,124server_ex, server_name,125req, e_data);126}127128129