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)