2005-10-11 21:51:00 +02:00
|
|
|
using System;
|
|
|
|
using System.Text;
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
namespace Novell.CASA.DataEngines.KWallet
|
|
|
|
{
|
|
|
|
|
|
|
|
public class kwallet
|
|
|
|
{
|
|
|
|
|
|
|
|
//private static int MAX_NAME_LENGTH = 512;
|
|
|
|
private const string CPP_LIB = "kwallets_rw";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
[DllImport(CPP_LIB)]
|
|
|
|
public static extern void MyTest(
|
|
|
|
EnumSecretList enumSecretList
|
|
|
|
);
|
|
|
|
|
|
|
|
*/
|
|
|
|
[DllImport(CPP_LIB)]
|
|
|
|
public static extern void Aggregate(
|
|
|
|
EnumSecretList enumSecretList
|
|
|
|
);
|
|
|
|
|
|
|
|
[DllImport(CPP_LIB)]
|
|
|
|
public static extern void FreeList();
|
|
|
|
|
2005-12-16 11:29:25 +01:00
|
|
|
[DllImport(CPP_LIB)]
|
|
|
|
public static extern int SetEntry(string walletName, string folderName, int entryType, string keyName, string value, int valueLen);
|
2005-10-11 21:51:00 +02:00
|
|
|
|
2005-12-16 11:29:25 +01:00
|
|
|
[DllImport(CPP_LIB)]
|
|
|
|
public static extern int SetMapEntry(string walletName, string folderName, string keyName, String[,] value, int eleCount);
|
|
|
|
[DllImport(CPP_LIB)]
|
|
|
|
public static extern int RemoveEntry(string walletName, string folderName, string keyName);
|
2005-10-11 21:51:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
public static int Try(EnumSecretList enumSecretList)
|
|
|
|
{
|
|
|
|
MyTest(enumSecretList);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
public static int AggregateKW(EnumSecretList enumSecretList)
|
|
|
|
{
|
|
|
|
Aggregate(enumSecretList);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static int FreeResources()
|
|
|
|
{
|
|
|
|
FreeList();
|
|
|
|
return 0;
|
|
|
|
}
|
2005-12-16 11:29:25 +01:00
|
|
|
|
|
|
|
|
2006-01-06 12:57:25 +01:00
|
|
|
public static int SetSecret(string walletName, string folderName, int entryType, string keyName, string value, int valueLen )
|
2005-12-16 11:29:25 +01:00
|
|
|
{
|
|
|
|
return(SetEntry(walletName, folderName, entryType, keyName, value, valueLen ));
|
|
|
|
}
|
2006-01-06 12:57:25 +01:00
|
|
|
|
|
|
|
|
2005-12-16 11:29:25 +01:00
|
|
|
public static int SetSecret(string walletName, string folderName, string keyName, NameValueCollection nvc)
|
|
|
|
{
|
|
|
|
|
|
|
|
String[,] mapele = new String[nvc.Count,2 ];
|
|
|
|
|
|
|
|
for (int i=0; i< nvc.Count; i++)
|
|
|
|
{
|
|
|
|
mapele[i,0] = nvc.GetKey(i);
|
|
|
|
mapele[i,1] = nvc.Get(nvc.GetKey(i));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return(SetMapEntry(walletName, folderName, keyName, mapele, nvc.Count));
|
|
|
|
}
|
2006-01-06 12:57:25 +01:00
|
|
|
|
2005-12-16 11:29:25 +01:00
|
|
|
public static int DeleteSecret(string walletName, string folderName, string keyName)
|
|
|
|
{
|
|
|
|
return(RemoveEntry(walletName, folderName, keyName));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-11 21:51:00 +02:00
|
|
|
|
|
|
|
//TBD: All this for future.
|
|
|
|
/*
|
|
|
|
[DllImport(CPP_LIB)]
|
|
|
|
public static extern int ReadSecret
|
|
|
|
(
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)]
|
|
|
|
String walletName,
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)]
|
|
|
|
String folderName,
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)]
|
|
|
|
String key,
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)]
|
|
|
|
Byte[] secretVal
|
|
|
|
);
|
|
|
|
|
|
|
|
[DllImport(CPP_LIB)]
|
|
|
|
public static extern int WriteSecret
|
|
|
|
(
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)]
|
|
|
|
String walletName,
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)]
|
|
|
|
String folderName,
|
|
|
|
int entryType,
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)]
|
|
|
|
String key,
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)]
|
|
|
|
Byte[] secret
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport(CPP_LIB)]
|
|
|
|
public static extern void CloseAllWallets();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static int ReadWallet(String walletName, String folderName, String key, Byte[] secretVal)
|
|
|
|
{
|
|
|
|
|
|
|
|
// Read a secret from wallet
|
|
|
|
return (ReadSecret(walletName, folderName, key, secretVal));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int WriteWallet(String walletName, String folderName,int entryType, String key, Byte[] secretVal)
|
|
|
|
{
|
|
|
|
|
|
|
|
// Write secret to wallet
|
|
|
|
return (WriteSecret( walletName, folderName, entryType, key, secretVal));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void DisconnectApplication()
|
|
|
|
{
|
|
|
|
|
|
|
|
CloseAllWallets();
|
|
|
|
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|