Added flush AuthToken cache API.

This commit is contained in:
Juan Carlos Luciani
2007-04-13 19:21:40 +00:00
parent 2342ee4dd0
commit 099e4cabfc
12 changed files with 497 additions and 198 deletions

View File

@@ -709,6 +709,78 @@ RemoveSessionTokenEntryInCache(
}
//++=======================================================================
void
DeleteAuthTokenEntriesInCache(
IN void *pCredStoreScope
)
//
// Arguments:
//
// Returns:
//
// Abstract:
//
// Notes:
//
// L2
//=======================================================================--
{
int32_t miCasaStatus;
SSCS_SECRET_ID_T sharedId = {27, "CASA_AUTHENTICATION_TOKENS"};
DbgTrace(1, "-DeleteAuthTokenEntriesInCache- Start\n", 0);
// Remove all of the auth tokens from the cache
miCasaStatus = miCASARemoveCredential(0,
&sharedId,
(SSCS_SECRET_ID_T*) NULL,
(SSCS_EXT_T*) pCredStoreScope);
if (miCasaStatus != NSSCS_SUCCESS)
{
DbgTrace(0, "-DeleteAuthTokenEntriesInCache- miCASADeleteCredential error = %0X\n", miCasaStatus);
}
DbgTrace(1, "-DeleteAuthTokenEntriesInCache- End\n", 0);
}
//++=======================================================================
void
DeleteSessionTokenEntriesInCache(
IN void *pCredStoreScope
)
//
// Arguments:
//
// Returns:
//
// Abstract:
//
// Notes:
//
// L2
//=======================================================================--
{
int32_t miCasaStatus;
SSCS_SECRET_ID_T sharedId = {20, "CASA_SESSION_TOKENS"};
DbgTrace(1, "-DeleteSessionTokenEntriesInCache- Start\n", 0);
// Remove all of the auth tokens from the cache
miCasaStatus = miCASARemoveCredential(0,
&sharedId,
(SSCS_SECRET_ID_T*) NULL,
(SSCS_EXT_T*) pCredStoreScope);
if (miCasaStatus != NSSCS_SUCCESS)
{
DbgTrace(0, "-DeleteSessionTokenEntriesInCache- miCASADeleteCredential error = %0X\n", miCasaStatus);
}
DbgTrace(1, "-DeleteSessionTokenEntriesInCache- End\n", 0);
}
//++=======================================================================
CasaStatus
InitializeAuthCache()

View File

@@ -833,6 +833,101 @@ ObtainAuthToken(
}
//++=======================================================================
void
CleanUpAuthTokenCacheInt(
IN const void *pCredStoreScope)
//
// Arguments:
// pCredStoreScope -
// Pointer to CASA structure for scoping credential store access
// to specific users. This can only be leveraged by applications
// running in the context of System.
//
// Returns:
// Nothing
//
// Description:
// Flush the AuthToken cache.
//=======================================================================--
{
CasaStatus retStatus;
HANDLE hUserMutex = NULL;
DbgTrace(1, "-CleanUpAuthTokenCacheInt- Start\n", 0);
// Obtain our synchronization mutex
AcquireModuleMutex;
// Create user synchronization mutex
retStatus = CreateUserMutex(&hUserMutex);
if (retStatus != CASA_STATUS_SUCCESS)
{
DbgTrace(0, "-CleanUpAuthTokenCacheInt- Error creating mutex for the user\n", 0);
goto exit;
}
// Make sure we are fully initialized
if (g_bInitialized == false)
{
retStatus = InitializeLibrary();
if (retStatus == CASA_STATUS_SUCCESS)
{
g_bInitialized = true;
}
else
{
goto exit;
}
}
// Release our synchronization mutex
ReleaseModuleMutex;
// Start user process synchronization
AcquireUserMutex(hUserMutex);
// Delete all of the tokens in our cache
DeleteAuthTokenEntriesInCache(pCredStoreScope);
DeleteSessionTokenEntriesInCache(pCredStoreScope);
// Stop user process synchronization
ReleaseUserMutex(hUserMutex);
exit:
if (hUserMutex != NULL)
{
DestroyUserMutex(hUserMutex);
}
DbgTrace(1, "-CleanUpAuthTokenCacheInt- End\n", 0);
}
//++=======================================================================
void SSCS_CALL
CleanUpAuthTokenCache(void)
//
// Arguments: None.
//
// Returns:
// Nothing
//
// Description:
// Flush the AuthToken cache.
//=======================================================================--
{
DbgTrace(1, "-CleanUpAuthTokenCache- Start\n", 0);
// Call our internal worker
CleanUpAuthTokenCacheInt(NULL);
DbgTrace(1, "-CleanUpAuthTokenCache- End\n", 0);
}
//++=======================================================================
int
InitializeLibrary(void)

View File

