Moving micasa 1.5 trunk to Novell forge.
This commit is contained in:
102
c_policy/AggregationPol.cs
Normal file
102
c_policy/AggregationPol.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
namespace Novell.CASA.CASAPolicy
|
||||
{
|
||||
public class Store
|
||||
{
|
||||
string storeName;
|
||||
public string StoreName
|
||||
{
|
||||
get
|
||||
{
|
||||
return storeName;
|
||||
}
|
||||
set
|
||||
{
|
||||
storeName = value;
|
||||
}
|
||||
}
|
||||
string storeId;
|
||||
public string StoreId
|
||||
{
|
||||
get
|
||||
{
|
||||
return storeId;
|
||||
}
|
||||
set
|
||||
{
|
||||
storeId = value;
|
||||
}
|
||||
}
|
||||
public Store(string name,string id)
|
||||
{
|
||||
storeId = id;
|
||||
storeName = name;
|
||||
}
|
||||
}
|
||||
|
||||
public class AggregationPol : CASAPol
|
||||
{
|
||||
ArrayList storeList;
|
||||
public ArrayList StoreList
|
||||
{
|
||||
get
|
||||
{
|
||||
return storeList;
|
||||
}
|
||||
}
|
||||
public AggregationPol(ArrayList stores)
|
||||
{
|
||||
policyType = CASAPolType.AGGREGATION_POL;
|
||||
storeList = stores;
|
||||
}
|
||||
|
||||
public override void DumpPol()
|
||||
{
|
||||
Console.WriteLine("\nAggregation Policy");
|
||||
IEnumerator enumerator = storeList.GetEnumerator();
|
||||
while(enumerator.MoveNext())
|
||||
{
|
||||
Console.WriteLine("StoreName = " + ((Store)(enumerator.Current)).StoreName + " StoreId = " + ((Store)(enumerator.Current)).StoreId);
|
||||
}
|
||||
}
|
||||
|
||||
internal override void AppendToDoc(XmlDocument doc)
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlElement storeElem;
|
||||
XmlAttribute storeNameAttr;
|
||||
XmlAttribute storeIdAttr;
|
||||
string xPath = "";
|
||||
|
||||
xPath = "//" + XmlConsts.CASAPolicyNode;
|
||||
XmlNode rootElem = doc.SelectSingleNode(xPath);
|
||||
|
||||
XmlElement aggPolElem = doc.CreateElement(XmlConsts.AggregationPolicyNode);
|
||||
rootElem.AppendChild(aggPolElem);
|
||||
|
||||
IEnumerator enumerator = storeList.GetEnumerator();
|
||||
while(enumerator.MoveNext())
|
||||
{
|
||||
storeElem = doc.CreateElement(XmlConsts.StoreAttr);
|
||||
storeNameAttr = doc.CreateAttribute(XmlConsts.StoreNameAttr);
|
||||
storeNameAttr.Value = ((Store)(enumerator.Current)).StoreName;
|
||||
storeElem.SetAttributeNode(storeNameAttr);
|
||||
|
||||
storeIdAttr = doc.CreateAttribute(XmlConsts.StoreIdAttr);
|
||||
storeIdAttr.Value = ((Store)(enumerator.Current)).StoreId;
|
||||
storeElem.SetAttributeNode(storeIdAttr);
|
||||
|
||||
aggPolElem.AppendChild(storeElem);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
c_policy/Makefile
Normal file
20
c_policy/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# configure environment
|
||||
#
|
||||
TARGET = Novell.CASA.CASAPolicy
|
||||
CS_NAME = $(TARGET)$(xtra).$(CSH)
|
||||
include global.mak
|
||||
include defaults.$(PLAT)
|
||||
include rules.mak
|
||||
|
||||
|
||||
#
|
||||
# target object and source files
|
||||
#
|
||||
include src.$(PLAT)
|
||||
include objs.$(PLAT)
|
||||
|
||||
#
|
||||
# targets
|
||||
#
|
||||
include target.cs
|
||||
130
c_policy/Novell.CASA.CASAPolicy.csproj
Normal file
130
c_policy/Novell.CASA.CASAPolicy.csproj
Normal file
@@ -0,0 +1,130 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.10.3077"
|
||||
SchemaVersion = "2.0"
|
||||
ProjectGuid = "{636A9D7E-BFB5-4EB9-96F8-51FF85A98826}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "Novell.CASA.CASAPol"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "Library"
|
||||
PreBuildEvent = ""
|
||||
PostBuildEvent = ""
|
||||
RootNamespace = "Novell.CASA.CASAPol"
|
||||
RunPostBuildEvent = "OnBuildSuccess"
|
||||
StartupObject = ""
|
||||
>
|
||||
<Config
|
||||
Name = "Debug"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "DEBUG;TRACE"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "true"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = ""
|
||||
Optimize = "false"
|
||||
OutputPath = "bin\Debug\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "TRACE"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "false"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = ""
|
||||
Optimize = "true"
|
||||
OutputPath = "bin\Release\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.XML"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
|
||||
/>
|
||||
</References>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AggregationPol.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "PersistencePol.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Policy.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "PolicyConstants.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "PolicyImpl.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "SynchPol.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Test.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "UIPol.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
48
c_policy/Novell.CASA.CASAPolicy.csproj.user
Normal file
48
c_policy/Novell.CASA.CASAPolicy.csproj.user
Normal file
@@ -0,0 +1,48 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP LastOpenVersion = "7.10.3077" >
|
||||
<Build>
|
||||
<Settings ReferencePath = "" >
|
||||
<Config
|
||||
Name = "Debug"
|
||||
EnableASPDebugging = "false"
|
||||
EnableASPXDebugging = "false"
|
||||
EnableUnmanagedDebugging = "false"
|
||||
EnableSQLServerDebugging = "false"
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartPage = ""
|
||||
StartProgram = ""
|
||||
StartURL = ""
|
||||
StartWorkingDirectory = ""
|
||||
StartWithIE = "true"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
EnableASPDebugging = "false"
|
||||
EnableASPXDebugging = "false"
|
||||
EnableUnmanagedDebugging = "false"
|
||||
EnableSQLServerDebugging = "false"
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartPage = ""
|
||||
StartProgram = ""
|
||||
StartURL = ""
|
||||
StartWorkingDirectory = ""
|
||||
StartWithIE = "true"
|
||||
/>
|
||||
</Settings>
|
||||
</Build>
|
||||
<OtherProjectSettings
|
||||
CopyProjectDestinationFolder = ""
|
||||
CopyProjectUncPath = ""
|
||||
CopyProjectOption = "0"
|
||||
ProjectView = "ProjectFiles"
|
||||
ProjectTrust = "0"
|
||||
/>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
83
c_policy/PersistencePol.cs
Normal file
83
c_policy/PersistencePol.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Novell.CASA.CASAPolicy
|
||||
{
|
||||
public class PersistencePol : CASAPol
|
||||
{
|
||||
string os;
|
||||
public string OS
|
||||
{
|
||||
get
|
||||
{
|
||||
return os;
|
||||
}
|
||||
}
|
||||
string filePath;
|
||||
public string FilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
int pollInterval;
|
||||
public int PollInterval
|
||||
{
|
||||
get
|
||||
{
|
||||
return pollInterval;
|
||||
}
|
||||
}
|
||||
|
||||
public PersistencePol(string osName,string path, int time)
|
||||
{
|
||||
policyType = CASAPolType.PERSISTENCE_POL;
|
||||
os = osName;
|
||||
filePath = path;
|
||||
pollInterval = time;
|
||||
}
|
||||
|
||||
public override void DumpPol()
|
||||
{
|
||||
Console.WriteLine("\nPersistent Policy");
|
||||
Console.WriteLine("os = " + os);
|
||||
Console.WriteLine("filePath = " + filePath);
|
||||
Console.WriteLine("pollInterval = " + pollInterval);
|
||||
}
|
||||
internal override void AppendToDoc(XmlDocument doc)
|
||||
{
|
||||
XmlElement elem;
|
||||
XmlAttribute attr;
|
||||
string xPath = "";
|
||||
try
|
||||
{
|
||||
xPath = "//" + XmlConsts.CASAPolicyNode;
|
||||
XmlNode rootElem = doc.SelectSingleNode(xPath);
|
||||
|
||||
XmlElement persistPolElem = doc.CreateElement(XmlConsts.PersistencePolicyNode);
|
||||
rootElem.AppendChild(persistPolElem);
|
||||
|
||||
elem = doc.CreateElement(XmlConsts.StoreFileLocationAttr);
|
||||
elem.InnerText = filePath;
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.OSAttr);
|
||||
attr.Value = os;
|
||||
elem.SetAttributeNode(attr);
|
||||
|
||||
persistPolElem.AppendChild(elem);
|
||||
|
||||
elem = doc.CreateElement(XmlConsts.PollIntervalNode);
|
||||
elem.InnerText = pollInterval.ToString();
|
||||
|
||||
persistPolElem.AppendChild(elem);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
c_policy/Policy.cs
Normal file
29
c_policy/Policy.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Novell.CASA.CASAPolicy
|
||||
{
|
||||
public enum CASAPolType
|
||||
{
|
||||
AGGREGATION_POL = 1,
|
||||
PERSISTENCE_POL,
|
||||
UI_POL,
|
||||
SYNCH_POL
|
||||
}
|
||||
|
||||
public abstract class CASAPol
|
||||
{
|
||||
protected CASAPolType policyType;
|
||||
public CASAPolType PolicyType
|
||||
{
|
||||
get
|
||||
{
|
||||
return policyType;
|
||||
}
|
||||
}
|
||||
abstract internal void AppendToDoc(XmlDocument doc);
|
||||
abstract public void DumpPol();
|
||||
}
|
||||
}
|
||||
37
c_policy/PolicyConstants.cs
Normal file
37
c_policy/PolicyConstants.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
namespace Novell.CASA.CASAPolicy
|
||||
{
|
||||
class XmlConsts
|
||||
{
|
||||
internal static string policyFileName = "/.CASAPolicy.xml";
|
||||
internal static string MicasaStoreName = "miCASA";
|
||||
internal static string KwalletStoreName = "Kwallet";
|
||||
internal static string GnomeKeyringStoreName = "Gnome-Keyring";
|
||||
internal static string FirefoxStoreName = "Firefox";
|
||||
internal static string MozillaStoreName = "Mozilla";
|
||||
|
||||
internal static string CASAPolicyNode = "CASAPolicy";
|
||||
internal static string AggregationPolicyNode = "AggregationPolicy";
|
||||
internal static string PersistencePolicyNode = "PersistencePolicy";
|
||||
internal static string UIPolicyNode = "UIPolicy";
|
||||
internal static string SynchPolicyNode = "SynchPolicy";
|
||||
internal static string StoreAttr = "Store";
|
||||
internal static string StoreNameAttr = "StoreName";
|
||||
internal static string StoreIdAttr = "StoreId";
|
||||
internal static string FolderIdAttr = "FolderId";
|
||||
internal static string SecretIdAttr = "SecretId";
|
||||
internal static string KeyAttr = "Key";
|
||||
internal static string StoreFileLocationAttr = "StoreFileLocation";
|
||||
internal static string OSAttr = "OS";
|
||||
internal static string PollIntervalNode = "PollInterval";
|
||||
internal static string ShowInTaskBarAttr = "ShowInTaskBar";
|
||||
internal static string ShowSecretValueAttr = "ShowSecretValue";
|
||||
internal static string ShowSecretInClearTextAttr = "ShowSecretInClearText";
|
||||
internal static string SynchEngineStartModeNode = "SynchEngineStartMode";
|
||||
internal static string LinkKeyNode = "LinkKey";
|
||||
internal static string LinkNode = "Link";
|
||||
internal static string LinkGroupNode = "LinkGroup";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
387
c_policy/PolicyImpl.cs
Normal file
387
c_policy/PolicyImpl.cs
Normal file
@@ -0,0 +1,387 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Novell.CASA.CASAPolicy
|
||||
{
|
||||
public class ICASAPol
|
||||
{
|
||||
static string GetPolicyFilePath()
|
||||
{
|
||||
try
|
||||
{
|
||||
/* There needs to be a better way to get the HOME dir,
|
||||
* if this is used by miCASAd(as it runs as root).
|
||||
*/
|
||||
|
||||
int platform = (int)Environment.OSVersion.Platform;
|
||||
string homeDir;
|
||||
|
||||
if ( (platform == 128) || ( platform == 4) )
|
||||
{
|
||||
homeDir = System.Environment.GetEnvironmentVariable("HOME");
|
||||
}
|
||||
else
|
||||
{
|
||||
homeDir = (System.Environment.GetEnvironmentVariable("USERPROFILE"));
|
||||
}
|
||||
|
||||
string path = homeDir + XmlConsts.policyFileName;
|
||||
return path;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
static public CASAPol[] GetPolicies()
|
||||
{
|
||||
try
|
||||
{
|
||||
if(!File.Exists(GetPolicyFilePath()))
|
||||
return null;
|
||||
CASAPol[] policies = new CASAPol[4];
|
||||
policies[0] = GetPolicy(CASAPolType.AGGREGATION_POL);
|
||||
policies[1] = GetPolicy(CASAPolType.PERSISTENCE_POL);
|
||||
policies[2] = GetPolicy(CASAPolType.UI_POL);
|
||||
policies[3] = GetPolicy(CASAPolType.SYNCH_POL);
|
||||
return policies;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static public bool SetPolicies(CASAPol[] polList)
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
|
||||
XmlElement rootElem = doc.CreateElement(XmlConsts.CASAPolicyNode);
|
||||
doc.AppendChild(rootElem);
|
||||
for(int i = 0; i < polList.Length; i++)
|
||||
{
|
||||
if(polList[i] != null)
|
||||
polList[i].AppendToDoc(doc);
|
||||
}
|
||||
/*
|
||||
FileStream fs = new FileStream(GetPolicyFilePath(),FileMode.Create);
|
||||
XmlTextWriter writer = new XmlTextWriter(fs,null);
|
||||
writer.Formatting = Formatting.Indented;
|
||||
doc.Save(writer);
|
||||
fs.Close();
|
||||
writer.Close();
|
||||
*/
|
||||
XmlTextWriter writer = new XmlTextWriter(GetPolicyFilePath(),null);
|
||||
writer.Formatting = Formatting.Indented;
|
||||
doc.Save(writer);
|
||||
writer.Close();
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static private AggregationPol GetAggPol(XmlDocument doc)
|
||||
{
|
||||
string xpath = "";
|
||||
try
|
||||
{
|
||||
xpath = "//" + XmlConsts.AggregationPolicyNode;
|
||||
XmlNode aggNode = doc.SelectSingleNode(xpath);
|
||||
Store store = null;
|
||||
ArrayList storeList = new ArrayList();
|
||||
if( null != aggNode )
|
||||
{
|
||||
XmlNodeList storeNodeList = aggNode.SelectNodes("descendant::Store");
|
||||
foreach( XmlNode node in storeNodeList )
|
||||
{
|
||||
XmlAttributeCollection attrList = node.Attributes;
|
||||
string storeName = (attrList[XmlConsts.StoreNameAttr]).Value;
|
||||
|
||||
attrList = node.Attributes;
|
||||
string storeId = (attrList[XmlConsts.StoreIdAttr]).Value;
|
||||
store = new Store(storeName, storeId);
|
||||
|
||||
storeList.Add(store);
|
||||
}
|
||||
AggregationPol aggPol = new AggregationPol(storeList);
|
||||
return aggPol;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
static private PersistencePol GetPersistencePol(XmlDocument doc)
|
||||
{
|
||||
string xpath = "";
|
||||
try
|
||||
{
|
||||
xpath = "//" + XmlConsts.PersistencePolicyNode;
|
||||
XmlNode persistenceNode = doc.SelectSingleNode(xpath);
|
||||
if( null != persistenceNode )
|
||||
{
|
||||
xpath = "//" + XmlConsts.StoreFileLocationAttr;
|
||||
XmlNode storeFileLocationNode = persistenceNode.SelectSingleNode(xpath);
|
||||
string storeFileLocation = storeFileLocationNode.InnerText;
|
||||
|
||||
XmlAttributeCollection attrColl = storeFileLocationNode.Attributes;
|
||||
string os = (attrColl[XmlConsts.OSAttr]).Value;
|
||||
|
||||
xpath = "//" + XmlConsts.PollIntervalNode;
|
||||
XmlNode pollIntervalNode = persistenceNode.SelectSingleNode(xpath);
|
||||
int pollInterval = Convert.ToInt32(pollIntervalNode.InnerText);
|
||||
|
||||
PersistencePol persistencePol = new PersistencePol(os,storeFileLocation, pollInterval);
|
||||
return persistencePol;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
static private UIPol GetUIPol(XmlDocument doc)
|
||||
{
|
||||
string xpath = "";
|
||||
try
|
||||
{
|
||||
xpath = "//" + XmlConsts.UIPolicyNode;
|
||||
XmlNode uiNode = doc.SelectSingleNode(xpath);
|
||||
if( null != uiNode )
|
||||
{
|
||||
XmlAttributeCollection attrColl = uiNode.Attributes;
|
||||
bool showInTaskBar = Convert.ToBoolean((attrColl[XmlConsts.ShowInTaskBarAttr]).Value);
|
||||
bool showSecretValue = Convert.ToBoolean((attrColl[XmlConsts.ShowSecretValueAttr]).Value);
|
||||
bool showSecretInClearText = Convert.ToBoolean((attrColl[XmlConsts.ShowSecretInClearTextAttr]).Value);
|
||||
|
||||
xpath = "//" + XmlConsts.SynchEngineStartModeNode;
|
||||
|
||||
XmlNode modeNode = uiNode.SelectSingleNode(xpath);
|
||||
string mode = modeNode.InnerText;
|
||||
|
||||
UIPol uiPol = new UIPol(showInTaskBar, showSecretValue, showSecretInClearText, mode);
|
||||
return uiPol;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static private SynchPol GetSynchPol(XmlDocument doc)
|
||||
{
|
||||
SynchPol synchPol = null;
|
||||
ArrayList linkGrpList = new ArrayList();
|
||||
ArrayList linksList = new ArrayList();
|
||||
ArrayList linkKeyList;// = new ArrayList();
|
||||
LinkKey linkKey = null;
|
||||
Link link = null;
|
||||
LinkGroup linkGrp = null;
|
||||
try
|
||||
{
|
||||
XmlNode synchNode = doc.SelectSingleNode("//SynchPolicy");
|
||||
if( null != synchNode )
|
||||
{
|
||||
XmlNodeList grpNodeList = synchNode.SelectNodes("descendant::LinkGroup");
|
||||
foreach( XmlNode node in grpNodeList )
|
||||
{
|
||||
XmlNodeList linkNodeList = node.SelectNodes("descendant::Link");
|
||||
foreach( XmlNode linkNode in linkNodeList )
|
||||
{
|
||||
XmlNodeList linkKeyNodeList = linkNode.SelectNodes("descendant::LinkKey");
|
||||
linkKeyList = new ArrayList();
|
||||
foreach( XmlNode linkKeyNode in linkKeyNodeList )
|
||||
{
|
||||
linkKey = GetLinkKey(linkKeyNode);
|
||||
linkKeyList.Add(linkKey);
|
||||
}
|
||||
link = new Link(linkKeyList);
|
||||
linksList.Add(link);
|
||||
}//end of linkNodeList loop
|
||||
linkGrp = new LinkGroup(linksList);
|
||||
linkGrpList.Add(linkGrp);
|
||||
}//end of grpNodeList loop
|
||||
synchPol = new SynchPol(linkGrpList);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
return synchPol;
|
||||
}
|
||||
|
||||
static private LinkKey GetLinkKey(XmlNode keyNode)
|
||||
{
|
||||
LinkKey linkKey = null;
|
||||
try
|
||||
{
|
||||
XmlAttributeCollection attrList = keyNode.Attributes;
|
||||
|
||||
string storeName = (attrList[XmlConsts.StoreNameAttr]).Value;
|
||||
string storeId = (attrList[XmlConsts.StoreIdAttr]).Value;
|
||||
string secretId = (attrList[XmlConsts.SecretIdAttr]).Value;
|
||||
string keyId = (attrList[XmlConsts.KeyAttr]).Value;
|
||||
string folderId;
|
||||
if(storeName == XmlConsts.KwalletStoreName)
|
||||
{
|
||||
folderId = (attrList[XmlConsts.FolderIdAttr]).Value;
|
||||
linkKey = new KWLinkKey(storeId,folderId,secretId,keyId);
|
||||
}
|
||||
else if(storeName == XmlConsts.GnomeKeyringStoreName)
|
||||
{
|
||||
linkKey = new GKLinkKey(storeId,secretId,keyId);
|
||||
}
|
||||
else if(storeName == XmlConsts.MozillaStoreName)
|
||||
{
|
||||
linkKey = new MZLinkKey(storeId,secretId,keyId);
|
||||
}
|
||||
else if(storeName == XmlConsts.FirefoxStoreName)
|
||||
{
|
||||
linkKey = new FXLinkKey(storeId,secretId,keyId);
|
||||
}
|
||||
else if(storeName == XmlConsts.MicasaStoreName)
|
||||
{
|
||||
linkKey = new CASALinkKey(secretId,keyId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
return linkKey;
|
||||
}
|
||||
|
||||
static public CASAPol GetPolicy(CASAPolType policyType)
|
||||
{
|
||||
CASAPol pol = null;
|
||||
try
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
if(!File.Exists(GetPolicyFilePath()))
|
||||
return null;
|
||||
doc.Load(GetPolicyFilePath());
|
||||
switch(policyType)
|
||||
{
|
||||
case CASAPolType.AGGREGATION_POL:
|
||||
{
|
||||
pol = GetAggPol(doc);
|
||||
break;
|
||||
}
|
||||
case CASAPolType.PERSISTENCE_POL:
|
||||
{
|
||||
pol = GetPersistencePol(doc);
|
||||
break;
|
||||
}
|
||||
case CASAPolType.UI_POL:
|
||||
{
|
||||
pol = GetUIPol(doc);
|
||||
break;
|
||||
}
|
||||
case CASAPolType.SYNCH_POL:
|
||||
{
|
||||
pol = GetSynchPol(doc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
return pol;
|
||||
}
|
||||
static public bool SetPolicy(CASAPol policy)
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
if(File.Exists(GetPolicyFilePath()))
|
||||
doc.Load(GetPolicyFilePath());
|
||||
CASAPolType policyType = policy.PolicyType;
|
||||
|
||||
AggregationPol aggPol = null;
|
||||
PersistencePol persistencePol = null;
|
||||
UIPol uiPol = null;
|
||||
SynchPol synchPol = null;
|
||||
|
||||
switch(policyType)
|
||||
{
|
||||
case CASAPolType.AGGREGATION_POL:
|
||||
{
|
||||
persistencePol = GetPersistencePol(doc);
|
||||
uiPol = GetUIPol(doc);
|
||||
synchPol = GetSynchPol(doc);
|
||||
aggPol = (AggregationPol)policy;
|
||||
break;
|
||||
}
|
||||
case CASAPolType.PERSISTENCE_POL:
|
||||
{
|
||||
aggPol = GetAggPol(doc);
|
||||
uiPol = GetUIPol(doc);
|
||||
synchPol = GetSynchPol(doc);
|
||||
persistencePol = (PersistencePol)policy;
|
||||
break;
|
||||
}
|
||||
case CASAPolType.UI_POL:
|
||||
{
|
||||
aggPol = GetAggPol(doc);
|
||||
persistencePol = GetPersistencePol(doc);
|
||||
synchPol = GetSynchPol(doc);
|
||||
uiPol = (UIPol)policy;
|
||||
break;
|
||||
}
|
||||
case CASAPolType.SYNCH_POL:
|
||||
{
|
||||
aggPol = GetAggPol(doc);
|
||||
persistencePol = GetPersistencePol(doc);
|
||||
uiPol = GetUIPol(doc);
|
||||
synchPol = (SynchPol)policy;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CASAPol[] policies = new CASAPol[4];
|
||||
policies[0] = aggPol;
|
||||
policies[1] = persistencePol;
|
||||
policies[2] = uiPol;
|
||||
policies[3] = synchPol;
|
||||
SetPolicies(policies);
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Should we support this? TBD later if required.
|
||||
*/
|
||||
static public bool RemovePolicy(CASAPolType policyType, CASAPol policy)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
459
c_policy/SynchPol.cs
Normal file
459
c_policy/SynchPol.cs
Normal file
@@ -0,0 +1,459 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Novell.CASA.CASAPolicy
|
||||
{
|
||||
public enum StoreKeyType
|
||||
{
|
||||
KW_KEY = 1,
|
||||
GK_KEY,
|
||||
MZ_KEY,
|
||||
FX_KEY,
|
||||
CASA_KEY
|
||||
}
|
||||
|
||||
abstract public class LinkKey
|
||||
{
|
||||
protected StoreKeyType keyType;
|
||||
public StoreKeyType KeyType
|
||||
{
|
||||
get
|
||||
{
|
||||
return keyType;
|
||||
}
|
||||
}
|
||||
|
||||
protected string storeName;
|
||||
public string StoreName
|
||||
{
|
||||
get
|
||||
{
|
||||
return storeName;
|
||||
}
|
||||
set
|
||||
{
|
||||
storeName = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected string storeId;
|
||||
public string StoreId
|
||||
{
|
||||
get
|
||||
{
|
||||
return storeId;
|
||||
}
|
||||
set
|
||||
{
|
||||
storeId = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected string secretId;
|
||||
public string SecretId
|
||||
{
|
||||
get
|
||||
{
|
||||
return secretId;
|
||||
}
|
||||
set
|
||||
{
|
||||
secretId = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected string keyId;
|
||||
public string KeyId
|
||||
{
|
||||
get
|
||||
{
|
||||
return keyId;
|
||||
}
|
||||
set
|
||||
{
|
||||
keyId = value;
|
||||
}
|
||||
}
|
||||
abstract public void AppendToDoc(XmlDocument doc, XmlElement linkKeyElem);
|
||||
abstract public void Dump();
|
||||
}
|
||||
|
||||
public class KWLinkKey : LinkKey
|
||||
{
|
||||
string folderId;
|
||||
public string FolderId
|
||||
{
|
||||
get
|
||||
{
|
||||
return folderId;
|
||||
}
|
||||
set
|
||||
{
|
||||
folderId = value;
|
||||
}
|
||||
}
|
||||
public KWLinkKey(string wallet, string folder,string secret,string key)
|
||||
{
|
||||
keyType = StoreKeyType.KW_KEY;
|
||||
storeName = XmlConsts.KwalletStoreName;
|
||||
storeId = wallet;
|
||||
folderId = folder;
|
||||
secretId = secret;
|
||||
keyId = key;
|
||||
}
|
||||
public override void Dump()
|
||||
{
|
||||
Console.WriteLine("StoreName = " + storeName + " StoreId = " + storeId + " FolderId = " + folderId + " SecretId = " + secretId + " Key = " + keyId);
|
||||
}
|
||||
|
||||
public override void AppendToDoc(XmlDocument doc, XmlElement linkKeyElem)
|
||||
{
|
||||
XmlAttribute attr;
|
||||
try
|
||||
{
|
||||
attr = doc.CreateAttribute(XmlConsts.StoreNameAttr);
|
||||
attr.Value = storeName;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.StoreIdAttr);
|
||||
attr.Value = storeId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.FolderIdAttr);
|
||||
attr.Value = folderId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.SecretIdAttr);
|
||||
attr.Value = secretId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.KeyAttr);
|
||||
attr.Value = keyId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GKLinkKey : LinkKey
|
||||
{
|
||||
public GKLinkKey(string keyring, string secret, string key)
|
||||
{
|
||||
keyType = StoreKeyType.GK_KEY;
|
||||
storeName = XmlConsts.GnomeKeyringStoreName;
|
||||
storeId = keyring;
|
||||
secretId = secret;
|
||||
keyId = key;
|
||||
}
|
||||
public override void Dump()
|
||||
{
|
||||
Console.WriteLine("StoreName = " + storeName + " StoreId = " + storeId + " SecretId = " + secretId + " Key = " + keyId);
|
||||
}
|
||||
|
||||
public override void AppendToDoc(XmlDocument doc, XmlElement linkKeyElem)
|
||||
{
|
||||
XmlAttribute attr;
|
||||
try
|
||||
{
|
||||
attr = doc.CreateAttribute(XmlConsts.StoreNameAttr);
|
||||
attr.Value = storeName;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.StoreIdAttr);
|
||||
attr.Value = storeId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.SecretIdAttr);
|
||||
attr.Value = secretId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.KeyAttr);
|
||||
attr.Value = keyId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class MZLinkKey : LinkKey
|
||||
{
|
||||
public MZLinkKey(string profile, string url, string key)
|
||||
{
|
||||
keyType = StoreKeyType.MZ_KEY;
|
||||
storeName = XmlConsts.MozillaStoreName;
|
||||
storeId = profile;
|
||||
secretId = url;
|
||||
keyId = key;
|
||||
}
|
||||
public override void Dump()
|
||||
{
|
||||
Console.WriteLine("StoreName = " + storeName + " StoreId = " + storeId + " SecretId = " + secretId + " Key = " + keyId);
|
||||
}
|
||||
|
||||
public override void AppendToDoc(XmlDocument doc, XmlElement linkKeyElem)
|
||||
{
|
||||
XmlAttribute attr;
|
||||
try
|
||||
{
|
||||
attr = doc.CreateAttribute(XmlConsts.StoreNameAttr);
|
||||
attr.Value = storeName;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.StoreIdAttr);
|
||||
attr.Value = storeId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.SecretIdAttr);
|
||||
attr.Value = secretId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.KeyAttr);
|
||||
attr.Value = keyId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public class FXLinkKey : LinkKey
|
||||
{
|
||||
public FXLinkKey(string profile,string url,string key)
|
||||
{
|
||||
keyType = StoreKeyType.FX_KEY;
|
||||
storeName = XmlConsts.FirefoxStoreName;
|
||||
storeId = profile;
|
||||
secretId = url;
|
||||
keyId = key;
|
||||
}
|
||||
public override void Dump()
|
||||
{
|
||||
Console.WriteLine("StoreName = " + storeName + " StoreId = " + storeId + " SecretId = " + secretId + " Key = " + keyId);
|
||||
}
|
||||
|
||||
public override void AppendToDoc(XmlDocument doc, XmlElement linkKeyElem)
|
||||
{
|
||||
XmlAttribute attr;
|
||||
try
|
||||
{
|
||||
attr = doc.CreateAttribute(XmlConsts.StoreNameAttr);
|
||||
attr.Value = storeName;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.StoreIdAttr);
|
||||
attr.Value = storeId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.SecretIdAttr);
|
||||
attr.Value = secretId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.KeyAttr);
|
||||
attr.Value = keyId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class CASALinkKey : LinkKey
|
||||
{
|
||||
public CASALinkKey(string secret, string key)
|
||||
{
|
||||
storeName = XmlConsts.MicasaStoreName;
|
||||
secretId = secret;
|
||||
keyId = key;
|
||||
}
|
||||
public override void Dump()
|
||||
{
|
||||
Console.WriteLine("StoreName = " + storeName + "SecretId = " + secretId + "Key = " + keyId);
|
||||
}
|
||||
|
||||
public override void AppendToDoc(XmlDocument doc, XmlElement linkKeyElem)
|
||||
{
|
||||
XmlAttribute attr;
|
||||
try
|
||||
{
|
||||
attr = doc.CreateAttribute(XmlConsts.StoreNameAttr);
|
||||
attr.Value = storeName;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.SecretIdAttr);
|
||||
attr.Value = secretId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.KeyAttr);
|
||||
attr.Value = keyId;
|
||||
linkKeyElem.SetAttributeNode(attr);
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class Link
|
||||
{
|
||||
ArrayList linkKeys;
|
||||
public ArrayList LinkKeys
|
||||
{
|
||||
get
|
||||
{
|
||||
return linkKeys;
|
||||
}
|
||||
}
|
||||
public Link(ArrayList linkList)
|
||||
{
|
||||
linkKeys = linkList;
|
||||
}
|
||||
public void Dump()
|
||||
{
|
||||
IEnumerator etor = linkKeys.GetEnumerator();
|
||||
while(etor.MoveNext())
|
||||
{
|
||||
((LinkKey)(etor.Current)).Dump();
|
||||
}
|
||||
}
|
||||
|
||||
public void AppendToDoc(XmlDocument doc, XmlElement linkElem)
|
||||
{
|
||||
try
|
||||
{
|
||||
IEnumerator enumerator = linkKeys.GetEnumerator();
|
||||
while(enumerator.MoveNext())
|
||||
{
|
||||
XmlElement linkKeyElem = doc.CreateElement(XmlConsts.LinkKeyNode);
|
||||
((LinkKey)(enumerator.Current)).AppendToDoc(doc,linkKeyElem);
|
||||
linkElem.AppendChild(linkKeyElem);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LinkGroup
|
||||
{
|
||||
ArrayList links;
|
||||
public ArrayList Links
|
||||
{
|
||||
get
|
||||
{
|
||||
return links;
|
||||
}
|
||||
}
|
||||
public LinkGroup(ArrayList linksList)
|
||||
{
|
||||
links = linksList;
|
||||
}
|
||||
public void Dump()
|
||||
{
|
||||
IEnumerator enumerator = links.GetEnumerator();
|
||||
while(enumerator.MoveNext())
|
||||
{
|
||||
Console.WriteLine("Link");
|
||||
((Link)(enumerator.Current)).Dump();
|
||||
}
|
||||
}
|
||||
|
||||
internal void AppendToDoc(XmlDocument doc, XmlElement synchPolElem)
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlElement linkGroupElem = doc.CreateElement(XmlConsts.LinkGroupNode);
|
||||
synchPolElem.AppendChild(linkGroupElem);
|
||||
|
||||
IEnumerator enumerator = links.GetEnumerator();
|
||||
while(enumerator.MoveNext())
|
||||
{
|
||||
XmlElement linkElem = doc.CreateElement(XmlConsts.LinkNode);
|
||||
((Link)(enumerator.Current)).AppendToDoc(doc,linkElem);
|
||||
linkGroupElem.AppendChild(linkElem);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class SynchPol: CASAPol
|
||||
{
|
||||
ArrayList linkGroups;
|
||||
public ArrayList LinkGroups
|
||||
{
|
||||
get
|
||||
{
|
||||
return linkGroups;
|
||||
}
|
||||
}
|
||||
|
||||
public SynchPol( ArrayList grps)
|
||||
{
|
||||
policyType = CASAPolType.SYNCH_POL;
|
||||
linkGroups = grps;
|
||||
}
|
||||
|
||||
public override void DumpPol()
|
||||
{
|
||||
Console.WriteLine("\nSynch Policy");
|
||||
IEnumerator grpEtor = linkGroups.GetEnumerator();
|
||||
while(grpEtor.MoveNext())
|
||||
{
|
||||
Console.WriteLine("\nLink Group\n");
|
||||
((LinkGroup)(grpEtor.Current)).Dump();
|
||||
} //end of while grpEtor
|
||||
}
|
||||
internal override void AppendToDoc(XmlDocument doc)
|
||||
{
|
||||
string xPath = "";
|
||||
try
|
||||
{
|
||||
xPath = "//" + XmlConsts.CASAPolicyNode;
|
||||
|
||||
XmlNode rootElem = doc.SelectSingleNode(xPath);
|
||||
|
||||
XmlElement synchPolElem = doc.CreateElement(XmlConsts.SynchPolicyNode);
|
||||
rootElem.AppendChild(synchPolElem);
|
||||
|
||||
IEnumerator enumerator = linkGroups.GetEnumerator();
|
||||
while(enumerator.MoveNext())
|
||||
{
|
||||
|
||||
((LinkGroup)(enumerator.Current)).AppendToDoc(doc,synchPolElem);
|
||||
// linkGroups[i].AppendToDoc(doc);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
98
c_policy/Test.cs
Normal file
98
c_policy/Test.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Novell.CASA.CASAPolicy;
|
||||
|
||||
class Test
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
ArrayList storeList = new ArrayList();
|
||||
|
||||
Store store = new Store("kwallet","walletid");
|
||||
storeList.Add(store);
|
||||
store = new Store("gnome-keyring","keyring1");
|
||||
storeList.Add(store);
|
||||
|
||||
AggregationPol aggPol = new AggregationPol(storeList);
|
||||
|
||||
PersistencePol persistPol = new PersistencePol("linux","myfile.xml",10);
|
||||
UIPol uiPol = new UIPol(true,false,true,"auto");
|
||||
|
||||
ArrayList linkKeyList = new ArrayList();
|
||||
KWLinkKey kwLinkKey = new KWLinkKey("wallet1","folder1","kw-secret","kw-passwd");
|
||||
linkKeyList.Add(kwLinkKey);
|
||||
GKLinkKey gkLinkKey = new GKLinkKey("keyring1","gk-secret","gk-passwd");
|
||||
linkKeyList.Add(gkLinkKey);
|
||||
Link link1 = new Link(linkKeyList);
|
||||
linkKeyList = new ArrayList();
|
||||
kwLinkKey = new KWLinkKey("wallet1","folder1","kw-secret","kw-username");
|
||||
linkKeyList.Add(kwLinkKey);
|
||||
gkLinkKey = new GKLinkKey("keyring1","gk-secret","gk-username");
|
||||
linkKeyList.Add(gkLinkKey);
|
||||
|
||||
|
||||
/*
|
||||
MZLinkKey mzLinkKey = new MZLinkKey("profile1","mz-secret","mz-username");
|
||||
linkKeyList.Add(mzLinkKey);
|
||||
*/
|
||||
|
||||
Link link2 = new Link(linkKeyList);
|
||||
ArrayList grp = new ArrayList();
|
||||
grp.Add(link1);
|
||||
grp.Add(link2);
|
||||
|
||||
LinkGroup linkGrp = new LinkGroup(grp);
|
||||
|
||||
ArrayList grpList = new ArrayList();
|
||||
grpList.Add(linkGrp);
|
||||
SynchPol synchPol = new SynchPol(grpList);
|
||||
|
||||
CASAPol[] policies = new CASAPol[4];
|
||||
policies[0] = aggPol;
|
||||
policies[1] = persistPol;
|
||||
policies[2] = uiPol;
|
||||
policies[3] = synchPol;
|
||||
|
||||
ICASAPol.SetPolicies(policies);
|
||||
policies = ICASAPol.GetPolicies();
|
||||
for(int i = 0; i < policies.Length; i++)
|
||||
{
|
||||
if(policies[i] != null)
|
||||
policies[i].DumpPol();
|
||||
}
|
||||
aggPol = (AggregationPol) ICASAPol.GetPolicy(CASAPolType.AGGREGATION_POL);
|
||||
aggPol.DumpPol();
|
||||
{
|
||||
Console.WriteLine("AGGPOL \n");
|
||||
ArrayList stores = aggPol.StoreList;
|
||||
IEnumerator enumerator = stores.GetEnumerator();
|
||||
while(enumerator.MoveNext())
|
||||
{
|
||||
Console.WriteLine("StoreName = " + ((Store)(enumerator.Current)).StoreName + " StoreId = " + ((Store)(enumerator.Current)).StoreId);
|
||||
}
|
||||
}
|
||||
persistPol = (PersistencePol)ICASAPol.GetPolicy(CASAPolType.PERSISTENCE_POL);
|
||||
persistPol.DumpPol();
|
||||
{
|
||||
Console.WriteLine("PERSISTENCE POL \n");
|
||||
Console.WriteLine("persistPol.OS = " + persistPol.OS);
|
||||
Console.WriteLine("persistPol.FilePath = " + persistPol.FilePath);
|
||||
Console.WriteLine("persistPol.PollInterval = " + persistPol.PollInterval);
|
||||
}
|
||||
uiPol = (UIPol)ICASAPol.GetPolicy(CASAPolType.UI_POL);
|
||||
uiPol.DumpPol();
|
||||
{
|
||||
Console.WriteLine("UIPOL \n");
|
||||
Console.WriteLine("uiPol.showInTaskBar = " + uiPol.ShowInTaskBar);
|
||||
Console.WriteLine("uiPol.showSecretValue = " + uiPol.ShowSecretValue);
|
||||
Console.WriteLine("uiPol.showSecretInClearText = " + uiPol.ShowSecretInClearText);
|
||||
Console.WriteLine("uiPol.synchEngineStartMode = " + uiPol.SynchEngineStartMode);
|
||||
|
||||
}
|
||||
persistPol = new PersistencePol("win","winfile.xml",100);
|
||||
ICASAPol.SetPolicy(persistPol);
|
||||
persistPol = (PersistencePol) ICASAPol.GetPolicy(CASAPolType.PERSISTENCE_POL);
|
||||
persistPol.DumpPol();
|
||||
|
||||
}
|
||||
}
|
||||
100
c_policy/UIPol.cs
Normal file
100
c_policy/UIPol.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace Novell.CASA.CASAPolicy
|
||||
{
|
||||
public class UIPol : CASAPol
|
||||
{
|
||||
bool showInTaskBar;
|
||||
public bool ShowInTaskBar
|
||||
{
|
||||
get
|
||||
{
|
||||
return showInTaskBar;
|
||||
}
|
||||
}
|
||||
bool showSecretValue;
|
||||
public bool ShowSecretValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return showSecretValue;
|
||||
}
|
||||
}
|
||||
bool showSecretInClearText;
|
||||
public bool ShowSecretInClearText
|
||||
{
|
||||
get
|
||||
{
|
||||
return showSecretInClearText;
|
||||
}
|
||||
}
|
||||
string synchEngineStartMode;
|
||||
public string SynchEngineStartMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return synchEngineStartMode;
|
||||
}
|
||||
}
|
||||
|
||||
public UIPol(bool inTrayIcon, bool inShowVals,bool inClearText,string startMode)
|
||||
{
|
||||
policyType = CASAPolType.UI_POL;
|
||||
showInTaskBar = inTrayIcon;
|
||||
showSecretValue = inShowVals;
|
||||
showSecretInClearText = inClearText;
|
||||
synchEngineStartMode = startMode;
|
||||
}
|
||||
|
||||
public override void DumpPol()
|
||||
{
|
||||
Console.WriteLine("\nUIPolicy");
|
||||
Console.WriteLine("showInTaskBar = " + showInTaskBar);
|
||||
Console.WriteLine("showSecretValue = " + showSecretValue);
|
||||
Console.WriteLine("showSecretInClearText = " + showSecretInClearText);
|
||||
Console.WriteLine("synchEngineStartMode = " + synchEngineStartMode);
|
||||
}
|
||||
|
||||
internal override void AppendToDoc(XmlDocument doc)
|
||||
{
|
||||
XmlElement elem;
|
||||
XmlAttribute attr;
|
||||
string xPath = "";
|
||||
|
||||
try
|
||||
{
|
||||
xPath = "//" + XmlConsts.CASAPolicyNode;
|
||||
XmlNode rootElem = doc.SelectSingleNode(xPath);
|
||||
|
||||
XmlElement uiPolElem = doc.CreateElement(XmlConsts.UIPolicyNode);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.ShowInTaskBarAttr);
|
||||
attr.Value = showInTaskBar.ToString();
|
||||
uiPolElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.ShowSecretValueAttr);
|
||||
attr.Value = showSecretValue.ToString();
|
||||
uiPolElem.SetAttributeNode(attr);
|
||||
|
||||
attr = doc.CreateAttribute(XmlConsts.ShowSecretInClearTextAttr);
|
||||
attr.Value = showSecretInClearText.ToString();
|
||||
uiPolElem.SetAttributeNode(attr);
|
||||
|
||||
rootElem.AppendChild(uiPolElem);
|
||||
|
||||
elem = doc.CreateElement(XmlConsts.SynchEngineStartModeNode);
|
||||
elem.InnerText = synchEngineStartMode;
|
||||
|
||||
uiPolElem.AppendChild(elem);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
//Console.WriteLine(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
9
c_policy/objs.lux
Normal file
9
c_policy/objs.lux
Normal file
@@ -0,0 +1,9 @@
|
||||
OBJS=\
|
||||
Policy\
|
||||
PolicyImpl\
|
||||
PolicyConstants\
|
||||
AggregationPol\
|
||||
PersistencePol\
|
||||
UIPol\
|
||||
SynchPol
|
||||
|
||||
9
c_policy/objs.w32
Normal file
9
c_policy/objs.w32
Normal file
@@ -0,0 +1,9 @@
|
||||
OBJS=\
|
||||
Policy\
|
||||
PolicyImpl\
|
||||
PolicyConstants\
|
||||
AggregationPol\
|
||||
PersistencePol\
|
||||
UIPol\
|
||||
SynchPol
|
||||
|
||||
9
c_policy/src.lux
Normal file
9
c_policy/src.lux
Normal file
@@ -0,0 +1,9 @@
|
||||
SRC=\
|
||||
Policy.cs\
|
||||
PolicyImpl.cs\
|
||||
PolicyConstants.cs\
|
||||
AggregationPol.cs\
|
||||
PersistencePol.cs\
|
||||
UIPol.cs\
|
||||
SynchPol.cs
|
||||
|
||||
9
c_policy/src.w32
Normal file
9
c_policy/src.w32
Normal file
@@ -0,0 +1,9 @@
|
||||
SRC=\
|
||||
Policy.cs\
|
||||
PolicyImpl.cs\
|
||||
PolicyConstants.cs\
|
||||
AggregationPol.cs\
|
||||
PersistencePol.cs\
|
||||
UIPol.cs\
|
||||
SynchPol.cs
|
||||
|
||||
Reference in New Issue
Block a user