diff --git a/CASA-auth-token/client/csharp-api/Novell.Casa.Authtoken/Authtoken.cs b/CASA-auth-token/client/csharp-api/Novell.Casa.Authtoken/Authtoken.cs
index 4f75ab69..2f05a0ee 100644
--- a/CASA-auth-token/client/csharp-api/Novell.Casa.Authtoken/Authtoken.cs
+++ b/CASA-auth-token/client/csharp-api/Novell.Casa.Authtoken/Authtoken.cs
@@ -70,6 +70,12 @@ namespace Novell.Casa.Client.Auth
[In] SSCS_EXT_T ext
);
+ [DllImport(AUTH_LIBRARY, CharSet = CharSet.None)]
+ private static extern int CleanUpAuthTokenCacheEx
+ (
+ [In] SSCS_EXT_T ext
+ );
+
public Authtoken()
{
@@ -94,7 +100,7 @@ namespace Novell.Casa.Client.Auth
return ObtainAuthToken(sService, sHost, null);
}
- private static byte[] ObtainAuthToken(string sService, string sHost, WinLuid luid)
+ public static byte[] ObtainAuthToken(string sService, string sHost, WinLuid luid)
{
int rcode = 0;
byte[] baService = null;
@@ -189,6 +195,54 @@ namespace Novell.Casa.Client.Auth
}
}
+ public static void CleanUpAuthTokenCache(WinLuid luid)
+ {
+ SSCS_EXT_T ext = new SSCS_EXT_T();
+ LUID sluid;
+ bool bLuidPassedIn = false;
+
+ if ((luid != null) &&
+ ((luid.GetHighPart() != 0) || (luid.GetLowPart() != 0)))
+ {
+ // allocate a structure to marshal
+ sluid = new LUID();
+ sluid.luidHigh = luid.GetHighPart();
+ sluid.luidLow = luid.GetLowPart();
+
+ ext.extID = 1;
+ ext.version = 1;
+ ext.ext = Marshal.AllocHGlobal(Marshal.SizeOf(sluid));
+
+ Marshal.StructureToPtr(sluid, ext.ext, false);
+ bLuidPassedIn = true;
+ }
+
+ // Do the call
+ try
+ {
+ if (bLuidPassedIn)
+ {
+ CleanUpAuthTokenCacheEx(ext);
+ }
+ else
+ {
+ CleanUpAuthTokenCacheEx(null);
+ }
+ }
+ catch (Exception e)
+ {
+ LogMessage(e.ToString());
+ }
+
+ if (ext.ext != IntPtr.Zero)
+ Marshal.FreeHGlobal(ext.ext);
+ }
+
+ public static void CleanUpAuthTokenCache()
+ {
+ CleanUpAuthTokenCache(null);
+ }
+
private static void LogMessage(string sMessage)
{
System.Diagnostics.Trace.WriteLine("(C#)AuthToken: " + sMessage);
diff --git a/CASA-auth-token/client/csharp-api/test/Class1.cs b/CASA-auth-token/client/csharp-api/test/Class1.cs
index 313e455b..892be930 100644
--- a/CASA-auth-token/client/csharp-api/test/Class1.cs
+++ b/CASA-auth-token/client/csharp-api/test/Class1.cs
@@ -49,8 +49,8 @@ namespace TestClientAuth
try
{
- WinLuid luid = new WinLuid(1234, 5678);
- Authtoken.ObtainAuthToken("testService", args[0], luid);
+ //WinLuid luid = new WinLuid(1234, 5678);
+ Authtoken.ObtainAuthToken("testService", args[0]);
byte[] baToken = Authtoken.ObtainAuthToken("testService", args[0]);
Console.WriteLine("Token returned: ("+ baToken.Length + ")");
@@ -61,6 +61,11 @@ namespace TestClientAuth
Console.WriteLine("");
Console.WriteLine("Press enter to continue");
Console.ReadLine();
+
+ // Cleanup the AuthTokenCache
+ Console.WriteLine("Cleaning the cache");
+ Authtoken.CleanUpAuthTokenCache();
+ Console.WriteLine("Done cleaning the cache");
}
catch (Exception e)
{
diff --git a/CASA-auth-token/client/csharp-api/test/TestClientAuth.csproj b/CASA-auth-token/client/csharp-api/test/TestClientAuth.csproj
index 61097399..a0bbb48f 100644
--- a/CASA-auth-token/client/csharp-api/test/TestClientAuth.csproj
+++ b/CASA-auth-token/client/csharp-api/test/TestClientAuth.csproj
@@ -1,109 +1,106 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ Local
+ 8.0.50727
+ 2.0
+ {0EA635EA-97F2-4950-B36B-8151ED858DA4}
+ Debug
+ AnyCPU
+ App.ico
+
+
+ TestClientAuth
+
+
+ JScript
+ Grid
+ IE50
+ false
+ Exe
+ TestClientAuth
+ OnBuildSuccess
+
+
+
+
+
+
+
+
+ bin\Debug\
+ false
+ 285212672
+ false
+
+
+ DEBUG;TRACE
+
+
+ true
+ 4096
+ false
+
+
+ false
+ false
+ false
+ false
+ 4
+ full
+ prompt
+
+
+ bin\Release\
+ false
+ 285212672
+ false
+
+
+ TRACE
+
+
+ false
+ 4096
+ false
+
+
+ true
+ false
+ false
+ false
+ 4
+ none
+ prompt
+
+
+
+ False
+ ..\Novell.Casa.Authtoken\bin\Debug\Novell.Casa.Client.Auth.dll
+
+
+ System
+
+
+ System.Data
+
+
+ System.XML
+
+
+
+
+
+ Code
+
+
+ Code
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CASA-auth-token/client/include/casa_c_authtoken.h b/CASA-auth-token/client/include/casa_c_authtoken.h
index 4dd91ad3..10a8a585 100644
--- a/CASA-auth-token/client/include/casa_c_authtoken.h
+++ b/CASA-auth-token/client/include/casa_c_authtoken.h
@@ -94,6 +94,20 @@ ObtainAuthToken(
//=======================================================================--
+//++=======================================================================
+extern void SSCS_CALL
+CleanUpAuthTokenCache(void);
+//
+// Arguments: None.
+//
+// Returns:
+// Nothing
+//
+// Description:
+// Flush the AuthToken cache.
+//=======================================================================--
+
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif // #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/CASA-auth-token/client/include/windows/casa_c_authtoken_ex.h b/CASA-auth-token/client/include/windows/casa_c_authtoken_ex.h
index 76960715..7c8990b5 100644
--- a/CASA-auth-token/client/include/windows/casa_c_authtoken_ex.h
+++ b/CASA-auth-token/client/include/windows/casa_c_authtoken_ex.h
@@ -51,7 +51,7 @@ extern "C"
//++=======================================================================
-CasaStatus SSCS_CALL
+extern CasaStatus SSCS_CALL
ObtainAuthTokenEx(
IN const char *pServiceName,
IN const char *pHostName,
@@ -101,6 +101,25 @@ ObtainAuthTokenEx(
//=======================================================================--
+//++=======================================================================
+extern 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.
+//=======================================================================--
+
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif // #if defined(__cplusplus) || defined(c_plusplus)
diff --git a/CASA-auth-token/client/library/cache.c b/CASA-auth-token/client/library/cache.c
index 2d3b280a..80557554 100644
--- a/CASA-auth-token/client/library/cache.c
+++ b/CASA-auth-token/client/library/cache.c
@@ -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()
diff --git a/CASA-auth-token/client/library/engine.c b/CASA-auth-token/client/library/engine.c
index ccc46eff..58aa37ac 100644
--- a/CASA-auth-token/client/library/engine.c
+++ b/CASA-auth-token/client/library/engine.c
@@ -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)
diff --git a/CASA-auth-token/client/library/internal.h b/CASA-auth-token/client/library/internal.h
index a019c925..25040527 100644
--- a/CASA-auth-token/client/library/internal.h
+++ b/CASA-auth-token/client/library/internal.h
@@ -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);
diff --git a/CASA-auth-token/client/library/test/windows/main.cpp b/CASA-auth-token/client/library/test/windows/main.cpp
index 65ab2b6c..edd5b592 100644
--- a/CASA-auth-token/client/library/test/windows/main.cpp
+++ b/CASA-auth-token/client/library/test/windows/main.cpp
@@ -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();
}
diff --git a/CASA-auth-token/client/library/windows/authtoken.def b/CASA-auth-token/client/library/windows/authtoken.def
index d0c062b8..6263acdd 100644
--- a/CASA-auth-token/client/library/windows/authtoken.def
+++ b/CASA-auth-token/client/library/windows/authtoken.def
@@ -8,4 +8,6 @@ EXPORTS
; DllGetClassObject PRIVATE
ObtainAuthToken PRIVATE
ObtainAuthTokenEx PRIVATE
+ CleanUpAuthTokenCache PRIVATE
+ CleanUpAuthTokenCacheEx PRIVATE
; DllCanUnloadNow PRIVATE
\ No newline at end of file
diff --git a/CASA-auth-token/client/library/windows/client.vcproj b/CASA-auth-token/client/library/windows/client.vcproj
index 7fa7bbeb..6a4f446b 100644
--- a/CASA-auth-token/client/library/windows/client.vcproj
+++ b/CASA-auth-token/client/library/windows/client.vcproj
@@ -68,7 +68,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-