@@ -299,6 +299,16 @@ RemoveSessionTokenEntryInCache(
IN const char *pCacheKey,
IN void *pCredStoreScope);
extern
void
DeleteAuthTokenEntriesInCache(
IN void *pCredStoreScope);
extern
void
DeleteSessionTokenEntriesInCache(
IN void *pCredStoreScope);
extern
CasaStatus
InitializeAuthCache(void);

View File

@@ -167,6 +167,10 @@ int main(int argc, char* argv[])
printf("Press 'Enter' to run test or 'n + Enter' to stop.\n");
}
// Cleanup the AuthToken cache to start clean the next time that
// we run the test application.
CleanUpAuthTokenCache();
// Close winsock
WSACleanup();
}

View File

@@ -8,4 +8,6 @@ EXPORTS
; DllGetClassObject PRIVATE
ObtainAuthToken PRIVATE
ObtainAuthTokenEx PRIVATE
CleanUpAuthTokenCache PRIVATE
CleanUpAuthTokenCacheEx PRIVATE
; DllCanUnloadNow PRIVATE

View File

@@ -68,7 +68,7 @@
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="false"
AdditionalOptions="/EXPORT:ObtainAuthToken /EXPORT:ObtainAuthTokenEx"
AdditionalOptions="/EXPORT:ObtainAuthToken /EXPORT:ObtainAuthTokenEx /EXPORT:CleanUpAuthTokenCache /EXPORT:CleanUpAuthTokenCacheEx"
AdditionalDependencies="ws2_32.lib winhttp.lib libexpatmt.lib micasa.lib shlwapi.lib"
OutputFile="$(OutDir)/casa_authtoken.dll"
LinkIncremental="1"
@@ -107,6 +107,90 @@
CommandLine=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="..\windows\$(ConfigurationName)"
IntermediateDirectory="..\windows\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D &quot;XML_STATIC&quot; /D &quot;_CRT_SECURE_NO_DEPRECATE&quot;"
AdditionalIncludeDirectories=".;..\;..\..\include;..\..\include\windows;&quot;$(MS_SDK_DIR)\include&quot;;&quot;$(CASA32_SDK_DIR)\include&quot;;&quot;..\..\..\..\..\Expat-2.0.0\Source\lib&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/EXPORT:ObtainAuthToken /EXPORT:ObtainAuthTokenEx /EXPORT:CleanUpAuthTokenCache /EXPORT:CleanUpAuthTokenCacheEx"
AdditionalDependencies="ws2_32.lib winhttp.lib libexpatmt.lib micasa.lib shlwapi.lib"
OutputFile="$(OutDir)/casa_authtoken.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(MS_SDK_DIR)\lib&quot;;&quot;$(CASA32_SDK_DIR)\lib&quot;;&quot;..\..\..\..\..\Expat-2.0.0\StaticLibs&quot;"
IgnoreDefaultLibraryNames="libc"
GenerateDebugInformation="true"
SubSystem="0"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(SolutionDir)lib\windows\$(TargetName).lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine=""
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
@@ -198,90 +282,6 @@
CommandLine=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="..\windows\$(ConfigurationName)"
IntermediateDirectory="..\windows\$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/D &quot;XML_STATIC&quot; /D &quot;_CRT_SECURE_NO_DEPRECATE&quot;"
AdditionalIncludeDirectories=".;..\;..\..\include;..\..\include\windows;&quot;$(MS_SDK_DIR)\include&quot;;&quot;$(CASA32_SDK_DIR)\include&quot;;&quot;..\..\..\..\..\Expat-2.0.0\Source\lib&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/EXPORT:ObtainAuthToken /EXPORT:ObtainAuthTokenEx"
AdditionalDependencies="ws2_32.lib winhttp.lib libexpatmt.lib micasa.lib shlwapi.lib"
OutputFile="$(OutDir)/casa_authtoken.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(MS_SDK_DIR)\lib&quot;;&quot;$(CASA32_SDK_DIR)\lib&quot;;&quot;..\..\..\..\..\Expat-2.0.0\StaticLibs&quot;"
IgnoreDefaultLibraryNames="libc"
GenerateDebugInformation="true"
SubSystem="0"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(SolutionDir)lib\windows\$(TargetName).lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine=""
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"

View File

@@ -122,6 +122,33 @@ ObtainAuthTokenEx(
}
//++=======================================================================
void SSCS_CALL
CleanUpAuthTokenCacheEx(
IN const void *pCredStoreScope)
//
// Arguments:
// pCredStoreScope -
// Pointer to CASA structure for scoping credential store access
// to specific users. This can only be leveraged by applications
// running in the context of System.
//
// Returns:
// Nothing
//
// Description:
// Flush the AuthToken cache.
//=======================================================================--
{
DbgTrace(1, "-CleanUpAuthTokenCacheEx- Start\n", 0);
// Call our internal worker
CleanUpAuthTokenCacheInt(pCredStoreScope);
DbgTrace(1, "-CleanUpAuthTokenCacheEx- End\n", 0);
}
//++=======================================================================
BOOL APIENTRY DllMain(
HANDLE hModule,