Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
//
// System.Net.Security.AuthenticatedStream.cs
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2004
// (c) 2004 Novell, Inc. (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.IO;
namespace System.Net.Security
{
public abstract class AuthenticatedStream : Stream
{
#region Fields
Stream innerStream;
bool leaveStreamOpen;
#endregion // Fields
#region Constructors
protected AuthenticatedStream (Stream innerStream, bool leaveInnerStreamOpen)
{
this.innerStream = innerStream;
this.leaveStreamOpen = leaveInnerStreamOpen;
}
#endregion // Constructors
#region Properties
protected Stream InnerStream {
get { return innerStream; }
}
public abstract bool IsAuthenticated { get; }
public abstract bool IsEncrypted { get; }
public abstract bool IsMutuallyAuthenticated { get; }
public abstract bool IsServer { get; }
public abstract bool IsSigned { get; }
public bool LeaveInnerStreamOpen {
get {
return leaveStreamOpen;
}
}
#endregion // Properties
#region Methods
protected override void Dispose (bool disposing)
{
if (disposing && innerStream != null){
if (!leaveStreamOpen)
innerStream.Close ();
innerStream = null;
}
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,42 @@
//
// System.Net.Security.AuthenticationLevel.cs
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2004
// (c) 2004 Novell, Inc. (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net.Security
{
public enum AuthenticationLevel
{
None,
MutualAuthRequested,
MutualAuthRequired,
}
}

View File

@@ -0,0 +1,87 @@
2010-07-21 Sebastien Pouliot <sebastien@ximian.com>
* LocalCertificateSelectionCallback.cs:
* SslStream.cs:
Don't use alias in moonlight build (not needed and breaks
compilation otherwise)
2010-06-29 Sebastien Pouliot <sebastien@ximian.com>
* RemoteCertificateValidationCallback.cs: Remove SECURITY_DEP use
2010-05-10 Sebastien Pouliot <sebastien@ximian.com>
* SslStream.cs: Allow Moonlight to build the non-server part
of SslStream
* RemoteCertificateValidationCallback.cs: Adjust visibility for
Moonlight build
2010-03-01 Gonzalo Paniagua Javier <gonzalo@novell.com>
* SslStream.cs: don't do anything if a chain element has
no error.
2009-08-20 Sebastien Pouliot <sebastien@ximian.com>
* SslStream.cs : Always use/provide a X509Chain even if this
duplicates some of the old/existing logic of Mono.Security.
This makes it possible to provide a callback using
ServicePointManager.ServerCertificateValidationCallback
2007-08-24 Atsushi Enomoto <atsushi@ximian.com>
* SslStream.cs : uh, fixed the build.
2007-08-24 Atsushi Enomoto <atsushi@ximian.com>
* SslStream.cs : implemented, based on Mono.Security.
* LocalCertificateSelectionCallback.cs : extern alias is needed.
2006-04-05 Sebastien Pouliot <sebastien@ximian.com>
* RemoteCertValidationCallback.cs: Fix build. X509Chain isn't
available when System.dll is first being build. This needs to be
reviewed since some System.Security.dll classes migrated to System.dll
2006-04-05 Atsushi Enomoto <atsushi@ximian.com>
* SslPolicyErrors.cs : forgot to add.
2006-04-05 Atsushi Enomoto <atsushi@ximian.com>
* AuthenticationLevel.cs,
NegotiateStream.cs,
SslStream.cs,
LocalCertificateSelectionCallback.cs,
RemoteCertificateValidationCallback.cs :
Updated all unimplemented things to 2.0 RTM.
2006-03-21 Miguel de Icaza <miguel@novell.com>
* AuthenticatedStream.cs: Implement Dispose method, remove Close
method, the Close to fix the API.
* NegotiateStream.cs: Implement Dispose method as well, kill
Close, rename the various methods to the new ones.
2006-03-11 Miguel de Icaza <miguel@novell.com>
* AuthenticatedStream.cs: Fixed normative parameter names (yes, we
need to do this everywhere one day).
(Close): actually obey the "leaveInnerStreamOpen" setting from the
constructor.
2006-03-07 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* SslStream.cs, NegotiateStream.cs: Override CanTimeout,
ReadTimeout and WriteTimeout properties, to avoid warnings.
2005-10-26 Atsushi Enomoto <atsushi@ximian.com>
* ProtectionLevel.cs : fix enumeration.
2004-09-13 Tim Coleman <tim@timcoleman.com>
* AuthenticatedStream.cs AuthenticationLevel.cs LocalCertSelectionCallback.cs
* NegotiateStream.cs ProtectionLevel.cs RemoteCertValidationCallback.cs
* SslStream.cs: New stubs for Fx 2.0

View File

@@ -0,0 +1,50 @@
//
// System.Net.Security.LocalCertificateSelectionCallback.cs
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2004
// (c) 2004 Novell, Inc. (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if SECURITY_DEP
#if !MONOTOUCH && !MONODROID
extern alias PrebuiltSystem;
using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
#endif
using System.Security.Cryptography.X509Certificates;
namespace System.Net.Security
{
public delegate X509Certificate LocalCertificateSelectionCallback (
object sender,
string targetHost,
X509CertificateCollection localCertificates,
X509Certificate remoteCertificate,
string [] acceptableIssuers);
}
#endif

View File

@@ -0,0 +1,277 @@
//
// System.Net.Security.NegotiateStream.cs
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2004
// (c) 2004 Novell, Inc. (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
using System.Net;
using System.Security.Principal;
namespace System.Net.Security
{
public class NegotiateStream : AuthenticatedStream
{
#region Fields
int readTimeout;
int writeTimeout;
#endregion // Fields
#region Constructors
[MonoTODO]
public NegotiateStream (Stream innerStream)
: base (innerStream, false)
{
}
[MonoTODO]
public NegotiateStream (Stream innerStream, bool leaveInnerStreamOpen)
: base (innerStream, leaveInnerStreamOpen)
{
}
#endregion // Constructors
#region Properties
public override bool CanRead {
get { return InnerStream.CanRead; }
}
public override bool CanSeek {
get { return InnerStream.CanSeek; }
}
[MonoTODO]
public override bool CanTimeout {
get { throw new NotImplementedException (); }
}
public override bool CanWrite {
get { return InnerStream.CanWrite; }
}
[MonoTODO]
public virtual TokenImpersonationLevel ImpersonationLevel {
get { throw new NotImplementedException (); }
}
[MonoTODO]
public override bool IsAuthenticated {
get { throw new NotImplementedException (); }
}
[MonoTODO]
public override bool IsEncrypted {
get { throw new NotImplementedException (); }
}
[MonoTODO]
public override bool IsMutuallyAuthenticated {
get { throw new NotImplementedException (); }
}
[MonoTODO]
public override bool IsServer {
get { throw new NotImplementedException (); }
}
[MonoTODO]
public override bool IsSigned {
get { throw new NotImplementedException (); }
}
public override long Length {
get { return InnerStream.Length; }
}
public override long Position {
get { return InnerStream.Position; }
set { InnerStream.Position = value; }
}
public override int ReadTimeout {
get { return readTimeout; }
set { readTimeout = value; }
}
[MonoTODO]
public virtual IIdentity RemoteIdentity {
get { throw new NotImplementedException (); }
}
public override int WriteTimeout {
get { return writeTimeout; }
set { writeTimeout = value; }
}
#endregion // Properties
#region Methods
[MonoTODO]
public virtual IAsyncResult BeginAuthenticateAsClient (AsyncCallback asyncCallback, object asyncState)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual IAsyncResult BeginAuthenticateAsClient (NetworkCredential credential, string targetName, AsyncCallback asyncCallback, object asyncState)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual IAsyncResult BeginAuthenticateAsClient (NetworkCredential credential, string targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel, AsyncCallback asyncCallback, object asyncState)
{
throw new NotImplementedException ();
}
[MonoTODO]
public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual IAsyncResult BeginAuthenticateAsServer (AsyncCallback asyncCallback, object asyncState)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual IAsyncResult BeginAuthenticateAsServer (NetworkCredential credential, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel, AsyncCallback asyncCallback, object asyncState)
{
throw new NotImplementedException ();
}
[MonoTODO]
public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual void AuthenticateAsClient ()
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual void AuthenticateAsClient (NetworkCredential credential, string targetName)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual void AuthenticateAsClient (NetworkCredential credential, string targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual void AuthenticateAsServer ()
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual void AuthenticateAsServer (NetworkCredential credential, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected override void Dispose (bool disposing)
{
if (disposing){
// TODO
}
}
[MonoTODO]
public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
{
throw new NotImplementedException ();
}
[MonoTODO]
public override int EndRead (IAsyncResult asyncResult)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
{
throw new NotImplementedException ();
}
[MonoTODO]
public override void EndWrite (IAsyncResult asyncResult)
{
throw new NotImplementedException ();
}
[MonoTODO]
public override void Flush ()
{
InnerStream.Flush ();
}
[MonoTODO]
public override int Read (byte[] buffer, int offset, int count)
{
throw new NotImplementedException ();
}
[MonoTODO]
public override long Seek (long offset, SeekOrigin origin)
{
throw new NotImplementedException ();
}
[MonoTODO]
public override void SetLength (long value)
{
throw new NotImplementedException ();
}
[MonoTODO]
public override void Write (byte[] buffer, int offset, int count)
{
throw new NotImplementedException ();
}
#endregion // Methods
}
}

View File

@@ -0,0 +1,41 @@
//
// System.Net.Security.ProtectionLevel.cs
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2004
// (c) 2004 Novell, Inc. (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net.Security
{
public enum ProtectionLevel
{
None,
Sign,
EncryptAndSign,
}
}

View File

@@ -0,0 +1,42 @@
//
// System.Net.Security.RemoteCertValidationCallback.cs
//
// Authors:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2004
// (c) 2004 Novell, Inc. (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Security.Cryptography.X509Certificates;
namespace System.Net.Security
{
public delegate bool RemoteCertificateValidationCallback (
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors);
}

View File

@@ -0,0 +1,39 @@
//
// System.Net.Security.SslPolicyErrors.cs
//
// Authors:
// Atsushi Enomoto <atsushi@ximian.com>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Net.Security
{
[Flags]
public enum SslPolicyErrors
{
None = 0,
RemoteCertificateNotAvailable = 1,
RemoteCertificateNameMismatch = 2,
RemoteCertificateChainErrors = 4,
}
}

File diff suppressed because it is too large Load Diff