major source structure and module name changes

This commit is contained in:
soochoi
2006-06-07 16:34:19 +00:00
parent 5c75241b4b
commit 1fa6f07e83
651 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
using System;
using System.Net;
using System.Net.Sockets;
//using sscs.communication.win.NamedPipes;
namespace Novell.CASA.MiCasa.Communication
{
public interface ClientChannel
{
void Open();
int Read(byte[] buf);
byte[] Read();
int Write(byte[] buf);
void Close();
}
}

View File

@@ -0,0 +1,50 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
using System;
namespace Novell.CASA.MiCasa.Communication
{
/// <summary>
/// Summary description for IPCClientFactory.
/// </summary>
public class IPCClientFactory
{
private IPCClientFactory()
{
}
public static ClientChannel CreateClientConnection()
{
#if LINUX
return( new UnixIPCClientChannel());
#endif
#if W32
return (new WinIPCClientChannel());
#endif
}
}
}

View File

@@ -0,0 +1,36 @@
#######################################################################
#
# Copyright (C) 2006 Novell, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#######################################################################
SUBDIRS =
DIST_SUBDIRS =
CFILES =
EXTRA_DIST = $(CSFILES)
.PHONY: package package-clean package-install package-uninstall
package package-clean package-install package-uninstall:
$(MAKE) -C $(TARGET_OS) $@
maintainer-clean-local:
rm -f Makefile.in

View File

@@ -0,0 +1,185 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
using System;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using Novell.CASA.MiCasa.Common;
namespace Novell.CASA.MiCasa.Communication
{
/// <summary>
/// Summary description for MiCasaRequestReply.
/// </summary>
public class MiCasaRequestReply
{
//public const int VERB_GET_SECRET = 1;
//public const int VERB_SET_SECRET = 2;
//public const int VERB_GET_KEYCHAIN = 3;
//public const int VERB_GET_STORE = 4;
//public const int VERB_SET_KEYVALUE = 5;
//public const int VERB_GET_KEYVALUE = 6;
public const int VERB_SET_LINKED_KEY = 7;
public const int VERB_GET_LINKED_KEYS = 8;
public const int VERB_REMOVE_LINKED_KEY = 9;
public const int VERB_WRITE_KEY = 10;
public const int VERB_REMOVE_ALL_SECRETS = 11;
public const int VERB_LOCK_STORE = 12;
public const int VERB_UNLOCK_STORE = 13;
public const int VERB_GET_STORE_STATUS = 14;
public const int VERB_REMOVE_KEY = 15;
public const int VERB_READ_KEY = 16;
public const int VERB_GET_KEY_LIST = 17;
public const int VERB_RESET_MASTER_PASSWORD = 18;
public const int VERB_GET_SECRETIDS = 19;
public const int VERB_VALIDATE_DESKTOP_PWD = 20;
public const int VERB_DUMP_LINKED_KEYS = 96;
public const int VERB_CREATE_TEST_SECRETS = 97;
public const int VERB_REMOVE_TEST_SECRETS = 98;
public const int VERB_PING_MICASAD = 99;
public MiCasaRequestReply()
{
//
// TODO: Add constructor logic here
//
}
public static object Send(int verb)
{
return Send(verb, null, null, null, null);
}
public static object Send(int verb, object wo)
{
return Send(verb, null, null, null, wo);
}
public static object Send(int verb,
string sKeyChainID,
string sSecretID,
string sKeyID,
object theObject)
{
// Lengths of message fields
int MSGID_LEN = 2;
int MSG_LEN = 4;
WrappedObject request;
WrappedObject reply = null;
// open a client connection
//IInterProcessConnection clientConnection = null;
ClientChannel ipcChannel = IPCClientFactory.CreateClientConnection();
ipcChannel.Open();
try
{
// contruct and serialize the Message Object
request = new WrappedObject(verb, sKeyChainID, sSecretID, sKeyID, theObject);
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
formatter.Serialize(ms, request);
ms.Flush();
ms.Position = 0;
byte[] rawBytes = new byte[2+4+ms.Length];
byte[] t = new byte[10];
// set message id
int destIndex = 0;
ushort msgId = 20;
t = BitConverter.GetBytes((ushort)msgId);
Array.Copy(t,0,rawBytes,destIndex,MSGID_LEN);
destIndex += MSGID_LEN;
// set the object length
//Poorna
int msgLen = 2+4+(int)ms.Length;
// int msgLen = (int)ms.Length;
t = BitConverter.GetBytes(msgLen);
// t = BitConverter.GetBytes(ms.Length);
Array.Copy(t,0,rawBytes,destIndex,MSG_LEN);
destIndex += MSG_LEN;
// copy in the object
Array.Copy(ms.GetBuffer(), 0, rawBytes, destIndex, ms.Length);
//clientConnection = new ClientPipeConnection("MyPipe", ".");
//clientConnection = new ClientPipeConnection(XTIER_RPC_PIPE, ".");
//clientConnection.Connect();
// write the bytes
//clientConnection.WriteBytes(rawBytes);
ipcChannel.Write(rawBytes);
// read the bytes
//byte[] returnBuffer = clientConnection.ReadBytes();
byte[] returnBuffer = ipcChannel.Read();
if (returnBuffer != null)
{
// deserialize MessageObject
uint iMsgLen = BitConverter.ToUInt32(returnBuffer,0);
ms = new MemoryStream(returnBuffer, 4, (int)iMsgLen);
ms.Position = 0;
reply = (WrappedObject)formatter.Deserialize(ms);
if (reply.GetReturnCode() != 0)
{
ipcChannel.Close();
throw new Exception(reply.GetReturnCode().ToString());
}
}
// close the connection
//clientConnection.Close();
ipcChannel.Close();
}
catch (Exception e1)
{
//Console.WriteLine(e1.ToString());
//clientConnection.Dispose();
//throw new Exception(e1.ToString());
}
if (reply != null)
return reply.GetObject();
else
return null;
}
}
}

