Remove line feed chars

This commit is contained in:
Jim Norman 2008-03-27 23:10:09 +00:00
parent a31cb2ba90
commit 54210a90b8
20 changed files with 2527 additions and 2527 deletions

View File

@ -35,38 +35,38 @@ using sscs.constants;
namespace sscs.common
{
class CSSSUtils
{
#if W32
private static bool IsRegKeySet(string sPath, string sValue)
{
Microsoft.Win32.RegistryKey key;
try
{
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sPath);
int iValue = (int)key.GetValue(sValue);
key.Close();
if (iValue > 0)
{
return true;
}
}
catch (Exception e)
{
}
return false;
}
#endif
public static bool StoreDesktopPasswordInCache()
{
{
#if W32
private static bool IsRegKeySet(string sPath, string sValue)
{
Microsoft.Win32.RegistryKey key;
try
{
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(sPath);
int iValue = (int)key.GetValue(sValue);
key.Close();
if (iValue > 0)
{
return true;
}
}
catch (Exception e)
{
}
return false;
}
#endif
public static bool StoreDesktopPasswordInCache()
{
#if LINUX
return true;
#else
return IsRegKeySet("SOFTWARE\\Novell\\CASA", "CacheDesktopPassword");
#endif
#else
return IsRegKeySet("SOFTWARE\\Novell\\CASA", "CacheDesktopPassword");
#endif
}
public static bool IsFileOwnedByRoot(string filePath)

View File

@ -20,132 +20,132 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of AddKeyChain call.
* There will be one instance existing for every call made by the client.
*/
internal class AddKeyChain : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint keyChainFlags = 0;
private uint keyChainIdLen = 0;
private string keyChainId;
private uint outMsgLen = 0;
private byte[] inBuf;
private byte[] outBuf;
private int retCode = 0;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of AddKeyChain
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
CSSSLogger.ExecutionTrace(this);
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainFlags = BitConverter.ToUInt32(inBuf,6);
keyChainIdLen = BitConverter.ToUInt32(inBuf,10);
byte[] tempArr = new byte[keyChainIdLen];
Array.Copy(inBuf,14,tempArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(tempArr);
// Message Format decipher - End
try
{
SecretStore ssStore = null;
KeyChain keyChain = null;
keyChain = new KeyChain(keyChainId);
ssStore = SessionManager.GetUserSecretStore(userId);
if( ssStore.CheckIfKeyChainExists(keyChainId) == false )
{
ssStore.AddKeyChain(keyChain);
}
else
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Keychain already present for keychain id " +keyChainId );
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_ALREADY_EXISTS;
}
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 5;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return (this.ToString());
}
}
}
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of AddKeyChain call.
* There will be one instance existing for every call made by the client.
*/
internal class AddKeyChain : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint keyChainFlags = 0;
private uint keyChainIdLen = 0;
private string keyChainId;
private uint outMsgLen = 0;
private byte[] inBuf;
private byte[] outBuf;
private int retCode = 0;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of AddKeyChain
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
CSSSLogger.ExecutionTrace(this);
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainFlags = BitConverter.ToUInt32(inBuf,6);
keyChainIdLen = BitConverter.ToUInt32(inBuf,10);
byte[] tempArr = new byte[keyChainIdLen];
Array.Copy(inBuf,14,tempArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(tempArr);
// Message Format decipher - End
try
{
SecretStore ssStore = null;
KeyChain keyChain = null;
keyChain = new KeyChain(keyChainId);
ssStore = SessionManager.GetUserSecretStore(userId);
if( ssStore.CheckIfKeyChainExists(keyChainId) == false )
{
ssStore.AddKeyChain(keyChain);
}
else
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Keychain already present for keychain id " +keyChainId );
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_ALREADY_EXISTS;
}
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 5;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return (this.ToString());
}
}
}

View File

@ -20,120 +20,120 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of CloseSecretStore call.
* There will be one instance existing for every call made by the client.
*/
internal class CloseSecretStore : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private byte[] inBuf;
private byte[] outBuf;
private int retCode = 0;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of CloseSecretStore
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
CSSSLogger.ExecutionTrace(this);
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
uint ssFlags = BitConverter.ToUInt32(inBuf,6);
// Message Format decipher - End
try
{
if ((ssFlags & ConstFlags.SSFLAGS_DESTROY_SESSION_F) == ConstFlags.SSFLAGS_DESTROY_SESSION_F)
{
#if W32
SessionManager.RemoveUserSession(userId, true);
#else
SessionManager.CheckAndDestroySession(userId, true);
#endif
}
else
SessionManager.RemoveUserSession(userId, false);
}
catch(Exception)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Exception encountered in removing user session.");
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
// Construct a Reply.
try
{
msgId = 2;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of CloseSecretStore call.
* There will be one instance existing for every call made by the client.
*/
internal class CloseSecretStore : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private byte[] inBuf;
private byte[] outBuf;
private int retCode = 0;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of CloseSecretStore
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
CSSSLogger.ExecutionTrace(this);
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
uint ssFlags = BitConverter.ToUInt32(inBuf,6);
// Message Format decipher - End
try
{
if ((ssFlags & ConstFlags.SSFLAGS_DESTROY_SESSION_F) == ConstFlags.SSFLAGS_DESTROY_SESSION_F)
{
#if W32
SessionManager.RemoveUserSession(userId, true);
#else
SessionManager.CheckAndDestroySession(userId, true);
#endif
}
else
SessionManager.RemoveUserSession(userId, false);
}
catch(Exception)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Exception encountered in removing user session.");
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
// Construct a Reply.
try
{
msgId = 2;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,134 +20,134 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of EnumerateKeyChainIds call.
* There will be one instance existing for every call made by the client.
*/
internal class EnumerateKeyChainIds : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private int retCode = 0;
private byte[] inBuf;
private byte[] outBuf;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of EnumerateKeyChainIds
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
int keyChainIdsLen = 0;
StringBuilder keyChainIds = new StringBuilder();
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
// Message Format decipher - End
try
{
int index = 0;
SecretStore ssStore = SessionManager.GetUserSecretStore(userId);
int numKeyChains = ssStore.GetNumKeyChains();
IDictionaryEnumerator etor = (IDictionaryEnumerator)ssStore.GetKeyChainEnumerator();
while(etor.MoveNext())
{
index++;
keyChainIds.Append((string)etor.Key,0,(((string)(etor.Key)).Length)-1);
keyChainIdsLen += ((string)(etor.Key)).Length-1;
if( index != numKeyChains )
{
keyChainIds.Append("*");
keyChainIdsLen += 1;
}
}
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
// Construct a Reply.
try
{
msgId = 4;
outMsgLen = 14 + (uint)keyChainIds.Length;
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(keyChainIdsLen);
Array.Copy(t,0,outBuf,6,4);
Encoding.UTF8.GetBytes(keyChainIds.ToString(),0,keyChainIds.Length,outBuf,10);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,(10+keyChainIds.Length),4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
return this.ToString();
}
}
}
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of EnumerateKeyChainIds call.
* There will be one instance existing for every call made by the client.
*/
internal class EnumerateKeyChainIds : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private int retCode = 0;
private byte[] inBuf;
private byte[] outBuf;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of EnumerateKeyChainIds
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
int keyChainIdsLen = 0;
StringBuilder keyChainIds = new StringBuilder();
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
// Message Format decipher - End
try
{
int index = 0;
SecretStore ssStore = SessionManager.GetUserSecretStore(userId);
int numKeyChains = ssStore.GetNumKeyChains();
IDictionaryEnumerator etor = (IDictionaryEnumerator)ssStore.GetKeyChainEnumerator();
while(etor.MoveNext())
{
index++;
keyChainIds.Append((string)etor.Key,0,(((string)(etor.Key)).Length)-1);
keyChainIdsLen += ((string)(etor.Key)).Length-1;
if( index != numKeyChains )
{
keyChainIds.Append("*");
keyChainIdsLen += 1;
}
}
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
// Construct a Reply.
try
{
msgId = 4;
outMsgLen = 14 + (uint)keyChainIds.Length;
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(keyChainIdsLen);
Array.Copy(t,0,outBuf,6,4);
Encoding.UTF8.GetBytes(keyChainIds.ToString(),0,keyChainIds.Length,outBuf,10);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,(10+keyChainIds.Length),4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
return this.ToString();
}
}
}

