Moving micasa 1.5 trunk to Novell forge.
This commit is contained in:
58
ClientPasswordManager/c-sharp-net-credential/AssemblyInfo.cs
Normal file
58
ClientPasswordManager/c-sharp-net-credential/AssemblyInfo.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("Novell.Security.ClientPasswordManager NetCredential")]
|
||||
[assembly: AssemblyDescription("Implements the NetCredential class for Novell.Security.ClientPasswordManager")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Novell, Inc.")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2004 Novell, Inc.")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("..\\..\\c-sharp-net-credential.snk")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
77
ClientPasswordManager/c-sharp-net-credential/Makefile.am
Normal file
77
ClientPasswordManager/c-sharp-net-credential/Makefile.am
Normal file
@@ -0,0 +1,77 @@
|
||||
#######################################################################
|
||||
#
|
||||
# Copyright (C) 2004 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.
|
||||
#
|
||||
# Author: Juan Carlos Luciani <jluciani@novell.com>
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
if DEBUG
|
||||
TARGET_CFG = Debug
|
||||
else
|
||||
TARGET_CFG = Release
|
||||
endif
|
||||
|
||||
# handle Mono secondary dependencies
|
||||
export MONO_PATH := $(MONO_PATH)
|
||||
|
||||
Module_CSFILES = $(srcdir)/NetCredential.cs
|
||||
Module_CSFILES_CSC := $(subst /,$(SEP),$(Module_CSFILES))
|
||||
Module_KEYFILE = $(srcdir)/c-sharp-net-credential.snk
|
||||
Module_INCLUDES =
|
||||
Module_RESOURCES =
|
||||
Module_FLAGS = $(CSC_LIBFLAG)
|
||||
Module_LIBS = System.dll System.Data.dll $(SYSTEM_XML) Novell.Security.ClientPasswordManager.PasswordDialog.dll Novell.Security.ClientPasswordManager.UsernameDialog.dll Novell.Security.Utilities.dll
|
||||
Module_LIBPATH = ../c-sharp-password-dialog/bin/$(TARGET_CFG) ../c-sharp-username-dialog/bin/$(TARGET_CFG) ../c-sharp-utilities/bin/$(TARGET_CFG)
|
||||
|
||||
EXTRA_DIST = $(Module_CSFILES) $(Module_KEYFILE)
|
||||
|
||||
CUR_DIR := $(shell pwd)
|
||||
|
||||
all: Novell.Security.ClientPasswordManager.NetCredential.dll
|
||||
|
||||
Novell.Security.ClientPasswordManager.NetCredential.dll: $(Module_CSFILES) $(Module_RESOURCES)
|
||||
$(mkinstalldirs) bin/$(TARGET_CFG)
|
||||
if WINDOWS
|
||||
$(CSC) /nowarn:1591,1573,1572 /out:bin/$(TARGET_CFG)/$@ $(CSCFLAGS) $(Module_FLAGS) $(Module_LIBS:%=/r:%) $(Module_LIBPATH:%=/lib:%) $(Module_CSFILES_CSC) /doc:Novell.Security.ClientPasswordManager.NetCredential.doc.xml
|
||||
else
|
||||
$(CSC) /nowarn:1591,1573,1572 /out:bin/$(TARGET_CFG)/$@ $(CSCFLAGS) $(Module_FLAGS) /keyfile:$(Module_KEYFILE) $(Module_LIBS:%=/r:%) $(Module_LIBPATH:%=/lib:%) $(Module_CSFILES_CSC) /doc:Novell.Security.ClientPasswordManager.NetCredential.doc.xml
|
||||
endif
|
||||
|
||||
install-exec-local: Novell.Security.ClientPasswordManager.NetCredential.dll
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
$(INSTALL_PROGRAM) bin/$(TARGET_CFG)/Novell.Security.ClientPasswordManager.NetCredential.dll $(DESTDIR)$(libdir)/
|
||||
|
||||
uninstall-local:
|
||||
cd $(DESTDIR)$(libdir); rm -f Novell.Security.ClientPasswordManager.NetCredential.dll
|
||||
rmdir $(DESTDIR)$(libdir)
|
||||
|
||||
#installcheck-local: install
|
||||
# $(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
|
||||
# cd $(DESTDIR)$(libdir); $(MONO)
|
||||
|
||||
CLEAN_FILES = bin/$(TARGET_CFG)/Novell.Security.ClientPasswordManager.NetCredential.dll /doc:Novell.Security.ClientPasswordManager.NetCredential.doc.xml
|
||||
|
||||
clean-local:
|
||||
rm -rf *.dbg *.exe *.dll $(CLEAN_FILES)
|
||||
|
||||
distclean-local:
|
||||
|
||||
maintainer-clean-local:
|
||||
rm -f Makefile.in
|
||||
|
||||
471
ClientPasswordManager/c-sharp-net-credential/NetCredential.cs
Normal file
471
ClientPasswordManager/c-sharp-net-credential/NetCredential.cs
Normal file
@@ -0,0 +1,471 @@
|
||||
/***********************************************************************
|
||||
* File: NetCredential.cs
|
||||
* Author: Juan Carlos Luciani (jluciani@novell.com)
|
||||
*
|
||||
* Namespace: Novell.Security.ClientPasswordManager
|
||||
*
|
||||
* Classes implemented: NetCredential.
|
||||
*
|
||||
* Copyright (C) 2004 Novell, Inc.
|
||||
*
|
||||
* This library 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 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using Novell.Security;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Novell.Security.ClientPasswordManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides an implementation of ICredentials that leverages the
|
||||
/// services of the SecretStore Client Service Wallet.
|
||||
/// </summary>
|
||||
public class NetCredential: ICredentials
|
||||
{
|
||||
#region Class Members and Defines
|
||||
|
||||
// This is temporary until we add code to interact with the SecretStore
|
||||
private class UserCache
|
||||
{
|
||||
public string m_userName;
|
||||
public CredentialCache m_credentialCache;
|
||||
|
||||
public UserCache()
|
||||
{
|
||||
m_userName = null;
|
||||
m_credentialCache = null;
|
||||
}
|
||||
}
|
||||
|
||||
// This is temporary until we add code to interact with the SecretStore
|
||||
private static UserCache[] m_userCaches = new UserCache[10];
|
||||
|
||||
private string m_svcName = null;
|
||||
private string m_svcGroupName = null;
|
||||
private string m_userName = null;
|
||||
private string m_password = null;
|
||||
private string m_credScope = null;
|
||||
|
||||
private bool m_haveCredentials;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private static bool bMiCasaIsAvailable = false;
|
||||
private static Assembly assembly = null; //
|
||||
private static string MI_CASA_CLASS_NAME = "Novell.CASA.miCASA";
|
||||
|
||||
|
||||
static NetCredential()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
assembly = Assembly.LoadWithPartialName("Novell.CASA.miCASAWrapper");
|
||||
if (assembly != null)
|
||||
bMiCasaIsAvailable = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Dbg.trcError(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a NetCredential object for Windows Applications.
|
||||
///
|
||||
/// There is a high probability that services under the same group share the
|
||||
/// same user name and passwords. By specifying a service group name, the caller wants to
|
||||
/// take advantage of this to try to improve the user experience. If the service group
|
||||
/// name is not specified then no effort is made to share usernames and passwords with
|
||||
/// other services.
|
||||
///
|
||||
/// If the svcGroupNameIsRealmName parameter is set to true then it is assumed that
|
||||
/// the services in the group validate username and passwords against the same
|
||||
/// database or against synchronized databases.
|
||||
///
|
||||
/// If the svcGroupNameIsRealmName parameter is set to false then an attempt will be
|
||||
/// made to share passwords between the services in the group but services will be
|
||||
/// allowed to use different passwords. Specifying a service group does not mean
|
||||
/// that the system will not be able to obtain a username and password that is
|
||||
/// unique to a particular service.
|
||||
/// </summary>
|
||||
/// <param name="svcName">Name of service requesting credentials.</param>
|
||||
/// <param name="svcGroupName">Name of group to which the service belongs, can be null or zero length.</param>
|
||||
/// <param name="svcGroupNameIsRealmName">The group name is the name of the backend authentication realm.</param>
|
||||
/// <param name="userName">Name of the user.</param>
|
||||
/// <param name="password">User password if known, otherwise null or empty string.</param>
|
||||
public NetCredential(string svcName,
|
||||
string svcGroupName,
|
||||
bool svcGroupNameIsRealmName,
|
||||
string userName,
|
||||
string password)
|
||||
{
|
||||
// Check input parameters
|
||||
if (svcName == null
|
||||
|| svcName.Length == 0
|
||||
|| (svcGroupNameIsRealmName
|
||||
&& (svcGroupName == null
|
||||
|| svcGroupName.Length == 0))
|
||||
|| userName == null
|
||||
|| userName.Length == 0)
|
||||
{
|
||||
Dbg.trcError("NetCredential constructor- Invalid input parameter");
|
||||
throw new Exception("NetCredential constructor- Invalid input parameter");
|
||||
}
|
||||
|
||||
m_svcName = svcName;
|
||||
m_svcGroupName = svcGroupName;
|
||||
m_userName = userName;
|
||||
m_password = password;
|
||||
|
||||
// Determine the name under which the credentials are scoped
|
||||
if (svcGroupNameIsRealmName)
|
||||
m_credScope = m_svcGroupName;
|
||||
else
|
||||
m_credScope = m_svcName;
|
||||
|
||||
// Check if we need to update the credential cache
|
||||
if (password != null
|
||||
&& password.Length != 0)
|
||||
{
|
||||
if (bMiCasaIsAvailable)
|
||||
{
|
||||
UpdateMiCasaCredential(userName, password, m_svcName, svcGroupName);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateCredentialCache(userName, password, m_credScope);
|
||||
}
|
||||
|
||||
// Remember that there object has credentials associated with it to avoid
|
||||
// looking them up in the cache at a later time.
|
||||
m_haveCredentials = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Indicate that we need to look up the credentials in the cache
|
||||
m_haveCredentials = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a NetCredential object.
|
||||
///
|
||||
/// No effort is made to share usernames and passwords with other services.
|
||||
/// </summary>
|
||||
/// <param name="svcName">Name of service requesting credentials.</param>
|
||||
/// <param name="userName">Name of the user.</param>
|
||||
/// <param name="password">User password if known, otherwise null or empty string. Not meaningfull if username is not specified.</param>
|
||||
public NetCredential(string svcName,
|
||||
string userName,
|
||||
string password)
|
||||
{
|
||||
// Check input parameters
|
||||
if (svcName == null
|
||||
|| svcName.Length == 0
|
||||
|| userName == null
|
||||
|| userName.Length == 0)
|
||||
{
|
||||
Dbg.trcError("NetCredential constructor- Invalid input parameter");
|
||||
throw new Exception("NetCredential constructor- Invalid input parameter");
|
||||
}
|
||||
|
||||
m_svcName = svcName;
|
||||
m_userName = userName;
|
||||
m_password = password;
|
||||
|
||||
// The credentials are scoped to the service name
|
||||
m_credScope = m_svcName;
|
||||
|
||||
// Check if we need to update the credential cache
|
||||
if (password != null
|
||||
&& password.Length != 0)
|
||||
{
|
||||
|
||||
if (bMiCasaIsAvailable)
|
||||
{
|
||||
UpdateMiCasaCredential(userName, password, m_svcName, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateCredentialCache(userName, password, m_credScope);
|
||||
}
|
||||
|
||||
// Remember that there object has credentials associated with it to avoid
|
||||
// looking them up in the cache at a later time.
|
||||
m_haveCredentials = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Indicate that we need to look up the credentials in the cache
|
||||
m_haveCredentials = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a NetworkCredential instance from the cache.
|
||||
/// </summary>
|
||||
/// <param name="uriPrefix">A Uri that specifies the URI prefix of the resources that the credential is used for.</param>
|
||||
/// <param name="authType">The authentication scheme used by the host named in <i>uriPrefix</i>. </param>
|
||||
public void Remove(Uri uriPrefix,
|
||||
String authType)
|
||||
{
|
||||
// Only process requests for the "Basic" authentication scheme
|
||||
if (authType.ToUpper() == "BASIC")
|
||||
{
|
||||
|
||||
if (bMiCasaIsAvailable)
|
||||
{
|
||||
RemoveMiCasaCredential(uriPrefix.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we already have credentials
|
||||
if (m_haveCredentials)
|
||||
{
|
||||
// Clear the credentials.
|
||||
m_password = null;
|
||||
m_haveCredentials = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Lookup the credentials in the cache
|
||||
//
|
||||
// Synchronize access into the cache
|
||||
lock (m_userCaches)
|
||||
{
|
||||
// Look for the user's cache
|
||||
int i;
|
||||
for (i = 0; i < m_userCaches.Length; i++)
|
||||
{
|
||||
// Check if the user cache has been instantiated
|
||||
if (m_userCaches[i] != null)
|
||||
{
|
||||
if (m_userCaches[i].m_userName == m_userName)
|
||||
{
|
||||
// We found a cache for this user, remove the credentials.
|
||||
m_userCaches[i].m_credentialCache.Remove(new Uri("http://" + m_credScope, true), "Basic");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dbg.trcError("NetCredential.GetCredential- Unsupported authentication scheme");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Obtains the network credentials necessary to gain access to the resources associated
|
||||
/// with the specified uri prefix.
|
||||
/// </summary>
|
||||
/// <param name="uriPrefix">Uri that specifies the URI prefix of resources that the credential grant access to</param>
|
||||
/// <param name="authType">The authentication scheme used by the resource</param>
|
||||
/// <returns>NetworkCredential object or null if not successful</returns>
|
||||
public NetworkCredential GetCredential(Uri uriPrefix,
|
||||
String authType)
|
||||
{
|
||||
NetworkCredential cred = null;
|
||||
|
||||
// Only process requests for the "Basic" authentication scheme
|
||||
if (authType.ToUpper() == "BASIC")
|
||||
{
|
||||
|
||||
if (bMiCasaIsAvailable)
|
||||
{
|
||||
return GetMiCasaCredential(m_svcName, m_svcGroupName);
|
||||
}
|
||||
|
||||
// Check if we already have credentials
|
||||
if (m_haveCredentials)
|
||||
{
|
||||
// Create NetworkCredential object with the credentials that we have.
|
||||
cred = new NetworkCredential(m_userName, m_password);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Lookup the credentials in the cache
|
||||
//
|
||||
// Synchronize access into the cache
|
||||
lock (m_userCaches)
|
||||
{
|
||||
// Look for the user's cache
|
||||
int i;
|
||||
for (i = 0; i < m_userCaches.Length; i++)
|
||||
{
|
||||
// Check if the user cache has been instantiated
|
||||
if (m_userCaches[i] != null)
|
||||
{
|
||||
if (m_userCaches[i].m_userName == m_userName)
|
||||
{
|
||||
// We found a cache for this user, check if we already have the
|
||||
// necessary credentials.
|
||||
cred = m_userCaches[i].m_credentialCache.GetCredential(new Uri("http://" + m_credScope, true), "Basic");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dbg.trcError("NetCredential.GetCredential- Unsuported authentication scheme");
|
||||
}
|
||||
|
||||
return cred;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the credential cache with the supplied credentials.
|
||||
/// </summary>
|
||||
/// <param name="userName">Name of the user.</param>
|
||||
/// <param name="password">User password.</param>
|
||||
/// <param name="credScope">Credential scope.</param>
|
||||
private void UpdateCredentialCache(string userName, string password, string credScope)
|
||||
{
|
||||
// Check if we already have a cache for the user
|
||||
lock (m_userCaches)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < m_userCaches.Length; i++)
|
||||
{
|
||||
// Check if the user cache has been instantiated
|
||||
if (m_userCaches[i] != null)
|
||||
{
|
||||
if (m_userCaches[i].m_userName == userName)
|
||||
{
|
||||
// A user cache has already been instantiated, check if
|
||||
// we already have a cache entry.
|
||||
if (m_userCaches[i].m_credentialCache.GetCredential(new Uri("http://" + credScope, true), "Basic") != null)
|
||||
{
|
||||
// We have a cache entry, remove it.
|
||||
m_userCaches[i].m_credentialCache.Remove(new Uri("http://" + credScope, true), "Basic");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Instantiate user cache and use it
|
||||
m_userCaches[i] = new UserCache();
|
||||
|
||||
// Setup user cache
|
||||
m_userCaches[i].m_userName = userName;
|
||||
m_userCaches[i].m_credentialCache = new CredentialCache();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Exit if we failed to obtain a user cache
|
||||
if (i == m_userCaches.Length)
|
||||
return;
|
||||
|
||||
// Create NetworkCredential object and add it to the credential cache
|
||||
NetworkCredential cred = new NetworkCredential(userName, password);
|
||||
m_userCaches[i].m_credentialCache.Add(new Uri("http://" + credScope, true), "Basic", cred);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// the following is micasa/secretstore code.
|
||||
private void UpdateMiCasaCredential(string sUsername, string sPassword, string sSecretID, string sSharedID)
|
||||
{
|
||||
|
||||
// call SetCredential through reflection
|
||||
Type type = assembly.GetType(MI_CASA_CLASS_NAME);
|
||||
object Instance = Activator.CreateInstance (type);
|
||||
|
||||
object[] arguments = new object[4];
|
||||
arguments[0] = sSecretID;
|
||||
arguments[1] = sSharedID;
|
||||
arguments[2] = sUsername;
|
||||
arguments[3] = sPassword;
|
||||
|
||||
object result;
|
||||
try
|
||||
{
|
||||
result = type.InvokeMember("SetBasicCredential", BindingFlags.InvokeMethod, null, Instance, arguments);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Dbg.trcError(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private NetworkCredential GetMiCasaCredential(string sSecretID, string sSharedID)
|
||||
{
|
||||
object oUsername;
|
||||
object oPassword;
|
||||
|
||||
Type type = assembly.GetType(MI_CASA_CLASS_NAME);
|
||||
object Instance = Activator.CreateInstance (type);
|
||||
|
||||
try
|
||||
{
|
||||
object[] arguments = new object[2];
|
||||
arguments[0] = sSecretID;
|
||||
arguments[1] = sSharedID;
|
||||
|
||||
// reflection call
|
||||
oUsername = type.InvokeMember("GetCredentialUsername", BindingFlags.InvokeMethod, null, Instance, arguments);
|
||||
oPassword = type.InvokeMember("GetCredentialPassword", BindingFlags.InvokeMethod, null, Instance, arguments);
|
||||
|
||||
if ((oUsername != null) & (oPassword != null))
|
||||
return new NetworkCredential(oUsername.ToString().Trim(), oPassword.ToString().Trim());
|
||||
|
||||
// invoke the GetUsername and GetPassword methods
|
||||
//object username = basicCred.InvokeMember("GetUsername", BindingFlags.InvokeMethod, null, result, null);
|
||||
//object password = basicCred.InvokeMember("GetPassword", BindingFlags.InvokeMethod, null, result, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Dbg.trcError(e.ToString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void RemoveMiCasaCredential(string sSecretID)
|
||||
{
|
||||
Type type = assembly.GetType(MI_CASA_CLASS_NAME);
|
||||
object Instance = Activator.CreateInstance (type);
|
||||
|
||||
try
|
||||
{
|
||||
object[] arguments = new object[2];
|
||||
arguments[0] = sSecretID;
|
||||
arguments[1] = null;
|
||||
|
||||
// reflection call
|
||||
type.InvokeMember("RemoveBasicCredential", BindingFlags.InvokeMethod, null, Instance, arguments);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Dbg.trcError(e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
34
ClientPasswordManager/c-sharp-net-credential/README
Normal file
34
ClientPasswordManager/c-sharp-net-credential/README
Normal file
@@ -0,0 +1,34 @@
|
||||
/***********************************************************************
|
||||
* File: README
|
||||
*
|
||||
* Copyright (C) 2004 Novell, Inc.
|
||||
*
|
||||
* This library 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 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
***********************************************************************/
|
||||
|
||||
INTRODUCTION
|
||||
|
||||
The c-sharp-net-credential component provides the class NetCredential
|
||||
which is an implementation of the ICredentials interface. Applications
|
||||
can use objects of this class to satisfy credential queries from classes
|
||||
such as the WebRequest class..
|
||||
|
||||
FEATURES
|
||||
|
||||
The c-sharp-net-credential class allows the user to set or retrieve
|
||||
password credentials from the credential cache provided by the SecretStore
|
||||
Client Service Wallet. The application can control how credentials are scoped
|
||||
in the credential store through the parameters utilized to instantiate
|
||||
NetCredential objects.
|
||||
@@ -0,0 +1,114 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.10.3077"
|
||||
SchemaVersion = "2.0"
|
||||
ProjectGuid = "{D7D0F5D8-0F45-4DCA-818B-8E71168A2CA3}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "Novell.Security.ClientPasswordManager.NetCredential"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "Library"
|
||||
PreBuildEvent = ""
|
||||
PostBuildEvent = ""
|
||||
RootNamespace = "Novell.Security.ClientPasswordManager"
|
||||
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 = "..\..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
HintPath = "..\..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
HintPath = "..\..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Windows.Forms"
|
||||
AssemblyName = "System.Windows.Forms"
|
||||
HintPath = "..\..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "Novell.Security.Utilities"
|
||||
AssemblyName = "Novell.Security.Utilities"
|
||||
HintPath = "..\c-sharp-utilities\bin\Debug\Novell.Security.Utilities.dll"
|
||||
/>
|
||||
</References>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AssemblyInfo.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "c-sharp-net-credential.snk"
|
||||
BuildAction = "None"
|
||||
/>
|
||||
<File
|
||||
RelPath = "NetCredential.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP LastOpenVersion = "7.10.3077" >
|
||||
<Build>
|
||||
<Settings ReferencePath = "C:\Documents and Settings\jluciani\My Documents\Visual Studio Projects\ClientPasswordManager\c-sharp-utilities\bin\Debug\;C:\Documents and Settings\jluciani\My Documents\Visual Studio Projects\ClientPasswordManager\c-sharp-username-dialog\bin\Debug\;C:\Documents and Settings\jluciani\My Documents\Visual Studio Projects\ClientPasswordManager\c-sharp-password-dialog\bin\Debug\;C:\Documents and Settings\jluciani\My Documents\Visual Studio Projects\ClientPasswordManager\c-sharp-utilities\bin\Release\;D:\ccm\SSClient\ClientPasswordManager\c-sharp-utilities\bin\Debug\;D:\ccm\SSClient\SecretStoreClient_src\ClientPasswordManager\c-sharp-utilities\bin\Debug\;D:\ccm\SSClient\SecretStoreClient_src\ClientPasswordManager\c-sharp-utilities\obj\Release\" >
|
||||
<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 = "false"
|
||||
/>
|
||||
</Settings>
|
||||
</Build>
|
||||
<OtherProjectSettings
|
||||
CopyProjectDestinationFolder = ""
|
||||
CopyProjectUncPath = ""
|
||||
CopyProjectOption = "0"
|
||||
ProjectView = "ProjectFiles"
|
||||
ProjectTrust = "0"
|
||||
/>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user