View File

@@ -0,0 +1,178 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
using System;
using System.Net;
using System.IO;
using System.Net.Sockets;
using Mono.Unix;
using System.Text;
namespace Novell.CASA.MiCasa.Communication
{
/// <summary>
/// Summary description for UnixIPCClientChannel.
/// </summary>
public class UnixIPCClientChannel : ClientChannel
{
private Socket mSocket = null;
private string socketFileName = "/tmp/.novellCASA";
private EndPoint sockEndPoint;
public UnixIPCClientChannel()
{
}
public void Open()
{
mSocket = new Socket( AddressFamily.Unix,
SocketType.Stream,
ProtocolType.IP );
if (mSocket == null)
{
throw new Exception("could not get socket");
}
sockEndPoint = new UnixEndPoint(socketFileName);
UnixFileSystemInfo sockFileInfo = new UnixFileInfo(socketFileName);
UnixUserInfo sockFileOwner = sockFileInfo.OwnerUser;
// root is the owner of the file "/tmp/.novellCASA"
if (sockFileOwner.UserId == 0)
{
mSocket.Connect(sockEndPoint);
}
else
{
throw new Exception("not a valid miCASA service");
}
}
public int Read(byte[] buf)
{
buf = Read();
if (buf != null)
{
//Console.WriteLine("Bytes read = " + buf.Length);
return buf.Length;
}
else
return 0;
}
public byte[] Read()
{
byte[] returnBuffer = null;
int bytesRecvd = 0;
try
{
/* We need to read 'msgLen' to know how many bytes to
* allocate.
*/
byte[] msgIdBytes = new byte[2];
bytesRecvd = mSocket.Receive(msgIdBytes);
if( 0 == bytesRecvd )
{
return null;
}
byte[] msgLenBytes = new byte[4];
bytesRecvd = mSocket.Receive(msgLenBytes);
if( 0 == bytesRecvd )
{
return null;
}
uint msgLen = BitConverter.ToUInt32(msgLenBytes,0);
if( msgLen > 6 )
{
System.Text.Encoding encoding = System.Text.Encoding.ASCII;
byte[] buf = null;
int bytesAvailable;
int totalBytes = 0;
int msgLencount = 0;
string bufstring = null;
byte[] temp = null;
while(totalBytes<(msgLen-6))
{
bytesAvailable = mSocket.Available;
if( 0 == bytesAvailable)
{
break;
}
buf = new byte[bytesAvailable];
bytesRecvd = mSocket.Receive (buf);
bufstring = bufstring + encoding.GetString(buf); //keep buffering in a string
totalBytes = totalBytes + bytesAvailable;
}
if(totalBytes==0)
return null;
byte[] finalbuf = encoding.GetBytes(bufstring);//finally, convert the string to a byte array of size 'totalBytes'
int returnBufferLen = msgIdBytes.Length+msgLenBytes.Length+totalBytes;
returnBuffer = new byte[returnBufferLen];
Array.Copy(msgIdBytes,returnBuffer,2);
Array.Copy(msgLenBytes,0,returnBuffer,2,4);
Array.Copy(finalbuf,0,returnBuffer,6,finalbuf.Length);
return returnBuffer;
}
else
{
returnBuffer = new byte[6];
Array.Copy(msgIdBytes,returnBuffer,2);
Array.Copy(msgLenBytes,0,returnBuffer,2,4);
return returnBuffer;
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return null;
}
}
public int Write(byte[] buf)
{
try
{
mSocket.Send(buf);
//Console.WriteLine("Bytes written = " + buf.Length);
return buf.Length;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return 0;
}
}
public void Close()
{
mSocket.Close();
}
}
}

View File

@@ -0,0 +1,103 @@
/***********************************************************************
*
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail,
* you may find current contact information at www.novell.com.
*
***********************************************************************/
using System;
using AppModule.InterProcessComm;
using AppModule.NamedPipes;
namespace Novell.CASA.MiCasa.Communication
{
/// <summary>
/// Summary description for WinIPCClientChannel.
/// </summary>
public class WinIPCClientChannel : ClientChannel
{
private static IInterProcessConnection clientConnection = null;
private static string XTIER_RPC_PIPE = "SS_RPC_PIPE";
public WinIPCClientChannel()
{
}
public void Open()
{
if (clientConnection == null)
{
clientConnection = new ClientPipeConnection(XTIER_RPC_PIPE, ".");
clientConnection.Connect();
}
}
public int Read(byte[] buf)
{
buf = Read();
if (buf != null)
return 0;
else
return -1;
}
public byte[] Read()
{
byte[] returnBuffer;
try
{
returnBuffer = clientConnection.ReadBytes();
return returnBuffer;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return null;
}
}
public int Write(byte[] buf)
{
try
{
clientConnection.WriteBytes(buf);
return 0;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return -1;
}
}
public void Close()
{
//clientConnection.Close();
//clientConnection.Dispose();
}
}
}