View File

@ -20,157 +20,157 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of EnumerateSecretIds call.
* There will be one instance existing for every call made by the client.
*/
internal class EnumerateSecretIds : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private string keyChainId;
private int retCode = 0;
private byte[] inBuf;
private byte[] outBuf;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of EnumerateSecretIds
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
int secretIdsLen = 0;
StringBuilder secretIds = new StringBuilder();
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
// Message Format decipher - End
try
{
SecretStore ssStore = SessionManager.GetUserSecretStore(userId);
if (!ssStore.IsStoreLocked())
{
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
KeyChain keyChain = ssStore.GetKeyChain(keyChainId);
int numSecrets = keyChain.GetNumSecrets();
int index = 0;
IDictionaryEnumerator etor = (IDictionaryEnumerator)keyChain.GetAllSecrets();
while(etor.MoveNext())
{
index++;
secretIds.Append((string)etor.Key,0,(((string)(etor.Key)).Length)-1);
secretIdsLen += ((string)(etor.Key)).Length-1;
if( index != numSecrets )
{
secretIds.Append("*");
secretIdsLen += 1;
}
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
{
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception)
{
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
//Construct a reply.
try
{
msgId = 7;
outMsgLen = 14 + (uint)secretIds.Length;
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(secretIdsLen);
Array.Copy(t,0,outBuf,6,4);
Encoding.UTF8.GetBytes(secretIds.ToString(),0,secretIds.Length,outBuf,10);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,(10+secretIds.Length),4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of EnumerateSecretIds call.
* There will be one instance existing for every call made by the client.
*/
internal class EnumerateSecretIds : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private string keyChainId;
private int retCode = 0;
private byte[] inBuf;
private byte[] outBuf;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of EnumerateSecretIds
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
int secretIdsLen = 0;
StringBuilder secretIds = new StringBuilder();
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
// Message Format decipher - End
try
{
SecretStore ssStore = SessionManager.GetUserSecretStore(userId);
if (!ssStore.IsStoreLocked())
{
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
KeyChain keyChain = ssStore.GetKeyChain(keyChainId);
int numSecrets = keyChain.GetNumSecrets();
int index = 0;
IDictionaryEnumerator etor = (IDictionaryEnumerator)keyChain.GetAllSecrets();
while(etor.MoveNext())
{
index++;
secretIds.Append((string)etor.Key,0,(((string)(etor.Key)).Length)-1);
secretIdsLen += ((string)(etor.Key)).Length-1;
if( index != numSecrets )
{
secretIds.Append("*");
secretIdsLen += 1;
}
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
{
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception)
{
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
//Construct a reply.
try
{
msgId = 7;
outMsgLen = 14 + (uint)secretIds.Length;
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(secretIdsLen);
Array.Copy(t,0,outBuf,6,4);
Encoding.UTF8.GetBytes(secretIds.ToString(),0,secretIds.Length,outBuf,10);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,(10+secretIds.Length),4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,123 +20,123 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of GetSecretStoreInfo call.
* There will be one instance existing for every call made by the client.
*/
internal class GetSecretStoreInfo : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint numKeyChains = 0;
private byte[] inBuf;
private byte[] outBuf;
private int retCode = 0;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of GetSecretStoreInfo
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
// Message Format decipher - End
try
{
SecretStore ssStore = SessionManager.GetUserSecretStore(userId);
numKeyChains = (uint) ssStore.GetNumKeyChains();
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
// Construct Response
try
{
msgId = 11;
outMsgLen = 14;
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(numKeyChains);
Array.Copy(t,0,outBuf,6,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of GetSecretStoreInfo call.
* There will be one instance existing for every call made by the client.
*/
internal class GetSecretStoreInfo : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint numKeyChains = 0;
private byte[] inBuf;
private byte[] outBuf;
private int retCode = 0;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of GetSecretStoreInfo
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
// Message Format decipher - End
try
{
SecretStore ssStore = SessionManager.GetUserSecretStore(userId);
numKeyChains = (uint) ssStore.GetNumKeyChains();
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
// Construct Response
try
{
msgId = 11;
outMsgLen = 14;
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(numKeyChains);
Array.Copy(t,0,outBuf,6,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,37 +20,37 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
namespace sscs.verbs
{
/*
* Defines the interfaces to be implemenetd by all Secret Store Verbs.
*/
interface SSVerb
{
/* Takes in the raw bytes and sets them for a Verb,
* so that the verb will execute in the bytes given.
* TBD: In case we are able to send the byte[] through constructor,
* we can avoid this interface.
*/
void SetMessageContent(byte[] rawbytes);
/* Takes in the SecretStore Reeference and returns the correct SSVerb
*/
byte[] ProcessRequest(UserIdentifier userId);
//Gives the name of operation performed.Can be used in case of error.
string GetVerbName();
}
}
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
namespace sscs.verbs
{
/*
* Defines the interfaces to be implemenetd by all Secret Store Verbs.
*/
interface SSVerb
{
/* Takes in the raw bytes and sets them for a Verb,
* so that the verb will execute in the bytes given.
* TBD: In case we are able to send the byte[] through constructor,
* we can avoid this interface.
*/
void SetMessageContent(byte[] rawbytes);
/* Takes in the SecretStore Reeference and returns the correct SSVerb
*/
byte[] ProcessRequest(UserIdentifier userId);
//Gives the name of operation performed.Can be used in case of error.
string GetVerbName();
}
}

View File

@ -1,165 +1,165 @@
using System;
using System.Collections;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
using sscs.lss;
namespace sscs.verbs
{
/// <summary>
/// Summary description for MergeCache.
/// </summary>
internal class MergeCache : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private int retCode = 0;
private byte[] inBuf;
private byte[] outBuf;
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of MergeSecret
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf, 0);
inMsgLen = BitConverter.ToUInt32(inBuf, 2);
if (inMsgLen != inBuf.Length)
throw new FormatException(" MsgLen sent does not match the length of the message received.");
// get the src LUID
int luidLow = BitConverter.ToInt32(inBuf, 14);
int luidHigh = BitConverter.ToInt32(inBuf, 18);
// get the target LUID
int targetLuidLow = BitConverter.ToInt32(inBuf, 30);
int targetLuidHigh = BitConverter.ToInt32(inBuf, 34);
// get destroy flag
int iDestroySrcCache = BitConverter.ToInt32(inBuf, 38);
CSSSLogger.DbgLog(" SRC LUID found: " + luidHigh.ToString() + ":"+ luidLow.ToString());
CSSSLogger.DbgLog("Target LUID found: " + targetLuidHigh.ToString() +":" + targetLuidLow.ToString());
#if W32
// only allow the merge if the calling process is "System"
WinUserIdentifier callingUser = (WinUserIdentifier)userId;
if ((callingUser.GetUIDLow() == 999) && (callingUser.GetUIDHigh() == 0))
{
CSSSLogger.DbgLog("MergeSecrets: Caller is system process");
// get the store for the src
try
{
//WinUserIdentifier srcUser = new WinUserIdentifier(luidLow, luidHigh);
SecretStore srcStore = SessionManager.GetUserSecretStore(userId);
KeyChain kcSrc = null;
KeyChain kcDest = null;
// rename keychainID from SRC LUID to Target LUID.
if (srcStore.CheckIfKeyChainExists(luidHigh.ToString() + luidLow.ToString()))
{
kcSrc = srcStore.GetKeyChain(luidHigh.ToString() + luidLow.ToString());
kcDest = new KeyChain(targetLuidHigh.ToString() + targetLuidLow.ToString());
if (!srcStore.CheckIfKeyChainExists(targetLuidHigh.ToString() + targetLuidLow.ToString()))
{
srcStore.AddKeyChain(kcDest);
}
// merge secrets from src to dest keychain
IDictionaryEnumerator secIter = (IDictionaryEnumerator)(kcSrc.GetAllSecrets());
while (secIter.MoveNext())
{
Secret secret = (Secret)secIter.Value;
kcDest.AddSecret(secret);
}
if (iDestroySrcCache > 0)
{
srcStore.RemoveKeyChain(luidHigh.ToString() + luidLow.ToString());
}
}
else
{
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
}
}
catch (Exception e)
{
CSSSLogger.DbgLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
}
}
else
{
CSSSLogger.DbgLog("Caller is NOT system process, Merge not allowed!");
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
}
#else
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
#endif
try
{
msgId = 19;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t, 0, outBuf, 0, 2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t, 0, outBuf, 2, 4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t, 0, outBuf, 6, 4);
}
catch (Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
using System;
using System.Collections;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
using sscs.lss;
namespace sscs.verbs
{
/// <summary>
/// Summary description for MergeCache.
/// </summary>
internal class MergeCache : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private int retCode = 0;
private byte[] inBuf;
private byte[] outBuf;
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of MergeSecret
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf, 0);
inMsgLen = BitConverter.ToUInt32(inBuf, 2);
if (inMsgLen != inBuf.Length)
throw new FormatException(" MsgLen sent does not match the length of the message received.");
// get the src LUID
int luidLow = BitConverter.ToInt32(inBuf, 14);
int luidHigh = BitConverter.ToInt32(inBuf, 18);
// get the target LUID
int targetLuidLow = BitConverter.ToInt32(inBuf, 30);
int targetLuidHigh = BitConverter.ToInt32(inBuf, 34);
// get destroy flag
int iDestroySrcCache = BitConverter.ToInt32(inBuf, 38);
CSSSLogger.DbgLog(" SRC LUID found: " + luidHigh.ToString() + ":"+ luidLow.ToString());
CSSSLogger.DbgLog("Target LUID found: " + targetLuidHigh.ToString() +":" + targetLuidLow.ToString());
#if W32
// only allow the merge if the calling process is "System"
WinUserIdentifier callingUser = (WinUserIdentifier)userId;
if ((callingUser.GetUIDLow() == 999) && (callingUser.GetUIDHigh() == 0))
{
CSSSLogger.DbgLog("MergeSecrets: Caller is system process");
// get the store for the src
try
{
//WinUserIdentifier srcUser = new WinUserIdentifier(luidLow, luidHigh);
SecretStore srcStore = SessionManager.GetUserSecretStore(userId);
KeyChain kcSrc = null;
KeyChain kcDest = null;
// rename keychainID from SRC LUID to Target LUID.
if (srcStore.CheckIfKeyChainExists(luidHigh.ToString() + luidLow.ToString()))
{
kcSrc = srcStore.GetKeyChain(luidHigh.ToString() + luidLow.ToString());
kcDest = new KeyChain(targetLuidHigh.ToString() + targetLuidLow.ToString());
if (!srcStore.CheckIfKeyChainExists(targetLuidHigh.ToString() + targetLuidLow.ToString()))
{
srcStore.AddKeyChain(kcDest);
}
// merge secrets from src to dest keychain
IDictionaryEnumerator secIter = (IDictionaryEnumerator)(kcSrc.GetAllSecrets());
while (secIter.MoveNext())
{
Secret secret = (Secret)secIter.Value;
kcDest.AddSecret(secret);
}
if (iDestroySrcCache > 0)
{
srcStore.RemoveKeyChain(luidHigh.ToString() + luidLow.ToString());
}
}
else
{
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
}
}
catch (Exception e)
{
CSSSLogger.DbgLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
}
}
else
{
CSSSLogger.DbgLog("Caller is NOT system process, Merge not allowed!");
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
}
#else
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
#endif
try
{
msgId = 19;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t, 0, outBuf, 0, 2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t, 0, outBuf, 2, 4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t, 0, outBuf, 6, 4);
}
catch (Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,134 +20,134 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of OpenSecretStore call.
* There will be one instance existing for every call made by the client.
*/
internal class OpenSecretStore : SSVerb
{
ushort msgId = 0;
uint inMsgLen = 0;
uint outMsgLen = 0;
uint ssVersion = 0;
uint ssNameLen = 0;
private string ssName; //Name of SecretStore to open
private byte[] inBuf;
private byte[] outBuf;
int retCode = 0;
private static int MAX_SS_NAME_LEN = 256;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of OpenSecretStore
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
CSSSLogger.ExecutionTrace(this);
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
ssVersion = BitConverter.ToUInt32(inBuf,6);
ssNameLen = BitConverter.ToUInt32(inBuf,10);
if (ssNameLen > MAX_SS_NAME_LEN)
throw new FormatException(" SecretStore Name length exceeds length allowed");
byte[] tempArr = new byte[ssNameLen];
Array.Copy(inBuf,14,tempArr,0,ssNameLen);
ssName = Encoding.UTF8.GetString(tempArr);
try
{
SecretStore ss = SessionManager.CreateUserSession(userId);
if( null == ss )
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " SecretStore instance is null");
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
else
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " + - Created a new Session entry");
}
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 1;
outMsgLen = 14;
outBuf = new byte[14];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes((uint)ssVersion);
Array.Copy(t,0,outBuf,6,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of OpenSecretStore call.
* There will be one instance existing for every call made by the client.
*/
internal class OpenSecretStore : SSVerb
{
ushort msgId = 0;
uint inMsgLen = 0;
uint outMsgLen = 0;
uint ssVersion = 0;
uint ssNameLen = 0;
private string ssName; //Name of SecretStore to open
private byte[] inBuf;
private byte[] outBuf;
int retCode = 0;
private static int MAX_SS_NAME_LEN = 256;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of OpenSecretStore
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
CSSSLogger.ExecutionTrace(this);
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
ssVersion = BitConverter.ToUInt32(inBuf,6);
ssNameLen = BitConverter.ToUInt32(inBuf,10);
if (ssNameLen > MAX_SS_NAME_LEN)
throw new FormatException(" SecretStore Name length exceeds length allowed");
byte[] tempArr = new byte[ssNameLen];
Array.Copy(inBuf,14,tempArr,0,ssNameLen);
ssName = Encoding.UTF8.GetString(tempArr);
try
{
SecretStore ss = SessionManager.CreateUserSession(userId);
if( null == ss )
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " SecretStore instance is null");
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
else
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " + - Created a new Session entry");
}
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 1;
outMsgLen = 14;
outBuf = new byte[14];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes((uint)ssVersion);
Array.Copy(t,0,outBuf,6,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,42 +20,42 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of ReadKey call.
* There will be one instance existing for every call made by the client.
*/
internal class ReadBinaryKey : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private uint secretIdLen = 0;
private int retCode = 0;
private string keyChainId;
private string secretId;
private uint keyLen;
private string key;
private uint valLen;
private byte[] val;
//private byte[] secretVal;
private byte[] inBuf;
private byte[] outBuf;
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of ReadKey call.
* There will be one instance existing for every call made by the client.
*/
internal class ReadBinaryKey : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private uint secretIdLen = 0;
private int retCode = 0;
private string keyChainId;
private string secretId;
private uint keyLen;
private string key;
private uint valLen;
private byte[] val;
//private byte[] secretVal;
private byte[] inBuf;
private byte[] outBuf;
// extension operations
private uint extId = 0;
#if W32
@ -63,59 +63,59 @@ namespace sscs.verbs
private int luidHigh = 0;
#endif
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of ReadKey
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
Secret secret = null;
CSSSLogger.ExecutionTrace(this);
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of ReadKey
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
Secret secret = null;
CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End
keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen));
byte[] keyArr = new byte[keyLen];
Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen);
key = Encoding.UTF8.GetString(keyArr);
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End
keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen));
byte[] keyArr = new byte[keyLen];
Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen);
key = Encoding.UTF8.GetString(keyArr);
try
{
// get extension ID
@ -128,125 +128,125 @@ namespace sscs.verbs
}
SecretStore ssStore;
if (extId == 1)
{
#if W32
CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{
// WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadBinaryKey: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
#if W32
CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{
// WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadBinaryKey: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
}
#endif
}
try
{
KeyChain keyChain = null;
// Secret secret = null;
ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked())
{
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false)
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
else
{
secret = keyChain.GetSecret(secretId);
KeyValue kv = secret.GetKeyValue(key);
if (kv != null)
{
val = kv.GetValueAsBytes();
}
else
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 16;
if( 0 == retCode )
{
valLen = (uint)val.Length;
outMsgLen = 14 + valLen;
}
else
{
outMsgLen = 14; //2+4+4+4
}
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(valLen);
Array.Copy(t,0,outBuf,6,4);
if( 0 == retCode )
Array.Copy(val,0,outBuf,10,valLen);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10+valLen,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
try
{
KeyChain keyChain = null;
// Secret secret = null;
ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked())
{
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false)
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
else
{
secret = keyChain.GetSecret(secretId);
KeyValue kv = secret.GetKeyValue(key);
if (kv != null)
{
val = kv.GetValueAsBytes();
}
else
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 16;
if( 0 == retCode )
{
valLen = (uint)val.Length;
outMsgLen = 14 + valLen;
}
else
{
outMsgLen = 14; //2+4+4+4
}
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(valLen);
Array.Copy(t,0,outBuf,6,4);
if( 0 == retCode )
Array.Copy(val,0,outBuf,10,valLen);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10+valLen,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,102 +20,102 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of ReadKey call.
* There will be one instance existing for every call made by the client.
*/
internal class ReadKey : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private uint secretIdLen = 0;
private int retCode = 0;
private string keyChainId;
private string secretId;
private uint keyLen;
private string key;
private uint valLen;
private byte[] val;
//private byte[] secretVal;
private byte[] inBuf;
private byte[] outBuf;
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of ReadKey call.
* There will be one instance existing for every call made by the client.
*/
internal class ReadKey : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private uint secretIdLen = 0;
private int retCode = 0;
private string keyChainId;
private string secretId;
private uint keyLen;
private string key;
private uint valLen;
private byte[] val;
//private byte[] secretVal;
private byte[] inBuf;
private byte[] outBuf;
// extension operations
private uint extId = 0;
#if W32
private int luidLow = 0;
private int luidHigh = 0;
#endif
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of ReadKey
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
Secret secret = null;
CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End
keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen));
byte[] keyArr = new byte[keyLen];
Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen);
key = Encoding.UTF8.GetString(keyArr);
#endif
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of ReadKey
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
Secret secret = null;
CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End
keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen));
byte[] keyArr = new byte[keyLen];
Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen);
key = Encoding.UTF8.GetString(keyArr);
try
{
// get extension ID
@ -130,124 +130,124 @@ namespace sscs.verbs
SecretStore ssStore;
if (extId == 1)
{
#if W32
CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{
// WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadKey: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
}
{
#if W32
CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{
// WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadKey: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
}
#endif
}
try
{
KeyChain keyChain = null;
ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked())
{
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false)
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
else
{
secret = keyChain.GetSecret(secretId);
KeyValue kv = secret.GetKeyValue(key);
if ((kv != null) && (kv.GetValue().Length > 0))
{
string valStr = secret.GetKeyValue(key).GetValue();
val = Encoding.UTF8.GetBytes(valStr);
}
else
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 16;
if( 0 == retCode )
{
valLen = (uint)val.Length;
outMsgLen = 14 + valLen;
}
else
{
outMsgLen = 14; //2+4+4+4
}
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(valLen);
Array.Copy(t,0,outBuf,6,4);
if( 0 == retCode )
Array.Copy(val,0,outBuf,10,valLen);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10+valLen,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
}
try
{
KeyChain keyChain = null;
ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked())
{
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false)
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
else
{
secret = keyChain.GetSecret(secretId);
KeyValue kv = secret.GetKeyValue(key);
if ((kv != null) && (kv.GetValue().Length > 0))
{
string valStr = secret.GetKeyValue(key).GetValue();
val = Encoding.UTF8.GetBytes(valStr);
}
else
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 16;
if( 0 == retCode )
{
valLen = (uint)val.Length;
outMsgLen = 14 + valLen;
}
else
{
outMsgLen = 14; //2+4+4+4
}
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(valLen);
Array.Copy(t,0,outBuf,6,4);
if( 0 == retCode )
Array.Copy(val,0,outBuf,10,valLen);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10+valLen,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,37 +20,37 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of ReadSecret call.
* There will be one instance existing for every call made by the client.
*/
internal class ReadSecret : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private uint secretIdLen = 0;
private uint secretValLen = 0;
private int retCode = 0;
private string keyChainId;
private string secretId;
//private byte[] secretVal;
private byte[] inBuf;
private byte[] outBuf;
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of ReadSecret call.
* There will be one instance existing for every call made by the client.
*/
internal class ReadSecret : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private uint secretIdLen = 0;
private uint secretValLen = 0;
private int retCode = 0;
private string keyChainId;
private string secretId;
//private byte[] secretVal;
private byte[] inBuf;
private byte[] outBuf;
// extension operations
private uint extId = 0;
@ -58,56 +58,56 @@ namespace sscs.verbs
private int luidLow = 0;
private int luidHigh = 0;
#endif
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of ReadSecret
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
Secret secret = null;
CSSSLogger.ExecutionTrace(this);
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of ReadSecret
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
Secret secret = null;
CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End
try
{
// get extension ID
@ -119,12 +119,12 @@ namespace sscs.verbs
//CSSSLogger.ExpLog(e.ToString());
}
SecretStore ssStore;
SecretStore ssStore;
CSSSLogger.DbgLog("Reading Secret ID: " + secretId);
if (extId == 1)
{
#if W32
#if W32
CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
@ -134,108 +134,108 @@ namespace sscs.verbs
// WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen)+((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen)+((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen)+((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
}
#endif
}
try
{
KeyChain keyChain = null;
// Secret secret = null;
ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked())
{
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false)
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
else
{
secret = keyChain.GetSecret(secretId);
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 8;
uint secretValLen = 0;
byte[] baSecretValue = new byte[0];
if( 0 == retCode )
{
baSecretValue = secret.GetValue(secretId);
secretValLen = (uint)baSecretValue.Length;
outMsgLen = 14 + secretValLen;
}
else
{
outMsgLen = 14; //2+4+4+4
}
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(secretValLen);
Array.Copy(t,0,outBuf,6,4);
if( 0 == retCode )
Array.Copy(baSecretValue,0,outBuf,10,secretValLen);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10+secretValLen,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
try
{
KeyChain keyChain = null;
// Secret secret = null;
ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked())
{
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false)
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
else
{
secret = keyChain.GetSecret(secretId);
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 8;
uint secretValLen = 0;
byte[] baSecretValue = new byte[0];
if( 0 == retCode )
{
baSecretValue = secret.GetValue(secretId);
secretValLen = (uint)baSecretValue.Length;
outMsgLen = 14 + secretValLen;
}
else
{
outMsgLen = 14; //2+4+4+4
}
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(secretValLen);
Array.Copy(t,0,outBuf,6,4);
if( 0 == retCode )
Array.Copy(baSecretValue,0,outBuf,10,secretValLen);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,10+secretValLen,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,100 +20,100 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of ReadKey call.
* There will be one instance existing for every call made by the client.
*/
internal class RemoveKey : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private uint secretIdLen = 0;
private int retCode = 0;
private string keyChainId;
private string secretId;
private uint keyLen;
private string key;
private byte[] inBuf;
private byte[] outBuf;
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.cache;
using sscs.common;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of ReadKey call.
* There will be one instance existing for every call made by the client.
*/
internal class RemoveKey : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private uint secretIdLen = 0;
private int retCode = 0;
private string keyChainId;
private string secretId;
private uint keyLen;
private string key;
private byte[] inBuf;
private byte[] outBuf;
// extension operations
private uint extId = 0;
#if W32
private int luidLow = 0;
private int luidHigh = 0;
#endif
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of ReadKey
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
Secret secret = null;
CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
UserIdentifier tempUserId = userId;
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End
keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen));
byte[] keyArr = new byte[keyLen];
Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen);
key = Encoding.UTF8.GetString(keyArr);
#endif
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of ReadKey
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
Secret secret = null;
CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
UserIdentifier tempUserId = userId;
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr);
// Message Format decipher - End
keyLen = BitConverter.ToUInt32(inBuf,(14+(int)keyChainIdLen+(int)secretIdLen));
byte[] keyArr = new byte[keyLen];
Array.Copy(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen),keyArr,0,keyLen);
key = Encoding.UTF8.GetString(keyArr);
try
{
// get extension ID
@ -126,116 +126,116 @@ namespace sscs.verbs
}
if (extId == 1)
{
#if W32
CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{
// WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
}
{
#if W32
CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{
// WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
}
#endif
}
try
{
KeyChain keyChain = null;
// Secret secret = null;
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked())
{
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false)
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
else
{
secret = keyChain.GetSecret(secretId);
if (secret != null)
{
try
{
secret.RemoveKeyValue(keyChain, key);
}
catch (Exception e)
{
CSSSLogger.ExpLog(e.ToString());
}
}
else
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
// Construct a Reply
try
{
msgId = 17;
outMsgLen = 10;
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t, 0, outBuf, 0, 2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t, 0, outBuf, 2, 4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t, 0, outBuf, 6, 4);
}
catch (Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
try
{
KeyChain keyChain = null;
// Secret secret = null;
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked())
{
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
keyChain = ssStore.GetKeyChain(keyChainId);
if( keyChain.CheckIfSecretExists(secretId) == false)
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
else
{
secret = keyChain.GetSecret(secretId);
if (secret != null)
{
try
{
secret.RemoveKeyValue(keyChain, key);
}
catch (Exception e)
{
CSSSLogger.ExpLog(e.ToString());
}
}
else
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
// Construct a Reply
try
{
msgId = 17;
outMsgLen = 10;
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t, 0, outBuf, 0, 2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t, 0, outBuf, 2, 4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t, 0, outBuf, 6, 4);
}
catch (Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,131 +20,131 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.constants;
using sscs.cache;
namespace sscs.verbs
{
/*
* This class is implementation of RemoveKeyChain call.
* There will be one instance existing for every call made by the client.
*/
internal class RemoveKeyChain : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private string keyChainId;
private int retCode = 0;
private byte[] inBuf;
private byte[] outBuf;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of RemoveKeyChain
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
// Message Format decipher - End
try
{
SecretStore ssStore = null;
ssStore = SessionManager.GetUserSecretStore(userId);
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
ssStore.RemoveKeyChain(keyChainId);
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 6;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.constants;
using sscs.cache;
namespace sscs.verbs
{
/*
* This class is implementation of RemoveKeyChain call.
* There will be one instance existing for every call made by the client.
*/
internal class RemoveKeyChain : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private string keyChainId;
private int retCode = 0;
private byte[] inBuf;
private byte[] outBuf;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of RemoveKeyChain
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
// Message Format decipher - End
try
{
SecretStore ssStore = null;
ssStore = SessionManager.GetUserSecretStore(userId);
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
ssStore.RemoveKeyChain(keyChainId);
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 6;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,94 +20,94 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of RemoveSecret call.
* There will be one instance existing for every call made by the client.
*/
internal class RemoveSecret : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private uint secretIdLen = 0;
private int retCode = 0;
private string keyChainId;
private string secretId;
private byte[] inBuf;
private byte[] outBuf;
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of RemoveSecret call.
* There will be one instance existing for every call made by the client.
*/
internal class RemoveSecret : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private uint keyChainIdLen = 0;
private uint secretIdLen = 0;
private int retCode = 0;
private string keyChainId;
private string secretId;
private byte[] inBuf;
private byte[] outBuf;
// extension operations
private uint extId = 0;
#if W32
private int luidLow = 0;
private int luidHigh = 0;
#endif
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of RemoveSecret
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr);
CSSSLogger.DbgLog("Deleting secret id: " + secretId);
#endif
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of RemoveSecret
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
UserIdentifier tempUserId = userId;
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
keyChainIdLen = BitConverter.ToUInt32(inBuf,6);
byte[] keyChainIdArr = new byte[keyChainIdLen];
Array.Copy(inBuf,10,keyChainIdArr,0,keyChainIdLen);
keyChainId = Encoding.UTF8.GetString(keyChainIdArr);
secretIdLen = BitConverter.ToUInt32(inBuf,
(10 + (int)keyChainIdLen));
byte[] secretIdArr = new byte[secretIdLen];
Array.Copy(inBuf,(10+keyChainIdLen+4),secretIdArr,0,secretIdLen);
secretId = Encoding.UTF8.GetString(secretIdArr);
CSSSLogger.DbgLog("Deleting secret id: " + secretId);
try
{
{
CSSSLogger.DbgLog("Looking for extention");
// get extension ID
int extLocation = 18 + ((int)keyChainIdLen) + ((int)secretIdLen);
@ -116,107 +116,107 @@ namespace sscs.verbs
catch (Exception)
{
//CSSSLogger.ExpLog(e.ToString());
}
}
if (extId == 1)
{
#if W32
CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{
// WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
}
{
#if W32
CSSSLogger.DbgLog("LUID ExtID found");
WinUserIdentifier test = (WinUserIdentifier)userId;
// NOTE: ONLY ALLOW THE SWITCH IF THE CALLER IS "SYSTEM"
if ((test.GetUIDLow() == 999) && (test.GetUIDHigh() == 0))
{
// WINDOWS LUID
// System Services, like DLU create fake UIDs, store credentials and then want to read that data.
luidLow = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 8);
luidHigh = BitConverter.ToInt32(inBuf, 18 + ((int)keyChainIdLen) + ((int)secretIdLen) + 12);
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
CSSSLogger.DbgLog("ReadSecret: Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
}
#endif
}
// Message Format decipher - End
try
{
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked())
{
if (ssStore.CheckIfKeyChainExists(keyChainId))
{
KeyChain keyChain = ssStore.GetKeyChain(keyChainId);
if (keyChain.CheckIfSecretExists(secretId) == false)
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
else
{
// TODO: get the secret and remove linked keys
keyChain.RemoveSecret(secretId);
ssStore.UpdatePersistentStore();
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception)
{
CSSSLogger.DbgLog( "In " + CSSSLogger.GetExecutionPath(this) + " - Secret ID not present" + secretId);
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
// Construct a Reply
try
{
msgId = 10;
outMsgLen = 10;
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
}
// Message Format decipher - End
try
{
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.IsStoreLocked())
{
if (ssStore.CheckIfKeyChainExists(keyChainId))
{
KeyChain keyChain = ssStore.GetKeyChain(keyChainId);
if (keyChain.CheckIfSecretExists(secretId) == false)
{
retCode = IPCRetCodes.SSCS_E_SECRETID_DOES_NOT_EXIST;
}
else
{
// TODO: get the secret and remove linked keys
keyChain.RemoveSecret(secretId);
ssStore.UpdatePersistentStore();
}
}
else
{
retCode = IPCRetCodes.SSCS_E_KEYCHAIN_DOES_NOT_EXIST;
}
}
else
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception)
{
CSSSLogger.DbgLog( "In " + CSSSLogger.GetExecutionPath(this) + " - Secret ID not present" + secretId);
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
// Construct a Reply
try
{
msgId = 10;
outMsgLen = 10;
outBuf = new byte[outMsgLen];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -21,112 +21,112 @@
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of RemoveSecretStore call.
* There will be one instance existing for every call made by the client.
*/
internal class RemoveSecretStore : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private byte[] inBuf;
private byte[] outBuf;
private int retCode = 0;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of RemoveSecretStore
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2) ;
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
try
{
SessionManager.RemoveUserSession(userId, true);
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 3;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of RemoveSecretStore call.
* There will be one instance existing for every call made by the client.
*/
internal class RemoveSecretStore : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint outMsgLen = 0;
private byte[] inBuf;
private byte[] outBuf;
private int retCode = 0;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of RemoveSecretStore
*
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
CSSSLogger.ExecutionTrace(this);
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2) ;
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
try
{
SessionManager.RemoveUserSession(userId, true);
}
catch(UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore" );
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
try
{
msgId = 3;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return this.ToString();
}
}
}

View File

@ -20,132 +20,132 @@
*
***********************************************************************/
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of SetMasterPasscode call.
* There will be one instance existing for every call made by the client.
*/
internal class SetMasterPasscode : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint passcodeLen = 0;
private string passcode;
private uint passcodeType = 0;
private uint outMsgLen = 0;
private byte[] inBuf;
private byte[] outBuf;
private int retCode = 0;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of SetMasterPasscode
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
CSSSLogger.ExecutionTrace(this);
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
passcodeType = BitConverter.ToUInt32(inBuf,6);
passcodeLen = BitConverter.ToUInt32(inBuf,10);
if (passcodeLen < 64)
{
byte[] tempArr = new byte[passcodeLen];
Array.Copy(inBuf, 14, tempArr, 0, passcodeLen);
passcode = Encoding.UTF8.GetString(tempArr);
// Message Format decipher - End
try
{
SecretStore ssStore = null;
ssStore = SessionManager.GetUserSecretStore(userId);
ssStore.PauseFileWatcher();
if (ssStore.SetMasterPasscode(passcode))
retCode = IPCRetCodes.SSCS_REPLY_SUCCESS;
else
retCode = IPCRetCodes.SSCS_E_SETTING_PASSCODE_FAILED;
ssStore.ResumeFileWatcher();
}
catch (UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore");
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch (Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
}
else
{
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
}
try
{
msgId = 15;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return (this.ToString());
}
}
}
using System;
using System.Collections;
using System.Text;
using System.Threading;
using sscs.verbs;
using sscs.common;
using sscs.cache;
using sscs.constants;
namespace sscs.verbs
{
/*
* This class is implementation of SetMasterPasscode call.
* There will be one instance existing for every call made by the client.
*/
internal class SetMasterPasscode : SSVerb
{
private ushort msgId = 0;
private uint inMsgLen = 0;
private uint passcodeLen = 0;
private string passcode;
private uint passcodeType = 0;
private uint outMsgLen = 0;
private byte[] inBuf;
private byte[] outBuf;
private int retCode = 0;
/*
* This method sets the class member with the byte array received.
*/
public void SetMessageContent(byte[] ipcBytes)
{
CSSSLogger.ExecutionTrace(this);
inBuf = ipcBytes;
}
/*
* This method does the actual implementation of SetMasterPasscode
*/
public byte[] ProcessRequest(UserIdentifier userId)
{
/* If an exception occurs in message format decoding,
* it is handled by AppHandler
*/
CSSSLogger.ExecutionTrace(this);
// Message Format decipher - Start
msgId = BitConverter.ToUInt16(inBuf,0);
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
passcodeType = BitConverter.ToUInt32(inBuf,6);
passcodeLen = BitConverter.ToUInt32(inBuf,10);
if (passcodeLen < 64)
{
byte[] tempArr = new byte[passcodeLen];
Array.Copy(inBuf, 14, tempArr, 0, passcodeLen);
passcode = Encoding.UTF8.GetString(tempArr);
// Message Format decipher - End
try
{
SecretStore ssStore = null;
ssStore = SessionManager.GetUserSecretStore(userId);
ssStore.PauseFileWatcher();
if (ssStore.SetMasterPasscode(passcode))
retCode = IPCRetCodes.SSCS_REPLY_SUCCESS;
else
retCode = IPCRetCodes.SSCS_E_SETTING_PASSCODE_FAILED;
ssStore.ResumeFileWatcher();
}
catch (UserNotInSessionException)
{
CSSSLogger.DbgLog("In " + CSSSLogger.GetExecutionPath(this) + " Unable to get user's secretstore");
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
catch (Exception e)
{
CSSSLogger.ExpLog(e.ToString());
retCode = IPCRetCodes.SSCS_E_SYSTEM_ERROR;
}
}
else
{
retCode = IPCRetCodes.SSCS_E_INVALID_INPUT;
}
try
{
msgId = 15;
outMsgLen = 10;
outBuf = new byte[10];
byte[] t = new byte[10];
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,outBuf,0,2);
t = BitConverter.GetBytes((uint)outMsgLen);
Array.Copy(t,0,outBuf,2,4);
t = BitConverter.GetBytes(retCode);
Array.Copy(t,0,outBuf,6,4);
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw new FormatException("Unable to form the response " + e.ToString());
}
return outBuf;
}
/*
* Gives the name of operation performed. Will be used in case
* of error.
*/
public string GetVerbName()
{
CSSSLogger.ExecutionTrace(this);
return (this.ToString());
}
}
}

View File

@ -92,12 +92,12 @@ namespace sscs.verbs
inMsgLen = BitConverter.ToUInt32(inBuf,2);
if( inMsgLen != inBuf.Length )
throw new FormatException(" MsgLen sent does not match the length of the message received.");
// get flags
throw new FormatException(" MsgLen sent does not match the length of the message received.");
// get flags
ssFlags = BitConverter.ToUInt32(inBuf, 6);
// get keychain
// get keychain
keyChainIdLen = BitConverter.ToUInt32(inBuf, 10);
byte[] keyChainIdArr = new byte[keyChainIdLen];
@ -132,10 +132,10 @@ namespace sscs.verbs
}
catch (Exception)
{
//CSSSLogger.ExpLog(e.ToString());
}
#if W32
//CSSSLogger.ExpLog(e.ToString());
}
#if W32
if (extId == 1)
{
// WINDOWS LUID
@ -143,45 +143,45 @@ namespace sscs.verbs
// we might be able to change this if/when we abstract the session.
// [4 byte extID][4 byte length][4 byte luidLow][4 byte luidHigh]
luidLow = BitConverter.ToInt32(inBuf, 30 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 8);
luidHigh = BitConverter.ToInt32(inBuf, 30 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 12);
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{
tempUserId = new WinUserIdentifier(luidLow, luidHigh);
SecretStore ss = SessionManager.CreateUserSession(tempUserId);
try
{
ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0"));
}
catch (Exception)
{
}
}
else
{
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.CheckIfKeyChainExists(keyChainId))
{
try
{
KeyChain newKeyChain = new KeyChain(keyChainId);
ssStore.AddKeyChain(newKeyChain);
}
catch (Exception e)
{
CSSSLogger.DbgLog("WriteKey: Adding keychain returned error: " + e.ToString());
}
}
}
}
#endif
luidHigh = BitConverter.ToInt32(inBuf, 30 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 12);
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{
tempUserId = new WinUserIdentifier(luidLow, luidHigh);
SecretStore ss = SessionManager.CreateUserSession(tempUserId);
try
{
ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0"));
}
catch (Exception)
{
}
}
else
{
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.CheckIfKeyChainExists(keyChainId))
{
try
{
KeyChain newKeyChain = new KeyChain(keyChainId);
ssStore.AddKeyChain(newKeyChain);
}
catch (Exception e)
{
CSSSLogger.DbgLog("WriteKey: Adding keychain returned error: " + e.ToString());
}
}
}
}
#endif
try
{
KeyChain keyChain = null;
@ -208,22 +208,22 @@ namespace sscs.verbs
(ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME == key)
)
{
KeyValue kvDesktop = secret.GetKeyValue(ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME);
if (null != kvDesktop)
KeyValue kvDesktop = secret.GetKeyValue(ConstStrings.MICASA_DESKTOP_PASSWD_KEYNAME);
if (null != kvDesktop)
oldPasswd = kvDesktop.GetValue();
}
secret.SetKeyValue(key,val);
KeyValue kv = secret.GetKeyValue(key);
if ((ssFlags & SSFLAGS.FLAG_DO_NOT_PERSIST) == SSFLAGS.FLAG_DO_NOT_PERSIST)
{
kv.IsPersistent = false;
}
else
{
kv.IsPersistent = true;
}
secret.SetKeyValue(key,val);
KeyValue kv = secret.GetKeyValue(key);
if ((ssFlags & SSFLAGS.FLAG_DO_NOT_PERSIST) == SSFLAGS.FLAG_DO_NOT_PERSIST)
{
kv.IsPersistent = false;
}
else
{
kv.IsPersistent = true;
}
if((ConstStrings.MICASA_DESKTOP_PASSWD == secretId) &&
@ -257,7 +257,7 @@ namespace sscs.verbs
}
}
else
{
{
retCode = IPCRetCodes.SSCS_SECRET_STORE_IS_LOCKED;
}

View File

@ -118,7 +118,7 @@ namespace sscs.verbs
valLen = BitConverter.ToUInt32(inBuf,(18+(int)keyChainIdLen+(int)secretIdLen+(int)keyLen));
val = new byte[valLen];
Array.Copy(inBuf,(22+keyChainIdLen+secretIdLen+keyLen),val,0,valLen);
valStr = Encoding.UTF8.GetString(val);
valStr = Encoding.UTF8.GetString(val);
CSSSLogger.DbgLog("Writing Secret:Key [" + secretId + ":" + key + "]");
@ -130,13 +130,13 @@ namespace sscs.verbs
}
catch (Exception)
{
//CSSSLogger.ExpLog(e.ToString());
}
#if W32
//CSSSLogger.ExpLog(e.ToString());
}
#if W32
if (extId == 1)
{
{
CSSSLogger.DbgLog("LUID ExtID found");
// WINDOWS LUID
@ -144,47 +144,47 @@ namespace sscs.verbs
// we might be able to change this if/when we abstract the session.
// [4 byte extID][4 byte length][4 byte luidLow][4 byte luidHigh]
luidLow = BitConverter.ToInt32(inBuf, 26 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 8);
luidHigh = BitConverter.ToInt32(inBuf, 26 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 12);
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{
tempUserId = new WinUserIdentifier(luidLow, luidHigh);
SecretStore ss = SessionManager.CreateUserSession(tempUserId);
CSSSLogger.DbgLog("Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
try
{
ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0"));
}
catch (Exception)
{
}
}
else
{
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.CheckIfKeyChainExists(keyChainId))
{
try
{
KeyChain newKeyChain = new KeyChain(keyChainId);
ssStore.AddKeyChain(newKeyChain);
}
catch (Exception e)
{
CSSSLogger.DbgLog("WriteKey: Adding keychain returned error: " + e.ToString());
}
}
}
}
#endif
luidHigh = BitConverter.ToInt32(inBuf, 26 + ((int)keyChainIdLen)+((int)secretIdLen) +((int)keyLen) + (int)valLen + 12);
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{
tempUserId = new WinUserIdentifier(luidLow, luidHigh);
SecretStore ss = SessionManager.CreateUserSession(tempUserId);
CSSSLogger.DbgLog("Switching LUID to [" + luidHigh.ToString() + "][" + luidLow.ToString() + "]");
try
{
ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0"));
}
catch (Exception)
{
}
}
else
{
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.CheckIfKeyChainExists(keyChainId))
{
try
{
KeyChain newKeyChain = new KeyChain(keyChainId);
ssStore.AddKeyChain(newKeyChain);
}
catch (Exception e)
{
CSSSLogger.DbgLog("WriteKey: Adding keychain returned error: " + e.ToString());
}
}
}
}
#endif
if (secretId.Length < 1 || key.Length < 1 || valStr.Length < 1)
{
CSSSLogger.DbgLog("Error in length");
@ -204,24 +204,24 @@ namespace sscs.verbs
if( ssStore.CheckIfKeyChainExists(keyChainId) )
{
keyChain = ssStore.GetKeyChain(keyChainId);
Secret secret = null;
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{
secret = ssStore.GetDesktopSecret();
}
else
{
// add this secret if it doesn't already exist
if (keyChain.CheckIfSecretExists(secretId) == false)
{
secret = new Secret(secretId);
keyChain.AddSecret(secret);
}
else
{
secret = keyChain.GetSecret(secretId);
}
Secret secret = null;
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{
secret = ssStore.GetDesktopSecret();
}
else
{
// add this secret if it doesn't already exist
if (keyChain.CheckIfSecretExists(secretId) == false)
{
secret = new Secret(secretId);
keyChain.AddSecret(secret);
}
else
{
secret = keyChain.GetSecret(secretId);
}
}
string oldPasswd = null;

View File

@ -120,10 +120,10 @@ namespace sscs.verbs
}
catch (Exception)
{
//CSSSLogger.ExpLog(e.ToString());
}
#if W32
//CSSSLogger.ExpLog(e.ToString());
}
#if W32
if (extId == 1)
{
// WINDOWS LUID
@ -131,43 +131,43 @@ namespace sscs.verbs
// we might be able to change this if/when we abstract the session.
// [4 byte extID][4 byte length][4 byte luidLow][4 byte luidHigh]
luidLow = BitConverter.ToInt32(inBuf, 22 + ((int)keyChainIdLen)+((int)secretIdLen) +(int)secretValLen + 8);
luidHigh = BitConverter.ToInt32(inBuf, 22 + ((int)keyChainIdLen)+((int)secretIdLen) +(int)secretValLen + 12);
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{
tempUserId = new WinUserIdentifier(luidLow, luidHigh);
SecretStore ss = SessionManager.CreateUserSession(tempUserId);
try
{
ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0"));
}
catch (Exception)
{
}
}
else
{
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.CheckIfKeyChainExists(keyChainId))
{
try
{
KeyChain newKeyChain = new KeyChain(keyChainId);
ssStore.AddKeyChain(newKeyChain);
}
catch (Exception e)
{
CSSSLogger.DbgLog("WriteSecret: Adding keychain returned error: " + e.ToString());
}
}
}
}
#endif
luidHigh = BitConverter.ToInt32(inBuf, 22 + ((int)keyChainIdLen)+((int)secretIdLen) +(int)secretValLen + 12);
if (ConstStrings.MICASA_DESKTOP_PASSWD == secretId)
{
tempUserId = new WinUserIdentifier(luidLow, luidHigh);
SecretStore ss = SessionManager.CreateUserSession(tempUserId);
try
{
ss.AddKeyChain(new KeyChain("SSCS_SESSION_KEY_CHAIN_ID\0"));
}
catch (Exception)
{
}
}
else
{
// this code is for ZEN. Here we switch to a keychain who's ID is the LUID of the user logging in.
// ZEN processes run as system and pass the LUID in the extension parameter.
keyChainId = luidHigh.ToString() + luidLow.ToString();
SecretStore ssStore = SessionManager.GetUserSecretStore(tempUserId);
if (!ssStore.CheckIfKeyChainExists(keyChainId))
{
try
{
KeyChain newKeyChain = new KeyChain(keyChainId);
ssStore.AddKeyChain(newKeyChain);
}
catch (Exception e)
{
CSSSLogger.DbgLog("WriteSecret: Adding keychain returned error: " + e.ToString());
}
}
}
}
#endif
try
{