external.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* SASL server API implementation
* Rob Siemborski
* Tim Martin
* $Id: external.c,v 1.19 2003/04/08 17:30:54 rjs3 Exp $
*/
/*
* Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The name "Carnegie Mellon University" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For permission or any other legal
* details, please contact
* Office of Technology Transfer
* Carnegie Mellon University
* 5000 Forbes Avenue
* Pittsburgh, PA 15213-3890
* (412) 268-4387, fax: (412) 268-7395
* tech-transfer@andrew.cmu.edu
*
* 4. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by Computing Services
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
*
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <string.h>
#include <sasl.h>
#include <saslplug.h>
#include "saslint.h"
#include <plugin_common.h>
/***************************** Common Section *****************************/
#ifndef _SUN_SDK_
static const char plugin_id[] = "$Id: external.c,v 1.19 2003/04/08 17:30:54 rjs3 Exp $";
#endif /* !_SUN_SDK_ */
/***************************** Server Section *****************************/
static int
void **conn_context)
{
if (!conn_context
|| !sparams
return SASL_BADPARAM;
return SASL_NOMECH;
*conn_context = NULL;
return SASL_OK;
}
static int
const char *clientin,
unsigned clientinlen,
const char **serverout,
unsigned *serveroutlen,
{
int result;
if (!sparams
|| !serverout
|| !serveroutlen
|| !oparams)
return SASL_BADPARAM;
return SASL_BADPROT;
#ifdef _INTEGRATED_SOLARIS_
gettext("anonymous login not allowed"));
#else
#endif /* _INTEGRATED_SOLARIS_ */
return SASL_NOAUTHZ;
}
*serveroutlen = 0;
if (!clientin) {
/* No initial data; we're in a protocol which doesn't support it.
* So we let the server app know that we need some... */
return SASL_CONTINUE;
}
if (clientinlen) { /* if we have a non-zero authorization id */
/* The user's trying to authorize as someone they didn't
* authenticate as */
} else {
}
/* set oparams */
oparams->param_version = 0;
return SASL_OK;
}
static int
{
return SASL_NOMECH;
return SASL_OK;
}
static sasl_server_plug_t external_server_plugins[] =
{
{
"EXTERNAL", /* mech_name */
0, /* max_ssf */
| SASL_SEC_NODICTIONARY, /* security_flags */
| SASL_FEAT_ALLOWS_PROXY, /* features */
NULL, /* glob_context */
&external_server_mech_new, /* mech_new */
&external_server_mech_step, /* mech_step */
NULL, /* mech_dispose */
NULL, /* mech_free */
NULL, /* setpass */
NULL, /* user_query */
NULL, /* idle */
&external_server_mech_avail, /* mech_avail */
NULL /* spare */
}
};
int max_version,
int *out_version,
int *plugcount)
{
return SASL_BADPARAM;
if (max_version != SASL_SERVER_PLUG_VERSION) {
#ifdef _SUN_SDK_
#else
#endif /* _SUN_SDK_ */
return SASL_BADVERS;
}
*plugcount = 1;
return SASL_OK;
}
/***************************** Client Section *****************************/
typedef struct client_context
{
char *out_buf;
#ifdef _SUN_SDK_
unsigned out_buf_len;
#else
#endif /* _SUN_SDK_ */
#ifdef _INTEGRATED_SOLARIS_
void *h;
#endif /* _INTEGRATED_SOLARIS_ */
void **conn_context)
{
if (!params
|| !conn_context)
return SASL_BADPARAM;
return SASL_NOMECH;
#ifdef _SUN_SDK_
#else
#endif /* _SUN_SDK_ */
if(!text) return SASL_NOMEM;
*conn_context = text;
return SASL_OK;
}
static int
unsigned serverinlen,
const char **clientout,
unsigned *clientoutlen,
{
int user_result = SASL_OK;
int result;
if (!params
|| !clientout
|| !clientoutlen
|| !oparams)
return SASL_BADPARAM;
return SASL_BADPROT;
if (serverinlen != 0)
return SASL_BADPROT;
*clientoutlen = 0;
/* try to get the userid */
return user_result;
}
/* free prompts we got */
if (prompt_need && *prompt_need) {
*prompt_need = NULL;
}
/* if there are prompts not filled in */
if (user_result == SASL_INTERACT) {
/* make the prompt list */
int result =
#ifdef _INTEGRATED_SOLARIS_
user_result == SASL_INTERACT ?
gettext("Please enter your authorization name"))
: NULL,
#else
user_result == SASL_INTERACT ?
"Please enter your authorization name" : NULL,
#endif /* _INTEGRATED_SOLARIS_ */
"",
return SASL_INTERACT;
}
#ifdef _SUN_SDK_
#else
#endif /* _SUN_SDK_ */
} else {
}
/* set oparams */
oparams->param_version = 0;
return SASL_OK;
}
static void
{
if (!text) return;
#ifdef _INTEGRATED_SOLARIS_
#endif /* _INTEGRATED_SOLARIS_ */
#ifdef _SUN_SDK_
#else
#endif /* _SUN_SDK_ */
}
#ifdef _SUN_SDK_
static const unsigned long external_required_prompts[] = {
#else
static const long external_required_prompts[] = {
#endif /* _SUN_SDK_ */
};
static sasl_client_plug_t external_client_plugins[] =
{
{
"EXTERNAL", /* mech_name */
0, /* max_ssf */
| SASL_SEC_NODICTIONARY, /* security_flags */
| SASL_FEAT_ALLOWS_PROXY, /* features */
external_required_prompts, /* required_prompts */
NULL, /* glob_context */
&external_client_mech_new, /* mech_new */
&external_client_mech_step, /* mech_step */
&external_client_mech_dispose, /* mech_dispose */
NULL, /* mech_free */
NULL, /* idle */
NULL, /* spare */
NULL /* spare */
}
};
int max_version,
int *out_version,
int *plugcount)
{
return SASL_BADPARAM;
if (max_version != SASL_CLIENT_PLUG_VERSION) {
#ifdef _SUN_SDK_
#else
#endif /* _SUN_SDK_ */
return SASL_BADVERS;
}
*plugcount = 1;
return SASL_OK;
}