2006-11-13 06:20:43 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Novell, Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, Novell, Inc.
|
|
|
|
*
|
|
|
|
* To contact Novell about this file by physical or electronic mail,
|
|
|
|
* you may find current contact information at www.novell.com.
|
|
|
|
*
|
|
|
|
* Author: Juan Carlos Luciani <jluciani@novell.com>
|
|
|
|
*
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
#ifndef _INTERNAL_H_
|
|
|
|
#define _INTERNAL_H_
|
|
|
|
|
|
|
|
//===[ Include files ]=====================================================
|
|
|
|
|
|
|
|
#include "platform.h"
|
|
|
|
#include <expat.h>
|
|
|
|
#include <micasa_types.h>
|
|
|
|
#include <casa_status.h>
|
|
|
|
#include <casa_c_authtoken.h>
|
|
|
|
#include "list_entry.h"
|
|
|
|
#include "config_if.h"
|
|
|
|
#include "mech_if.h"
|
|
|
|
#include "proto.h"
|
|
|
|
|
|
|
|
//===[ Type definitions ]==================================================
|
|
|
|
|
2007-02-03 00:02:43 +01:00
|
|
|
#define MAX_RPC_REPLY_SZ (256 * 1024)
|
|
|
|
|
2007-05-30 00:59:50 +02:00
|
|
|
//
|
|
|
|
// ATS Host Entry structure
|
|
|
|
//
|
|
|
|
typedef struct _ATSHostEntry
|
|
|
|
{
|
|
|
|
LIST_ENTRY listEntry;
|
|
|
|
char *pNameAndPort;
|
|
|
|
char *pName;
|
|
|
|
uint16_t port;
|
|
|
|
|
|
|
|
|
|
|
|
} ATSHostEntry, *PATSHostEntry;
|
|
|
|
|
2006-11-13 06:20:43 +01:00
|
|
|
//
|
|
|
|
// Authentication Context structure
|
|
|
|
//
|
|
|
|
typedef struct _AuthContext
|
|
|
|
{
|
|
|
|
LIST_ENTRY listEntry;
|
|
|
|
char *pContext;
|
2007-02-06 23:09:00 +01:00
|
|
|
size_t contextLen;
|
2006-11-13 06:20:43 +01:00
|
|
|
char *pMechanism;
|
2007-02-06 23:09:00 +01:00
|
|
|
size_t mechanismLen;
|
2006-11-13 06:20:43 +01:00
|
|
|
char *pMechInfo;
|
2007-02-06 23:09:00 +01:00
|
|
|
size_t mechInfoLen;
|
2006-11-13 06:20:43 +01:00
|
|
|
|
|
|
|
} AuthContext, *PAuthContext;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Authentication Policy structure
|
|
|
|
//
|
|
|
|
typedef struct _AuthPolicy
|
|
|
|
{
|
|
|
|
LIST_ENTRY authContextListHead;
|
|
|
|
|
|
|
|
} AuthPolicy, *PAuthPolicy;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get Authentication Policy Response structure
|
|
|
|
//
|
|
|
|
typedef struct _GetAuthPolicyResp
|
|
|
|
{
|
2007-02-06 23:09:00 +01:00
|
|
|
char *pPolicy;
|
|
|
|
size_t policyLen;
|
2006-11-13 06:20:43 +01:00
|
|
|
|
|
|
|
} GetAuthPolicyResp, *PGetAuthPolicyResp;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get Authentication Token Response structure
|
|
|
|
//
|
|
|
|
typedef struct _GetAuthTokenResp
|
|
|
|
{
|
2007-02-06 23:09:00 +01:00
|
|
|
char *pToken;
|
|
|
|
size_t tokenLen;
|
|
|
|
int tokenLifetime;
|
2006-11-13 06:20:43 +01:00
|
|
|
|
|
|
|
} GetAuthTokenResp, *PGetAuthTokenResp;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Authenticate Response structure
|
|
|
|
//
|
|
|
|
typedef struct _AuthenticateResp
|
|
|
|
{
|
2007-02-06 23:09:00 +01:00
|
|
|
char *pToken;
|
|
|
|
size_t tokenLen;
|
|
|
|
int tokenLifetime;
|
2006-11-13 06:20:43 +01:00
|
|
|
|
|
|
|
} AuthenticateResp, *PAuthenticateResp;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Auth Cache Entry definition
|
|
|
|
//
|
2007-01-04 14:27:31 +01:00
|
|
|
// IMPORTANT NOTE - If changes are made to this structure then you
|
|
|
|
// will need to deal with compatibility issues with cached tokens
|
|
|
|
// since the entries are stored binarily in the miCASA cache.
|
|
|
|
//
|
2006-11-13 06:20:43 +01:00
|
|
|
typedef struct _AuthCacheEntry
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
DWORD creationTime;
|
|
|
|
DWORD expirationTime;
|
|
|
|
bool doesNotExpire;
|
|
|
|
char token[1];
|
|
|
|
|
|
|
|
} AuthCacheEntry, *PAuthCacheEntry;
|
|
|
|
|
|
|
|
|
|
|
|
//===[ Inlines functions ]===============================================
|
|
|
|
|
|
|
|
//===[ Function prototypes ]===============================================
|
|
|
|
|
|
|
|
//===[ Global variables ]==================================================
|
|
|
|
|
|
|
|
//===[ Global externals ]==================================================
|
|
|
|
|
|
|
|
extern int DebugLevel;
|
2007-03-05 07:48:26 +01:00
|
|
|
extern char *g_pDebugLogFilePath;
|
2006-11-13 06:20:43 +01:00
|
|
|
|
2007-03-05 07:48:26 +01:00
|
|
|
extern char clientConfigFolder[];
|
2006-11-13 06:20:43 +01:00
|
|
|
|
2007-03-05 07:48:26 +01:00
|
|
|
extern char mechConfigFolder[];
|
2006-11-13 06:20:43 +01:00
|
|
|
|
2007-03-05 07:48:26 +01:00
|
|
|
extern char pathCharString[];
|
2006-11-13 06:20:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
//===[ External prototypes ]===============================================
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions exported by engine.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
ObtainAuthTokenInt(
|
|
|
|
IN const char *pServiceName,
|
|
|
|
IN const char *pHostName,
|
2007-04-03 00:16:07 +02:00
|
|
|
IN const void *pCredStoreScope,
|
2006-11-13 06:20:43 +01:00
|
|
|
INOUT char *pAuthTokenBuf,
|
2007-04-03 00:16:07 +02:00
|
|
|
INOUT int *pAuthTokenBufLen);
|
2006-11-13 06:20:43 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Functions exported by authmech.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
GetAuthMechToken(
|
|
|
|
IN AuthContext *pAuthContext,
|
|
|
|
IN const char *pHostName,
|
|
|
|
IN void *pCredStoreScope,
|
|
|
|
INOUT char **ppAuthMechToken);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions exported by getpolicymsg.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
char*
|
|
|
|
BuildGetAuthPolicyMsg(
|
|
|
|
IN const char *pServiceName,
|
|
|
|
IN const char *pHostName);
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
CreateGetAuthPolicyResp(
|
|
|
|
IN char *pRespMsg,
|
2007-02-06 23:09:00 +01:00
|
|
|
IN size_t respLen,
|
2006-11-13 06:20:43 +01:00
|
|
|
INOUT GetAuthPolicyResp **ppGetAuthPolicyResp);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
RelGetAuthPolicyResp(
|
|
|
|
IN GetAuthPolicyResp *pGetAuthPolicyResp);
|
|
|
|
|
2007-02-03 00:02:43 +01:00
|
|
|
extern
|
|
|
|
int
|
|
|
|
InitializeLibrary(void);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
UnInitializeLibrary(void);
|
|
|
|
|
|
|
|
|
2006-11-13 06:20:43 +01:00
|
|
|
//
|
|
|
|
// Functions exported by authpolicy.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
CreateAuthPolicy(
|
|
|
|
IN char *pEncodedData,
|
2007-02-06 23:09:00 +01:00
|
|
|
IN size_t encodedDataLen,
|
2006-11-13 06:20:43 +01:00
|
|
|
INOUT AuthPolicy **ppAuthPolicy);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
RelAuthPolicy(
|
|
|
|
IN AuthPolicy *pAuthPolicy);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions exported by authmsg.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
char*
|
|
|
|
BuildAuthenticateMsg(
|
|
|
|
IN AuthContext *pAuthContext,
|
|
|
|
IN char *pAuthMechToken);
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
CreateAuthenticateResp(
|
|
|
|
IN char *pRespMsg,
|
2007-02-03 00:02:43 +01:00
|
|
|
IN size_t respLen,
|
2006-11-13 06:20:43 +01:00
|
|
|
INOUT AuthenticateResp **ppAuthenticateResp);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
RelAuthenticateResp(
|
|
|
|
IN AuthenticateResp *pAuthenticateResp);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions exported by gettokenmsg.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
char*
|
|
|
|
BuildGetAuthTokenMsg(
|
|
|
|
IN const char *pServiceName,
|
|
|
|
IN const char *pHostName,
|
|
|
|
IN char *pSessionToken);
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
CreateGetAuthTokenResp(
|
|
|
|
IN char *pRespMsg,
|
2007-02-06 23:09:00 +01:00
|
|
|
IN size_t respLen,
|
2006-11-13 06:20:43 +01:00
|
|
|
INOUT GetAuthTokenResp **ppGetAuthTokenResp);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
RelGetAuthTokenResp(
|
|
|
|
IN GetAuthTokenResp *pGetAuthTokenResp);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions exported by cache.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
AuthCacheEntry*
|
|
|
|
CreateSessionTokenCacheEntry(
|
|
|
|
IN const char *pCacheKey,
|
|
|
|
IN CasaStatus status,
|
|
|
|
IN char *pToken,
|
|
|
|
IN int entryLifetime,
|
|
|
|
IN void *pCredStoreScope);
|
|
|
|
|
|
|
|
extern
|
|
|
|
AuthCacheEntry*
|
|
|
|
CreateAuthTokenCacheEntry(
|
|
|
|
IN const char *pCacheKey,
|
|
|
|
IN const char *pHostName,
|
2007-05-30 00:59:50 +02:00
|
|
|
IN const ATSHostEntry *pATSHost,
|
2006-11-13 06:20:43 +01:00
|
|
|
IN CasaStatus status,
|
|
|
|
IN char *pToken,
|
|
|
|
IN int entryLifetime,
|
|
|
|
IN void *pCredStoreScope);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
FreeAuthCacheEntry(
|
|
|
|
IN AuthCacheEntry *pEntry);
|
|
|
|
|
|
|
|
extern
|
|
|
|
AuthCacheEntry*
|
|
|
|
FindSessionTokenEntryInCache(
|
|
|
|
IN const char *pCacheKey,
|
|
|
|
IN void *pCredStoreScope);
|
|
|
|
|
|
|
|
extern
|
|
|
|
AuthCacheEntry*
|
|
|
|
FindAuthTokenEntryInCache(
|
|
|
|
IN const char *pCacheKey,
|
|
|
|
IN const char *pGroupOrHostName,
|
2007-05-30 00:59:50 +02:00
|
|
|
IN const ATSHostEntry *pATSHost,
|
2006-11-13 06:20:43 +01:00
|
|
|
IN void *pCredStoreScope);
|
|
|
|
|
2007-01-29 11:46:18 +01:00
|
|
|
extern
|
|
|
|
void
|
|
|
|
RemoveSessionTokenEntryInCache(
|
|
|
|
IN const char *pCacheKey,
|
|
|
|
IN void *pCredStoreScope);
|
|
|
|
|
2007-04-13 21:21:40 +02:00
|
|
|
extern
|
|
|
|
void
|
|
|
|
DeleteAuthTokenEntriesInCache(
|
|
|
|
IN void *pCredStoreScope);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
DeleteSessionTokenEntriesInCache(
|
|
|
|
IN void *pCredStoreScope);
|
|
|
|
|
2006-11-13 06:20:43 +01:00
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
InitializeAuthCache(void);
|
|
|
|
|
2007-01-29 14:04:22 +01:00
|
|
|
extern
|
|
|
|
void
|
|
|
|
UnInitializeAuthCache(void);
|
|
|
|
|
|
|
|
|
2006-11-13 06:20:43 +01:00
|
|
|
//
|
|
|
|
// Functions exported by config.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
GetConfigInterface(
|
|
|
|
IN const char *pConfigFolder,
|
|
|
|
IN const char *pConfigName,
|
|
|
|
INOUT ConfigIf **ppConfigIf);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions exported by platform.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
CreateUserMutex(
|
|
|
|
HANDLE *phMutex
|
|
|
|
);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
AcquireUserMutex(
|
|
|
|
HANDLE hMutex
|
|
|
|
);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
ReleaseUserMutex(
|
|
|
|
HANDLE hMutex
|
|
|
|
);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
DestroyUserMutex(
|
|
|
|
HANDLE hMutex
|
|
|
|
);
|
|
|
|
|
|
|
|
extern
|
|
|
|
LIB_HANDLE
|
|
|
|
OpenLibrary(
|
|
|
|
IN char *pFileName);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
CloseLibrary(
|
|
|
|
IN LIB_HANDLE libHandle);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void*
|
|
|
|
GetFunctionPtr(
|
|
|
|
IN LIB_HANDLE libHandle,
|
|
|
|
IN char *pFunctionName);
|
|
|
|
|
|
|
|
extern
|
|
|
|
char*
|
|
|
|
NormalizeHostName(
|
|
|
|
IN const char *pHostName);
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
InitializeHostNameNormalization(void);
|
|
|
|
|
2007-01-29 11:46:18 +01:00
|
|
|
extern
|
|
|
|
void
|
|
|
|
UnInitializeHostNameNormalization(void);
|
|
|
|
|
2006-11-13 06:20:43 +01:00
|
|
|
//
|
|
|
|
// Functions exported by rpc.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
RpcSession*
|
|
|
|
OpenRpcSession(
|
|
|
|
IN const char *pHostName,
|
|
|
|
IN const uint16_t hostPort);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
CloseRpcSession(
|
|
|
|
IN RpcSession *pSession);
|
|
|
|
|
|
|
|
#define SECURE_RPC_FLAG 1
|
|
|
|
#define ALLOW_INVALID_CERTS_RPC_FLAG 2
|
|
|
|
#define ALLOW_INVALID_CERTS_USER_APPROVAL_RPC_FLAG 4
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
Rpc(
|
|
|
|
IN RpcSession *pSession,
|
|
|
|
IN char *pMethod,
|
|
|
|
IN long flags,
|
|
|
|
IN char *pRequestData,
|
|
|
|
INOUT char **ppResponseData,
|
2007-02-03 00:02:43 +01:00
|
|
|
INOUT size_t *pResponseDataLen);
|
2006-11-13 06:20:43 +01:00
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
InitializeRpc(void);
|
|
|
|
|
2007-01-29 11:46:18 +01:00
|
|
|
extern
|
|
|
|
void
|
|
|
|
UnInitializeRpc(void);
|
|
|
|
|
|
|
|
|
2006-11-13 06:20:43 +01:00
|
|
|
//
|
|
|
|
// Functions exported by utils.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
EncodeData(
|
|
|
|
IN const void *pData,
|
2007-02-06 23:09:00 +01:00
|
|
|
IN const uint32_t dataLen,
|
2006-11-13 06:20:43 +01:00
|
|
|
INOUT char **ppEncodedData,
|
2007-02-06 23:09:00 +01:00
|
|
|
INOUT uint32_t *pEncodedDataLen);
|
2006-11-13 06:20:43 +01:00
|
|
|
|
|
|
|
extern
|
|
|
|
CasaStatus
|
|
|
|
DecodeData(
|
|
|
|
IN const char *pEncodedData,
|
2007-02-06 23:09:00 +01:00
|
|
|
IN const uint32_t encodedDataLen, // Does not include NULL terminator
|
2006-11-13 06:20:43 +01:00
|
|
|
INOUT void **ppData,
|
2007-02-06 23:09:00 +01:00
|
|
|
INOUT uint32_t *pDataLen);
|
2006-11-13 06:20:43 +01:00
|
|
|
|
|
|
|
extern
|
|
|
|
int
|
|
|
|
dtoul(
|
|
|
|
IN const char *cp,
|
|
|
|
IN const int len);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions exported by invalidcert.c
|
|
|
|
//
|
|
|
|
|
|
|
|
extern
|
|
|
|
bool
|
|
|
|
InvalidCertsFromHostAllowed(
|
|
|
|
IN char *pHostName);
|
|
|
|
|
|
|
|
extern
|
|
|
|
void
|
|
|
|
AllowInvalidCertsFromHost(
|
|
|
|
IN char *pHostName);
|
|
|
|
|
|
|
|
#define INVALID_CERT_CA_FLAG 1
|
|
|
|
#define INVALID_CERT_CN_FLAG 2
|
|
|
|
#define INVALID_CERT_DATE_FLAG 4
|
|
|
|
|
|
|
|
extern
|
|
|
|
bool
|
|
|
|
UserApprovedCert(
|
|
|
|
IN char *pHostName,
|
|
|
|
IN char *pCertSubject,
|
|
|
|
IN char *pCertIssuer,
|
|
|
|
IN long invalidCertFlags);
|
|
|
|
|
|
|
|
|
|
|
|
//=========================================================================
|
|
|
|
|
|
|
|
#endif // _INTERNAL_H_
|
|
|
|
|