2008-11-17 18:29:00 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
2008-03-05 09:52:00 -05:00
|
|
|
//
|
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
//
|
2008-11-17 18:29:00 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
2008-03-05 09:52:00 -05:00
|
|
|
|
|
|
|
namespace Microsoft.Singularity.Security
|
|
|
|
{
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using Microsoft.Singularity.Channels;
|
|
|
|
using Microsoft.Singularity.Directory;
|
|
|
|
using Microsoft.Singularity.Security;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// This is a client-library proxy to the security service.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public class SecurityDiagnostics
|
|
|
|
{
|
|
|
|
private ChannelPool! pool;
|
|
|
|
|
|
|
|
public SecurityDiagnostics()
|
|
|
|
{
|
|
|
|
pool = new ChannelPool();
|
|
|
|
}
|
|
|
|
|
|
|
|
public string! GetStatistics()
|
|
|
|
{
|
|
|
|
string result = String.Empty;
|
|
|
|
SecurityDiagnosticsContract.Imp! imp = pool.Acquire();
|
2008-11-17 18:29:00 -05:00
|
|
|
try {
|
2008-03-05 09:52:00 -05:00
|
|
|
imp.SendGetStatistics();
|
2008-11-17 18:29:00 -05:00
|
|
|
switch receive {
|
2008-03-05 09:52:00 -05:00
|
|
|
case imp.GetStatisticsAck(stats):
|
|
|
|
result = Bitter.ToString2(stats);
|
|
|
|
delete stats;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-11-17 18:29:00 -05:00
|
|
|
finally {
|
2008-03-05 09:52:00 -05:00
|
|
|
pool.Release(imp);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ClearStatistics()
|
|
|
|
{
|
|
|
|
SecurityDiagnosticsContract.Imp! imp = pool.Acquire();
|
2008-11-17 18:29:00 -05:00
|
|
|
try {
|
2008-03-05 09:52:00 -05:00
|
|
|
imp.SendClearStatistics();
|
2008-11-17 18:29:00 -05:00
|
|
|
switch receive {
|
2008-03-05 09:52:00 -05:00
|
|
|
case imp.Ack():
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-11-17 18:29:00 -05:00
|
|
|
finally {
|
2008-03-05 09:52:00 -05:00
|
|
|
pool.Release(imp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Disable(bool yes)
|
|
|
|
{
|
|
|
|
SecurityDiagnosticsContract.Imp! imp = pool.Acquire();
|
2008-11-17 18:29:00 -05:00
|
|
|
try {
|
2008-03-05 09:52:00 -05:00
|
|
|
imp.SendDisable(yes);
|
2008-11-17 18:29:00 -05:00
|
|
|
switch receive {
|
2008-03-05 09:52:00 -05:00
|
|
|
case imp.Ack():
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-11-17 18:29:00 -05:00
|
|
|
finally {
|
2008-03-05 09:52:00 -05:00
|
|
|
pool.Release(imp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void FlushCaches()
|
|
|
|
{
|
|
|
|
SecurityDiagnosticsContract.Imp! imp = pool.Acquire();
|
2008-11-17 18:29:00 -05:00
|
|
|
try {
|
2008-03-05 09:52:00 -05:00
|
|
|
imp.SendFlushCaches();
|
2008-11-17 18:29:00 -05:00
|
|
|
switch receive {
|
2008-03-05 09:52:00 -05:00
|
|
|
case imp.Ack():
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-11-17 18:29:00 -05:00
|
|
|
finally {
|
2008-03-05 09:52:00 -05:00
|
|
|
pool.Release(imp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|