Delete OpenSim-Modules-Currency directory

This commit is contained in:
ManfredAabye
2025-06-20 17:12:38 +02:00
committed by GitHub
parent 7764bd8728
commit ce6853bd6a
5 changed files with 0 additions and 2687 deletions
File diff suppressed because it is too large Load Diff
@@ -1,266 +0,0 @@
/*
* Copyright (c) Contributors, http://www.nsl.tuis.ac.jp
*
*/
using System;
using System.Net;
using System.Net.Security;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using log4net;
namespace NSL.Certificate.Tools
{
/// <summary>
/// class NSL Certificate Verify
/// </summary>
public class NSLCertificateVerify
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private X509Chain m_chain = null;
private X509Certificate2 m_cacert = null;
private X509Certificate2 m_mycert = null;
private Mono.Security.X509.X509Crl m_clientcrl = null;
/// <summary>NSL Certificate Verify</summary>
public NSLCertificateVerify()
{
m_chain = null;
m_cacert = null;
m_clientcrl = null;
// m_log.InfoFormat("[NSL CERT VERIFY]: NSLCertificateVerify()");
}
/// <summary>
/// NSL Certificate Verify
/// </summary>
/// <param name="certfile"></param>
public NSLCertificateVerify(string certfile)
{
SetPrivateCA(certfile);
// m_log.InfoFormat("[NSL CERT VERIFY]: NSLCertificateVerify()");
}
/// <summary>
/// NSL Certificate Verify
/// </summary>
/// <param name="certfile"></param>
/// <param name="crlfile"></param>
public NSLCertificateVerify(string certfile, string crlfile)
{
SetPrivateCA(certfile);
SetPrivateCRL(crlfile);
// m_log.InfoFormat("[NSL CERT VERIFY]: NSLCertificateVerify()");
}
/// <summary>
/// Set Private Certificate
/// </summary>
/// <param name="certfile"></param>
/// <param name="passwd"></param>
public void SetPrivateCert(string certfile, string passwd)
{
try
{
m_mycert = new X509Certificate2(certfile, passwd);
}
catch (Exception ex)
{
m_mycert = null;
m_log.ErrorFormat("[SET PRIVATE CERT]: Cert File setting error [{0}]. {1}", certfile, ex);
}
}
/// <summary>
/// Get Private Certificate
/// </summary>
public X509Certificate2 GetPrivateCert()
{
return m_mycert;
}
/// <summary>
/// Set Private CA
/// </summary>
/// <param name="certfile"></param>
public void SetPrivateCA(string certfile)
{
try
{
m_cacert = new X509Certificate2(certfile);
}
catch (Exception ex)
{
m_cacert = null;
m_log.ErrorFormat("[SET PRIVATE CA]: CA File reading error [{0}]. {1}", certfile, ex);
}
if (m_cacert != null)
{
m_chain = new X509Chain();
m_chain.ChainPolicy.ExtraStore.Add(m_cacert);
m_chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
m_chain.ChainPolicy.VerificationFlags = X509VerificationFlags.NoFlag;
}
}
/// <summary>Sets the private CRL.</summary>
/// <param name="crlfile">The crlfile.</param>
public void SetPrivateCRL(string crlfile)
{
try
{
m_clientcrl = Mono.Security.X509.X509Crl.CreateFromFile(crlfile);
}
catch (Exception ex)
{
m_clientcrl = null;
m_log.ErrorFormat("[SET PRIVATE CRL]: CRL File reading error [{0}]. {1}", crlfile, ex);
}
}
/// <summary>
/// Check Private Chain
/// </summary>
/// <param name="cert"></param>
/// <returns></returns>
public bool CheckPrivateChain(X509Certificate2 cert)
{
if (m_chain == null || m_cacert == null)
{
return false;
}
bool ret = m_chain.Build((X509Certificate2)cert);
if (ret)
{
return true;
}
for (int i = 0; i < m_chain.ChainStatus.Length; i++)
{
if (m_chain.ChainStatus[i].Status == X509ChainStatusFlags.UntrustedRoot) return true;
}
return false;
}
/// <summary>
/// Validate Server Certificate Callback Function
/// </summary>
/// <param name="obj"></param>
/// <param name="certificate"></param>
/// <param name="chain"></param>
/// <param name="sslPolicyErrors"></param>
/// <returns></returns>
public bool ValidateServerCertificate(object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
m_log.InfoFormat("[NSL SERVER CERT VERIFY]: ValidateServerCertificate: Policy is ({0})", sslPolicyErrors);
if (obj is HttpWebRequest)
{
HttpWebRequest Request = (HttpWebRequest)obj;
string noVerify = Request.Headers.Get("NoVerifyCert");
if ((noVerify != null) && (noVerify.ToLower() == "true"))
{
m_log.InfoFormat("[NSL SERVER CERT VERIFY]: ValidateServerCertificate: No Verify Server Certificate.");
return true;
}
}
X509Certificate2 certificate2 = new X509Certificate2(certificate);
string commonname = certificate2.GetNameInfo(X509NameType.SimpleName, false);
m_log.InfoFormat("[NSL SERVER CERT VERIFY]: ValidateServerCertificate: Common Name is \"{0}\"", commonname);
// None, ChainErrors Error except for
if ((sslPolicyErrors != SslPolicyErrors.None) && (sslPolicyErrors != SslPolicyErrors.RemoteCertificateChainErrors))
{
m_log.InfoFormat("[NSL SERVER CERT VERIFY]: ValidateServerCertificate: Policy Error! {0}", sslPolicyErrors);
return false;
}
bool valid = CheckPrivateChain(certificate2);
if (valid)
{
m_log.InfoFormat("[NSL SERVER CERT VERIFY]: ValidateServerCertificate: Valid Server Certification for \"{0}\"", commonname);
}
else
{
m_log.InfoFormat("[NSL SERVER CERT VERIFY]: ValidateServerCertificate: Failed to Verify Server Certification for \"{0}\"", commonname);
}
return valid;
}
/// <summary>
/// Validate Client Certificate Callback Function
/// </summary>
/// <param name="obj"></param>
/// <param name="certificate"></param>
/// <param name="chain"></param>
/// <param name="sslPolicyErrors"></param>
/// <returns></returns>
public bool ValidateClientCertificate(object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
m_log.InfoFormat("[NSL CLIENT CERT VERIFY]: ValidateClientCertificate: Start.");
if (certificate == null)
{
m_log.InfoFormat("[NSL CLIENT CERT VERIFY]: ValidateClientCertificate: Client does not have a Certificate!");
return false;
}
X509Certificate2 certificate2 = new X509Certificate2(certificate);
string commonname = certificate2.GetNameInfo(X509NameType.SimpleName, false);
m_log.InfoFormat("[NSL CLIENT CERT VERIFY]: ValidateClientCertificate: Common Name is \"{0}\"", commonname);
// None, ChainErrors Anything other than that is an error.
if (sslPolicyErrors != SslPolicyErrors.None && sslPolicyErrors != SslPolicyErrors.RemoteCertificateChainErrors)
{
m_log.InfoFormat("[NSL CLIENT CERT VERIFY]: ValidateClientCertificate: Policy Error! {0}", sslPolicyErrors);
return false;
}
// check CRL
if (m_clientcrl != null)
{
Mono.Security.X509.X509Certificate monocert = new Mono.Security.X509.X509Certificate(certificate.GetRawCertData());
Mono.Security.X509.X509Crl.X509CrlEntry entry = m_clientcrl.GetCrlEntry(monocert);
if (entry != null)
{
m_log.InfoFormat("[NSL CLIENT CERT VERIFY]: Common Name \"{0}\" was revoked at {1}", commonname, entry.RevocationDate.ToString());
return false;
}
}
bool valid = CheckPrivateChain(certificate2);
if (valid)
{
m_log.InfoFormat("[NSL CLIENT CERT VERIFY]: Valid Client Certification for \"{0}\"", commonname);
}
else
{
m_log.InfoFormat("[NSL CLIENT CERT VERIFY]: Failed to Verify Client Certification for \"{0}\"", commonname);
}
return valid;
}
}
}
@@ -1,160 +0,0 @@
/*
* Copyright (c) Contributors, http://www.nsl.tuis.ac.jp
*
*/
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Net;
using System.Text;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using log4net;
using Nwc.XmlRpc;
using System.Net.Security;
using NSL.Certificate.Tools;
namespace NSL.Network.XmlRpc
{
public class NSLXmlRpcRequest : XmlRpcRequest
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// The encoding
private Encoding _encoding = new UTF8Encoding();
// The serializer
private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
// The deserializer
private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
/// <summary>
/// Initializes a new instance of the <see cref="NSLXmlRpcRequest" /> class.
/// </summary>
/// <remarks>
/// This constructor initializes the request with an empty parameter list.
/// </remarks>
public NSLXmlRpcRequest()
{
// Initialize the parameter list as an empty ArrayList
_params = new ArrayList();
}
/// <summary>
/// Initializes a new instance of the <see cref="NSLXmlRpcRequest" /> class.
/// </summary>
/// <param name="methodName">Name of the method to be invoked in the XML-RPC request.</param>
/// <param name="parameters">The parameters to be passed to the method.</param>
public NSLXmlRpcRequest(String methodName, IList parameters)
{
// Set the method name for the XML-RPC request
MethodName = methodName;
// Set the parameters for the XML-RPC request
_params = parameters;
}
/// <summary>
/// Sends a certificate-based XML-RPC request to the specified URL.
/// </summary>
/// <param name="url">The URL of the XML-RPC server.</param>
/// <param name="certVerify">The certificate verification object.</param>
/// <param name="checkServerCert">Whether to check the server's certificate.</param>
/// <param name="timeout">The timeout for the request in milliseconds.</param>
/// <returns>The XML-RPC response from the server.</returns>
/// <exception cref="Nwc.XmlRpc.XmlRpcException">Thrown if there is an error with the request.</exception>
public XmlRpcResponse certSend(String url, NSLCertificateVerify certVerify, bool checkServerCert, Int32 timeout)
{
// Log the request URL
m_log.InfoFormat("[MONEY NSL XMLRPC]: XmlRpcResponse certSend: connect to {0}", url);
// Create a new HTTP web request
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
if (request == null)
{
// Throw an exception if the request cannot be created
throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url);
}
// Set the request method and content type
request.Method = "POST";
request.ContentType = "text/xml";
request.AllowWriteStreamBuffering = true;
request.Timeout = timeout;
request.UserAgent = "NSLXmlRpcRequest";
// Add the client certificate if provided
X509Certificate2 clientCert = null;
if (certVerify != null)
{
clientCert = certVerify.GetPrivateCert();
if (clientCert != null) request.ClientCertificates.Add(clientCert); // Own certificate
request.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(certVerify.ValidateServerCertificate);
}
else
{
// Disable server certificate checking if no verification object is provided
checkServerCert = false;
}
// Disable server certificate checking if requested
if (!checkServerCert)
{
request.Headers.Add("NoVerifyCert", "true"); // Do not verify the certificate of the other party
}
// Get the request stream
Stream stream = null;
try
{
stream = request.GetRequestStream();
}
catch (Exception ex)
{
// Log any errors getting the request stream
m_log.ErrorFormat("[MONEY NSL XMLRPC]: GetRequestStream Error: {0}", ex);
stream = null;
}
// Return null if the request stream could not be obtained
if (stream == null) return null;
// Serialize the request to the stream
XmlTextWriter xml = new XmlTextWriter(stream, _encoding);
_serializer.Serialize(xml, this);
xml.Flush();
xml.Close();
// Get the response from the server
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (Exception ex)
{
// Log any errors getting the response
m_log.ErrorFormat("[MONEY NSL XMLRPC]: XmlRpcResponse certSend: GetResponse Error: {0}", ex.ToString());
}
// Deserialize the response from the server
StreamReader input = new StreamReader(response.GetResponseStream());
string inputXml = input.ReadToEnd();
XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml);
// Close the input and response streams
input.Close();
response.Close();
// Return the deserialized response
return resp;
}
}
}
@@ -1,34 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Mono.Addins;
// 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("OpenSim.Modules.Currency")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("DTL/NSL Group")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2363e3c9-7be0-4b9b-84ac-82923d5021f4")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -1,45 +0,0 @@
<?xml version="1.0" ?>
<Project name="OpenSim.Modules.Currency" path="addon-modules/OpenSim-Modules-Currency" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../bin/</OutputPath>
<AllowUnsafe>true</AllowUnsafe>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../bin/</OutputPath>
<AllowUnsafe>true</AllowUnsafe>
</Options>
</Configuration>
<ReferencePath>../../bin/</ReferencePath>
<Reference name="Mono.Addins" path="../../bin/"/>
<Reference name="Mono.Security" path="../../bin/"/>
<Reference name="Nini" path="../../bin/"/>
<Reference name="log4net" path="../../bin/"/>
<Reference name="OpenMetaverse" path="../../bin/"/>
<Reference name="OpenMetaverseTypes" path="../../bin/"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Data.MySQL.MySQLMoneyDataWrapper"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Server.Base"/>
<Reference name="OpenSim.Services.Interfaces"/>
<Reference name="XMLRPC" path="../../bin/"/>
<Files>
<Match pattern="*.cs" recurse="true">
<Exclude name="obj" pattern="obj"/>
<Exclude name="Tests" pattern="Tests"/>
</Match>
</Files>
</Project>