Added the capability of configuring the ATS Address, port, and whether or not SSL should be used for communications.

This commit is contained in:
Juan Carlos Luciani 2006-09-22 16:24:03 +00:00
parent 6e12d33817
commit 637726123c
7 changed files with 171 additions and 51 deletions

View File

@ -76,7 +76,6 @@ GetAuthTokenIf(
CasaStatus retStatus; CasaStatus retStatus;
ConfigIf *pModuleConfigIf; ConfigIf *pModuleConfigIf;
DbgTrace(2, "-GetAuthTokenIf- Start\n", 0); DbgTrace(2, "-GetAuthTokenIf- Start\n", 0);
// Get the configuration for the module // Get the configuration for the module
@ -268,7 +267,6 @@ GetAuthMechToken(
CASA_STATUS_UNSUCCESSFUL); CASA_STATUS_UNSUCCESSFUL);
AuthTokenIf *pAuthTokenIf; AuthTokenIf *pAuthTokenIf;
DbgTrace(1, "-GetAuthMechToken- Start\n", 0); DbgTrace(1, "-GetAuthMechToken- Start\n", 0);
// Initialize output parameter // Initialize output parameter

View File

@ -0,0 +1,48 @@
#######################################################
# #
# CASA Authentication Token System configuration file #
# for client. #
# #
#######################################################
#
# ATS-hostname setting.
#
# Description: Used to configure the address of the
# ATS that should be used for obtaining
# authentication tokens.
#
# If this parameter is not set, the client
# assummes that the ATS resides in the same
# host as the authentication token consuming
# services.
#
#ATS-hostname hostname or IP address
#
# ATS-port setting.
#
# Description: Used to configure the port utilized by the
# ATS to listen for connections.
#
# If this parameter is not set, the client
# assummes that the ATS is listening for
# connections on port 443 if configured to
# use SSL, otherwise it assumes that it is
# listening for connections on port 80.
#
ATS-port 8080
#
# UseSSL setting.
#
# Description: Used to specify that communications to the ATS
# should occur over SSL to ensure security.
#
# If this parameter is not set, the client
# defaults to using SSL when communicating with
# ATSs.
#
UseSSL false

View File

