From e1001dfc6fb67e0a6c65b670a367a186aa2e9ef8 Mon Sep 17 00:00:00 2001 From: Juan Carlos Luciani Date: Wed, 21 Mar 2007 22:19:05 +0000 Subject: [PATCH] Modified the Krb5 mechanisms to allow it to receive multiple settings via the authentication policy mechanism information string. This will allow to add new settings in the future without breaking existing clients. --- .../library/mechanisms/krb5/windows/get.c | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/CASA-auth-token/client/library/mechanisms/krb5/windows/get.c b/CASA-auth-token/client/library/mechanisms/krb5/windows/get.c index e8711cc1..378f1104 100644 --- a/CASA-auth-token/client/library/mechanisms/krb5/windows/get.c +++ b/CASA-auth-token/client/library/mechanisms/krb5/windows/get.c @@ -96,7 +96,7 @@ AuthTokenIf_GetAuthToken( //=======================================================================-- { CasaStatus retStatus; - char *pKrbServiceName = pMechInfo; + char *pKrbServiceName = NULL; SECURITY_STATUS secStatus; TimeStamp expiry; CredHandle hCredentials = {0}; @@ -118,6 +118,37 @@ AuthTokenIf_GetAuthToken( goto exit; } + // Process any mechanism information that may have been provided + if (pMechInfo) + { + // Mechanism information has been provided. Mechanism information + // consists of semicolon delimited settings. The settings are formated + // using the format settingName=settingvalue. No white space is allowed + // as part of the mechanism information. + char *pNextSettingToken; + char *pSettingValueToken = strtok_s(pMechInfo, ";", &pNextSettingToken); + while (pSettingValueToken != NULL) + { + char *pNextToken; + char *pSettingName = strtok_s(pSettingValueToken, "=", &pNextToken); + char *pSettingValue = strtok_s(NULL, "=", &pNextToken); + if (pSettingValue) + { + // Process the setting + if (strcmpi(pSettingName, "SVC_PRINCIPAL") == 0) + { + pKrbServiceName = pSettingValue; + } + } + else + { + printf("Bad setting\n"); + } + + pSettingValueToken = strtok_s(NULL, ";", &pNextSettingToken); + } + } + // Check if we need to construct the service name if (pKrbServiceName == NULL || strlen(pKrbServiceName) == 0)