Update of /cvsroot/aolserver/knspnego/include In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv7639/include Added Files: base64.h knexportlibraryknspnego.h knexportlibraryknspnegomodule.h spnegoconfig.h spnegohelp.h Log Message: First version of port of Apache's "mod_spnego" to AOLServer. Works, but is difficult to configure (relies on environment variables the way Apache does, instead of ns_section/ns_param) and needs some work for integration into the AOLServer "configure" environment. --- NEW FILE: base64.h --- /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as * applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * The apr_vsnprintf/apr_snprintf functions are based on, and used with the * permission of, the SIO stdio-replacement strx_* functions by Panos * Tsirigotis <pa...@al...> for xinetd. */ /** * @file base64.h * @brief APR-UTIL Base64 Encoding */ #ifndef BASE64_H #define BASE64_H //#include "apu.h" //#include "apr_general.h" #ifdef __cplusplus extern "C" { #endif /** * @defgroup APR_Util_Base64 Base64 Encoding * @ingroup APR_Util * @{ */ /* Simple BASE64 encode/decode functions. * * As we might encode binary strings, hence we require the length of * the incoming plain source. And return the length of what we decoded. * * The decoding function takes any non valid char (i.e. whitespace, \0 * or anything non A-Z,0-9 etc as terminal. * * plain strings/binary sequences are not assumed '\0' terminated. Encoded * strings are neither. But probably should. * */ /** * Given the length of an un-encrypted string, get the length of the * encrypted string. * @param len the length of an unencrypted string. * @return the length of the string after it is encrypted */ int base64_encode_len(int len); /** * Encode a text string using base64encoding. * @param coded_dst The destination string for the encoded string. * @param plain_src The original string in plain text * @param len_plain_src The length of the plain text string * @return the length of the encoded string */ int base64_encode(char * coded_dst, const char *plain_src, int len_plain_src); /** * Encode an EBCDIC string using base64encoding. * @param coded_dst The destination string for the encoded string. * @param plain_src The original string in plain text * @param len_plain_src The length of the plain text string * @return the length of the encoded string */ int base64_encode_binary(char * coded_dst, const unsigned char *plain_src, int len_plain_src); /** * Determine the length of a plain text string given the encoded version * @param coded_src The encoded string * @return the length of the plain text string */ int base64_decode_len(const char * coded_src); /** * Decode a string to plain text * @param plain_dst The destination string for the plain text * @param coded_src The encoded string * @return the length of the plain text string */ int base64_decode(char * plain_dst, const char *coded_src); /** * Decode an EBCDIC string to plain text * @param plain_dst The destination string for the plain text * @param coded_src The encoded string * @return the length of the plain text string */ int base64_decode_binary(unsigned char * plain_dst, const char *coded_src); /** @} */ #ifdef __cplusplus } #endif #endif /* !bASE64_H */ --- NEW FILE: knexportlibraryknspnego.h --- /* /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * 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 * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * Defines export/import declarations for windows interfaces for this dll. * It is important to declare this as export when compiling modules in the dll * and import for modules not in the dll. */ #ifndef KNEXPORTLIBRARYKNSPNEGO_H #define KNEXPORTLIBRARYKNSPNEGO_H #ifdef WIN32 #ifdef EXPORT_LIBRARY_KNSPNEGO_MODULE #define EXPORT_LIBRARY_KNSPNEGO __declspec(dllexport) #else #define EXPORT_LIBRARY_KNSPNEGO __declspec(dllimport) #endif #else #define EXPORT_LIBRARY_KNSPNEGO #endif #endif /* KNEXPORTLIBRARYKNSPNEGO_H */ --- NEW FILE: knexportlibraryknspnegomodule.h --- /* /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * 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 * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * Defines this modules as part of the knconfig.dll. * See knexportlibraryknconfig.h for more details. */ #define EXPORT_LIBRARY_KNSPNEGO_MODULE #include "knexportlibraryknspnego.h" --- NEW FILE: spnegoconfig.h --- /* ----------------------------------------------------------------------------- /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * 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 * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * spnegoconfig.h declares classes for handling configuration parameters. * * Author: Avet Mnatsakanian * * ----------------------------------------------------------------------------- */ #ifndef SPNEGOCONFIG_H #define SPNEGOCONFIG_H #define APR_HAS_ANSI_FS 1 #define APR_HAS_UNICODE_FS 0 #define APR_SUCCESS 0 #define HTTP_CONTINUE 100 #define HTTP_SWITCHING_PROTOCOLS 101 #define HTTP_PROCESSING 102 #define HTTP_OK 200 #define HTTP_CREATED 201 #define HTTP_ACCEPTED 202 #define HTTP_NON_AUTHORITATIVE 203 #define HTTP_NO_CONTENT 204 #define HTTP_RESET_CONTENT 205 #define HTTP_PARTIAL_CONTENT 206 #define HTTP_MULTI_STATUS 207 #define HTTP_MULTIPLE_CHOICES 300 #define HTTP_MOVED_PERMANENTLY 301 #define HTTP_MOVED_TEMPORARILY 302 #define HTTP_SEE_OTHER 303 #define HTTP_NOT_MODIFIED 304 #define HTTP_USE_PROXY 305 #define HTTP_TEMPORARY_REDIRECT 307 #define HTTP_BAD_REQUEST 400 #define HTTP_UNAUTHORIZED 401 #define HTTP_PAYMENT_REQUIRED 402 #define HTTP_FORBIDDEN 403 #define HTTP_NOT_FOUND 404 #define HTTP_METHOD_NOT_ALLOWED 405 #define HTTP_NOT_ACCEPTABLE 406 #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407 #define HTTP_REQUEST_TIME_OUT 408 #define HTTP_CONFLICT 409 #define HTTP_GONE 410 #define HTTP_LENGTH_REQUIRED 411 #define HTTP_PRECONDITION_FAILED 412 #define HTTP_REQUEST_ENTITY_TOO_LARGE 413 #define HTTP_REQUEST_URI_TOO_LARGE 414 #define HTTP_UNSUPPORTED_MEDIA_TYPE 415 #define HTTP_RANGE_NOT_SATISFIABLE 416 #define HTTP_EXPECTATION_FAILED 417 #define HTTP_UNPROCESSABLE_ENTITY 422 #define HTTP_LOCKED 423 #define HTTP_FAILED_DEPENDENCY 424 #define HTTP_UPGRADE_REQUIRED 426 #define HTTP_INTERNAL_SERVER_ERROR 500 #define HTTP_NOT_IMPLEMENTED 501 #define HTTP_BAD_GATEWAY 502 #define HTTP_SERVICE_UNAVAILABLE 503 #define HTTP_GATEWAY_TIME_OUT 504 #define HTTP_VERSION_NOT_SUPPORTED 505 #define HTTP_VARIANT_ALSO_VARIES 506 #define HTTP_INSUFFICIENT_STORAGE 507 #define HTTP_NOT_EXTENDED 510 /*#ifdef __cplusplus extern "C" { #endif */ #include "ns.h" #include <openssl/asn1.h> /* Object identifier declarations. */ extern const ASN1_OBJECT spnegoGssApi; /* 1.3.6.1.5.5.2 */ /* ----------------------------------------------------------------------------- * makeNegTokenTarg makes an RFC 2478 SPNEGO NegTokenTarg (token) from an * RFC 1964 Kerberos GSS-API token. * * If makeNegTokenTarg is successful, call free (*negTokenTarg) to free the * memory allocated by parseNegTokenInit. * * Returns 0 if successful, 1 otherwise. * ----------------------------------------------------------------------------- */ class DIRECTORY_CONFIG { private: const char * krb5KeyTabFile; const char * krb5ServiceName; public: void setKrb5KeyTabFile(char *tabFile){krb5KeyTabFile = tabFile;} void setKrb5ServiceName(char *srvcName){krb5ServiceName = srvcName;} const char* getKrb5KeyTabFile(){return krb5KeyTabFile;} const char* getKrb5ServiceName(){return krb5ServiceName;} }; // DIRECTORY_CONFIG; class SERVER_CONFIG { int krb5AuthEachReq; public: void setKrb5AuthEachReq(int on){krb5AuthEachReq = on;} int getKrb5AuthEachReq(){return krb5AuthEachReq;} }; class SPNEGO_CONFIG { public: static DIRECTORY_CONFIG *directoryConfig ; static SERVER_CONFIG *serverConfig; static const char *authType; static void setAuthType(char *type) {authType = type;} static const char *getAuthType() {return authType;} static DIRECTORY_CONFIG* getDirConfig(){return directoryConfig;}; static SERVER_CONFIG* getServerConfig(){return serverConfig;}; }; int apr_env_set(const char *envvar, const char *value); //int authenticateUser (Conn *connPtr, const char *authToken); /* #ifdef __cplusplus } #endif */ #endif /*SPNEGOCONFIG_H */ --- NEW FILE: spnegohelp.h --- /* ----------------------------------------------------------------------------- * spnegohelp.h declares RFC 2478 SPNEGO GSS-API mechanism helper APIs. * * Author: Frank Balluffi * * Copyright (C) 2002-2005 Frank Balluffi. All rights reserved. * ----------------------------------------------------------------------------- */ #ifndef SPNEGOHELP_H #define SPNEGOHELP_H #ifdef __cplusplus extern "C" { #endif #include <openssl/asn1.h> //#include <stddef.h> /* Object identifier declarations. */ extern const ASN1_OBJECT spnegoGssApi; /* 1.3.6.1.5.5.2 */ /* ----------------------------------------------------------------------------- * makeSpnegoInitialToken makes an RFC 2743 GSS-API InitialContextToken * containing an RFC 2478 SPNEGO NegotiationToken of choice negTokenInit from a * mechanism token. * * If makeSpnegoInitialToken is successful, call free (spnegoToken), where * spnegoToken is of type unsigned char *, to free the memory allocated by * makeSpnegoInitialToken. * * Returns 1 if successful, 0 otherwise. * ----------------------------------------------------------------------------- */ int makeSpnegoInitialToken (const ASN1_OBJECT * mechType, const unsigned char * mechToken, size_t mechTokenLength, unsigned char ** spnegoToken, size_t * spnegoTokenLength); /* ----------------------------------------------------------------------------- * makeSpnegoTargetToken makes an RFC 2743 GSS-API InitialContextToken * containing an RFC 2478 SPNEGO NegotiationToken of choice negTokenTarg from a * response token. * * If makeSpnegoTargetToken is successful, call free (spnegoToken), where * spnegoToken is of type unsigned char *, to free the memory allocated by * makeSpnegoTargetToken. * * Returns 1 if successful, 0 otherwise. * ----------------------------------------------------------------------------- */ int makeSpnegoTargetToken (const long * negResult, const ASN1_OBJECT * supportedMech, const unsigned char * responseToken, size_t responseTokenLength, const unsigned char * mechListMic, size_t mechListMicLength, unsigned char ** spnegoToken, size_t * spnegoTokenLength); /* ----------------------------------------------------------------------------- * parseSpnegoInitialToken parses an RFC 2743 GSS-API InitialContextToken * containing an RFC 2478 SPNEGO NegotiationToken of choice negTokenInit, and * optionally searches for a mechanism type and extracts the mechanism token. * * If parseSpnegoInitialToken is successful, call free (mechToken), where * mechToken is of type unsigned char *, to free the memory allocated by * parseSpnegoInitialToken. * * Returns 1 if successful, 0 otherwise. * ----------------------------------------------------------------------------- */ int parseSpnegoInitialToken (const unsigned char * spnegoToken, size_t spnegoTokenLength, const ASN1_OBJECT * mechType, unsigned char ** mechToken, size_t * mechTokenLength); /* ----------------------------------------------------------------------------- * parseSpnegoTargetToken parses an RFC 2743 GSS-API InitialContextToken * containing an RFC 2478 SPNEGO NegotiationToken of choice negTokenTarg. * * If parseSpnegoTargetToken is successful, call * ASN1_OBJECT_free (supportedMech), free (responseToken) and * free (mechListMIC), where supportedMech, responseToken and mechListMIC are of * types ASN1_OBJECT *, unsigned char * and unsigned char *, to free the memory * allocated by parseSpnegoTargetToken. * * parseSpnegoTargetToken 1 if successful, 0 otherwise. * ----------------------------------------------------------------------------- */ int parseSpnegoTargetToken (const unsigned char * spnegoToken, size_t spnegoTokenLength, long * negResult, ASN1_OBJECT ** supportedMech, unsigned char ** responseToken, size_t * responseTokenLength, unsigned char ** mechListMIC, size_t * mechListMICLength); #ifdef __cplusplus } #endif #endif /* SPNEGOHELP_H */ |