@ -43,8 +43,11 @@ int DebugLevel = 0;
// //
// Operating parameter // Operating parameter
// //
bool secureRpcSetting = false; bool g_bInitialized = FALSE;
bool g_bInitialized = FALSE; bool g_secureRpcSetting = true;
char *g_pATSHostName = NULL;
uint16_t g_ATSPort = 443; // Default HTTPS
//++======================================================================= //++=======================================================================
static static
@ -147,7 +150,7 @@ ObtainSessionToken(
// Issue rpc // Issue rpc
retStatus = Rpc(pRpcSession, retStatus = Rpc(pRpcSession,
"Authenticate", "Authenticate",
secureRpcSetting, g_secureRpcSetting,
pReqMsg, pReqMsg,
&pRespMsg, &pRespMsg,
&respLen); &respLen);
@ -276,7 +279,8 @@ ObtainAuthTokenFromServer(
*ppAuthToken = NULL; *ppAuthToken = NULL;
// Open Rpc Session to the auth service at the specified host // Open Rpc Session to the auth service at the specified host
pRpcSession = OpenRpcSession(pHostName); pRpcSession = OpenRpcSession((g_pATSHostName != NULL) ? g_pATSHostName : pHostName,
g_ATSPort);
if (pRpcSession) if (pRpcSession)
{ {
char *pReqMsg = NULL; char *pReqMsg = NULL;
@ -294,7 +298,7 @@ ObtainAuthTokenFromServer(
// Issue rpc // Issue rpc
retStatus = Rpc(pRpcSession, retStatus = Rpc(pRpcSession,
"GetAuthPolicy", "GetAuthPolicy",
secureRpcSetting, g_secureRpcSetting,
pReqMsg, pReqMsg,
&pRespMsg, &pRespMsg,
&respLen); &respLen);
@ -326,7 +330,7 @@ ObtainAuthTokenFromServer(
// Issue rpc // Issue rpc
retStatus = Rpc(pRpcSession, retStatus = Rpc(pRpcSession,
"GetAuthToken", "GetAuthToken",
secureRpcSetting, g_secureRpcSetting,
pReqMsg, pReqMsg,
&pRespMsg, &pRespMsg,
&respLen); &respLen);
@ -474,7 +478,6 @@ ObtainAuthToken(
unsigned char *pToken; unsigned char *pToken;
HANDLE hUserMutex = NULL; HANDLE hUserMutex = NULL;
DbgTrace(1, "-ObtainAuthToken- Start\n", 0); DbgTrace(1, "-ObtainAuthToken- Start\n", 0);
// Verify the input parameters // Verify the input parameters
@ -494,19 +497,18 @@ ObtainAuthToken(
DbgTrace(1, "-ObtainAuthToken- HostName = %s\n", pHostName); DbgTrace(1, "-ObtainAuthToken- HostName = %s\n", pHostName);
DbgTrace(1, "-ObtainAuthToken- BufferLength = %d\n", *pAuthTokenBufLen); DbgTrace(1, "-ObtainAuthToken- BufferLength = %d\n", *pAuthTokenBufLen);
// Make sure we are initialized
// Obtain our synchronization mutex // Obtain our synchronization mutex
AcquireInitializationMutex(); AcquireInitializationMutex();
// Create user synchronization mutex // Create user synchronization mutex
retStatus = CreateUserMutex(&hUserMutex); retStatus = CreateUserMutex(&hUserMutex);
if (retStatus != CASA_STATUS_SUCCESS) if (retStatus != CASA_STATUS_SUCCESS)
{ {
DbgTrace(0, "-ObtainAuthToken- Error creating mutex for the user\n", 0); DbgTrace(0, "-ObtainAuthToken- Error creating mutex for the user\n", 0);
goto exit; goto exit;
} }
// Make sure we are fully initialized
if (g_bInitialized == FALSE) if (g_bInitialized == FALSE)
{ {
retStatus = InitializeLibrary(); retStatus = InitializeLibrary();
@ -627,6 +629,96 @@ exit:
} }
//++=======================================================================
int
InitializeLibrary(void)
//
// Arguments:
//
// Returns:
//
// Abstract:
//
// Notes:
//
// L2
//=======================================================================--
{
int retStatus = -1;
int getConfigStatus = -1;
ConfigIf *pClientConfigIf;
char *pATSPortSetting;
char *pUseSSLSetting;
DbgTrace(1, "-InitializeLibrary- Start\n", 0);
// Try to obtain client configuration settings
getConfigStatus = GetConfigInterface(clientConfigFolder,
"client",
&pClientConfigIf);
if (CASA_SUCCESS(getConfigStatus)
&& CasaStatusCode(getConfigStatus) != CASA_STATUS_OBJECT_NOT_FOUND)
{
// Check if an ATS hostname has been configured
g_pATSHostName = pClientConfigIf->getEntryValue(pClientConfigIf, "ATS-hostname");
if (g_pATSHostName != NULL)
{
DbgTrace(0, "-InitializeLibrary- ATS hostname %s configured\n", g_pATSHostName);
}
// Check if the UseSSL setting has been configured
pUseSSLSetting = pClientConfigIf->getEntryValue(pClientConfigIf, "UseSSL");
if (pUseSSLSetting != NULL)
{
DbgTrace(0, "-InitializeLibrary- UseSSL setting %s configured\n", pUseSSLSetting);
// Set the g_secureRpcSetting variable based on the setting
if (stricmp(pUseSSLSetting, "false") == 0)
{
g_secureRpcSetting = false;
// Change the default ATS port to 80 from 443
g_ATSPort = 80;
}
else if (stricmp(pUseSSLSetting, "true") == 0)
{
g_secureRpcSetting = true;
}
// Free the buffer holding the UseSSL setting
free(pUseSSLSetting);
}
// Check if an ATS port number has been configured
pATSPortSetting = pClientConfigIf->getEntryValue(pClientConfigIf, "ATS-port");
if (pATSPortSetting != NULL)
{
DbgTrace(0, "-InitializeLibrary- ATS port number %s configured\n", pATSPortSetting);
// Convert the number to hex
g_ATSPort = (int) dtoul(pATSPortSetting, strlen(pATSPortSetting));
// Free the buffer holding the port number
free(pATSPortSetting);
}
// Release config interface instance
pClientConfigIf->releaseReference(pClientConfigIf);
}
// Initialize the host name normalization
retStatus = InitializeHostNameNormalization();
if (CASA_SUCCESS(retStatus))
{
retStatus = InitializeAuthCache();
}
DbgTrace(1, "-InitializeLibrary- End, retStatus = %08X\n", retStatus);
return retStatus;
}
//++======================================================================= //++=======================================================================
int int
Initialize(void) Initialize(void)
@ -654,37 +746,6 @@ Initialize(void)
} }
//++=======================================================================
int
InitializeLibrary(void)
//
// Arguments:
//
// Returns:
//
// Abstract:
//
// Notes:
//
// L2
//=======================================================================--
{
int retStatus = -1;
DbgTrace(1, "-InitializeLibrary- Start\n", 0);
// Initialize the host name normalization
retStatus = InitializeHostNameNormalization();
if (CASA_SUCCESS(retStatus))
{
retStatus = InitializeAuthCache();
}
DbgTrace(1, "-InitializeLibrary- End, retStatus = %08X\n", retStatus);
return retStatus;
}
//++======================================================================= //++=======================================================================
//++======================================================================= //++=======================================================================
//++======================================================================= //++=======================================================================

View File

@ -106,6 +106,8 @@ typedef struct _AuthenticateResp
extern int DebugLevel; extern int DebugLevel;
extern char clientConfigFolder[];
extern char mechConfigFolder[]; extern char mechConfigFolder[];
extern char pathCharString[]; extern char pathCharString[];
@ -345,7 +347,8 @@ InitializeHostNameNormalization(void);
extern extern
RpcSession* RpcSession*
OpenRpcSession( OpenRpcSession(
IN char *pHostName); IN char *pHostName,
IN uint16_t hostPort);
extern extern
void void

View File

@ -29,6 +29,9 @@
#include <shlwapi.h> #include <shlwapi.h>
//===[ External data ]===================================================== //===[ External data ]=====================================================
extern
char clientConfigFolderPartialPath[];
extern extern
char mechConfigFolderPartialPath[]; char mechConfigFolderPartialPath[];
@ -54,6 +57,7 @@ BOOL APIENTRY DllMain(
//=======================================================================-- //=======================================================================--
{ {
BOOL retStatus = TRUE; BOOL retStatus = TRUE;
char programFilesFolder[MAX_PATH];
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@ -61,13 +65,17 @@ BOOL APIENTRY DllMain(
{ {
g_hModule = hModule; g_hModule = hModule;
// Setup the path to the auth mechanisms config folder // Setup the path to the client and auth mechanisms config folders
if (SHGetFolderPath(NULL, if (SHGetFolderPath(NULL,
CSIDL_PROGRAM_FILES, CSIDL_PROGRAM_FILES,
NULL, NULL,
0, 0,
mechConfigFolder) == 0) programFilesFolder) == 0)
{ {
strcpy(clientConfigFolder, programFilesFolder);
PathAppend(clientConfigFolder, clientConfigFolderPartialPath);
strcpy(mechConfigFolder, programFilesFolder);
PathAppend(mechConfigFolder, mechConfigFolderPartialPath); PathAppend(mechConfigFolder, mechConfigFolderPartialPath);
// Initialize the library // Initialize the library

View File

@ -53,6 +53,10 @@ LIST_ENTRY normalizedHostNameCacheListHead;
static static
HANDLE hNormalizedHostNameCacheMutex; HANDLE hNormalizedHostNameCacheMutex;
// Client configuration file folder
char clientConfigFolder[MAX_PATH];
char clientConfigFolderPartialPath[] = "Novell\\Casa\\Etc\\Auth";
// Authentication mechanism configuration file folder // Authentication mechanism configuration file folder
char mechConfigFolder[MAX_PATH]; char mechConfigFolder[MAX_PATH];
char mechConfigFolderPartialPath[] = "Novell\\Casa\\Etc\\Auth\\Mechanisms"; char mechConfigFolderPartialPath[] = "Novell\\Casa\\Etc\\Auth\\Mechanisms";

View File

@ -38,7 +38,6 @@
//===[ Global variables ]================================================== //===[ Global variables ]==================================================
//++======================================================================= //++=======================================================================
static static
CasaStatus CasaStatus
@ -62,7 +61,6 @@ CopyMultiToWideAlloc(
int retStatus; int retStatus;
int size, i; int size, i;
DbgTrace(2, "-CopyMultiToWideAlloc- Start\n", 0); DbgTrace(2, "-CopyMultiToWideAlloc- Start\n", 0);
size = (multiSize + 1) * sizeof(WCHAR); size = (multiSize + 1) * sizeof(WCHAR);
@ -99,7 +97,8 @@ CopyMultiToWideAlloc(
//++======================================================================= //++=======================================================================
RpcSession* RpcSession*
OpenRpcSession( OpenRpcSession(
IN char *pHostName) IN char *pHostName,
IN uint16_t hostPort)
// //
// Arguments: // Arguments:
// //
@ -114,7 +113,6 @@ OpenRpcSession(
{ {
RpcSession *pSession; RpcSession *pSession;
DbgTrace(1, "-OpenRpcSession- Start\n", 0); DbgTrace(1, "-OpenRpcSession- Start\n", 0);
// Allocate space for the session // Allocate space for the session
@ -145,7 +143,7 @@ OpenRpcSession(
// Now open connection // Now open connection
pSession->hConnection = WinHttpConnect(pSession->hSession, pSession->hConnection = WinHttpConnect(pSession->hSession,
pWideHostName, pWideHostName,
8080, /*INTERNET_DEFAULT_HTTP_PORT,*/ hostPort,
0); 0);
if (pSession->hConnection == NULL) if (pSession->hConnection == NULL)
{ {