You've already forked linux-packaging-mono
Imported Upstream version 3.10.0
Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
@@ -147,8 +147,10 @@ run-test-vts: test-vts
|
||||
@echo Running vts tests...
|
||||
PATH="$(TEST_RUNTIME_WRAPPERS_PATH):$(PATH)" $(TEST_RUNTIME) $(RUNTIME_FLAGS) $(TEST_HARNESS) -noshadow \
|
||||
$(vtsdir)/$(PROFILE)_TestLib/BinarySerializationOverVersions.exe
|
||||
ifndef NO_TEST
|
||||
test: test-vts
|
||||
run-test: run-test-vts
|
||||
endif
|
||||
|
||||
EXTRA_DISTFILES += \
|
||||
$(vtsdir)/VersionTolerantSerializationTestLib/1.0/Address.cs \
|
||||
|
@@ -383,7 +383,11 @@ namespace System.IO {
|
||||
canonicalize = start > 0;
|
||||
}
|
||||
|
||||
path = Directory.InsecureGetCurrentDirectory() + DirectorySeparatorStr + path;
|
||||
var cwd = Directory.InsecureGetCurrentDirectory();
|
||||
if (cwd [cwd.Length - 1] == DirectorySeparatorChar)
|
||||
path = cwd + path;
|
||||
else
|
||||
path = cwd + DirectorySeparatorChar + path;
|
||||
} else if (DirectorySeparatorChar == '\\' &&
|
||||
path.Length >= 2 &&
|
||||
IsDsc (path [0]) &&
|
||||
|
@@ -33,6 +33,10 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
#if NET_4_5
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endif
|
||||
|
||||
namespace System.IO
|
||||
{
|
||||
@@ -48,6 +52,9 @@ namespace System.IO
|
||||
#if NET_4_0
|
||||
SafeBuffer safebuffer;
|
||||
#endif
|
||||
#if NET_4_5
|
||||
Task<int> read_task;
|
||||
#endif
|
||||
|
||||
internal event EventHandler Closed;
|
||||
|
||||
@@ -209,6 +216,36 @@ namespace System.IO
|
||||
return progress;
|
||||
}
|
||||
|
||||
#if NET_4_5
|
||||
public override Task<int> ReadAsync (byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("buffer");
|
||||
if (offset < 0)
|
||||
throw new ArgumentOutOfRangeException("offset", "Non-negative number required.");
|
||||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException("count", "Non-negative number required.");
|
||||
if ((buffer.Length - offset) < count)
|
||||
throw new ArgumentException("The length of the buffer array minus the offset parameter is less than the count parameter");
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return TaskConstants<int>.Canceled;
|
||||
|
||||
try {
|
||||
count = Read (buffer, offset, count);
|
||||
|
||||
// Try not to allocate a new task for every buffer read
|
||||
if (read_task == null || read_task.Result != count)
|
||||
read_task = Task<int>.FromResult (count);
|
||||
|
||||
return read_task;
|
||||
} catch (Exception ex) {
|
||||
return Task<int>.FromException (ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public override int ReadByte ()
|
||||
{
|
||||
if (closed)
|
||||
@@ -293,6 +330,21 @@ namespace System.IO
|
||||
//This method performs no action for this class
|
||||
//but is included as part of the Stream base class
|
||||
}
|
||||
|
||||
#if NET_4_5
|
||||
public override Task FlushAsync (CancellationToken cancellationToken)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return TaskConstants.Canceled;
|
||||
|
||||
try {
|
||||
Flush ();
|
||||
return TaskConstants.Finished;
|
||||
} catch (Exception ex) {
|
||||
return Task<object>.FromException (ex);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
@@ -349,6 +401,32 @@ namespace System.IO
|
||||
if (current_position > length)
|
||||
length = current_position;
|
||||
}
|
||||
|
||||
#if NET_4_5
|
||||
public override Task WriteAsync (byte[] buffer, int offset, int count, CancellationToken cancellationToken)
|
||||
{
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("The buffer parameter is a null reference");
|
||||
if (offset < 0)
|
||||
throw new ArgumentOutOfRangeException("offset", "Non-negative number required.");
|
||||
if (count < 0)
|
||||
throw new ArgumentOutOfRangeException("count", "Non-negative number required.");
|
||||
if ((buffer.Length - offset) < count)
|
||||
throw new ArgumentException("The length of the buffer array minus the offset parameter is less than the count parameter");
|
||||
if (current_position > capacity - count)
|
||||
throw new NotSupportedException ("Unable to expand length of this stream beyond its capacity.");
|
||||
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
return TaskConstants.Canceled;
|
||||
|
||||
try {
|
||||
Write (buffer, offset, count);
|
||||
return TaskConstants.Finished;
|
||||
} catch (Exception ex) {
|
||||
return Task<object>.FromException (ex);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public override void WriteByte (byte value)
|
||||
{
|
||||
|
@@ -808,6 +808,12 @@ namespace System.Reflection.Emit
|
||||
|
||||
if (parent == pmodule.assemblyb.corlib_enum_type && methods != null)
|
||||
throw new TypeLoadException ("Could not load type '" + FullName + "' from assembly '" + Assembly + "' because it is an enum with methods.");
|
||||
if (interfaces != null) {
|
||||
foreach (var iface in interfaces) {
|
||||
if (iface.IsNestedPrivate && iface.Assembly != Assembly)
|
||||
throw new TypeLoadException ("Could not load type '" + FullName + "' from assembly '" + Assembly + "' because it is implements the inaccessible interface '" + iface.FullName + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
if (methods != null) {
|
||||
bool is_concrete = !IsAbstract;
|
||||
|
@@ -752,13 +752,6 @@ namespace System.Reflection {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// The following functions are only for the Mono Debugger.
|
||||
//
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
internal static extern int MonoDebugger_GetMethodToken (MethodBase method);
|
||||
|
||||
[MonoTODO ("Currently it always returns zero")]
|
||||
[ComVisible (false)]
|
||||
public
|
||||
|
@@ -35,6 +35,7 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace System.Reflection
|
||||
{
|
||||
@@ -43,12 +44,16 @@ namespace System.Reflection
|
||||
[Serializable]
|
||||
[ClassInterfaceAttribute (ClassInterfaceType.None)]
|
||||
[StructLayout (LayoutKind.Sequential)]
|
||||
#if MOBILE
|
||||
public partial class ParameterInfo : ICustomAttributeProvider {
|
||||
#else
|
||||
public partial class ParameterInfo : ICustomAttributeProvider, _ParameterInfo {
|
||||
public partial class ParameterInfo : ICustomAttributeProvider
|
||||
|
||||
#if !MOBILE
|
||||
, _ParameterInfo
|
||||
#endif
|
||||
|
||||
#if NET_4_0
|
||||
, IObjectReference
|
||||
#endif
|
||||
{
|
||||
protected Type ClassImpl;
|
||||
protected object DefaultValueImpl;
|
||||
protected MemberInfo MemberImpl;
|
||||
@@ -245,6 +250,11 @@ namespace System.Reflection
|
||||
return new object [0];
|
||||
}
|
||||
|
||||
public object GetRealObject (StreamingContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public virtual bool IsDefined( Type attributeType, bool inherit) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -1,4 +1,3 @@
|
||||
#if NET_4_5
|
||||
//
|
||||
// InterfaceImplementedInVersionAttribute.cs
|
||||
//
|
||||
@@ -24,12 +23,13 @@
|
||||
// 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;
|
||||
|
||||
#if NET_4_5
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System.Runtime.InteropServices.WindowsRuntime
|
||||
{
|
||||
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple = false, Inherited = false)]
|
||||
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
|
||||
public sealed class InterfaceImplementedInVersionAttribute : Attribute
|
||||
{
|
||||
public InterfaceImplementedInVersionAttribute (Type interfaceType, byte majorVersion, byte minorVersion,
|
||||
|
@@ -40,16 +40,23 @@ using System.Globalization;
|
||||
namespace System.Runtime.Serialization
|
||||
{
|
||||
[System.Runtime.InteropServices.ComVisibleAttribute (true)]
|
||||
public sealed class FormatterServices
|
||||
#if NET_4_5
|
||||
static
|
||||
#else
|
||||
sealed
|
||||
#endif
|
||||
public class FormatterServices
|
||||
{
|
||||
private const BindingFlags fieldFlags = BindingFlags.Public |
|
||||
BindingFlags.Instance |
|
||||
BindingFlags.NonPublic |
|
||||
BindingFlags.DeclaredOnly;
|
||||
|
||||
#if !NET_4_5
|
||||
private FormatterServices ()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
public static object [] GetObjectData (object obj, MemberInfo [] members)
|
||||
{
|
||||
|
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// CompatibilitySwitch.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar (marek.safar@gmail.com)
|
||||
//
|
||||
// Copyright 2014 Xamarin Inc
|
||||
//
|
||||
// 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 NET_4_5
|
||||
|
||||
namespace System.Runtime.Versioning {
|
||||
public static class CompatibilitySwitch
|
||||
{
|
||||
public static bool IsEnabled (string compatibilitySwitchName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static string GetValue (string compatibilitySwitchName)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -37,12 +37,21 @@ namespace System.Runtime
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
[MonoTODO ("Always returns GCLatencyMode.Interactive and ignores set (.NET 2.0 SP1 member)")]
|
||||
[MonoTODO ("Always returns GCLatencyMode.Interactive and ignores set")]
|
||||
public static GCLatencyMode LatencyMode {
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
|
||||
get { return GCLatencyMode.Interactive; }
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
|
||||
set { ; }
|
||||
}
|
||||
|
||||
#if NET_4_5
|
||||
public static GCLargeObjectHeapCompactionMode LargeObjectHeapCompactionMode {
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
|
||||
get;
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
|
||||
set;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@@ -44,29 +44,25 @@ namespace System.Security.Claims
|
||||
|
||||
public const string AuthorizationDecision = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/authorizationdecision";
|
||||
|
||||
public const string ClaimsType2005Namespace = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims";
|
||||
|
||||
public const string ClaimsType2009Namespace = "http://schemas.xmlsoap.org/ws/2009/09/identity/claims";
|
||||
|
||||
public const string ClaimsTypeNamespace = "http://schemas.microsoft.com/ws/2008/06/identity/claims";
|
||||
|
||||
public const string CookiePath = "http://schemas.microsoft.com/ws/2008/06/identity/claims/cookiepath";
|
||||
|
||||
public const string Country = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/country";
|
||||
|
||||
public const string DateOfBirth = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/dateofbirth";
|
||||
|
||||
public const string DenyOnlyPrimaryGroup = "http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarygroup";
|
||||
public const string DenyOnlyPrimaryGroupSid = "http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarygroupsid";
|
||||
|
||||
public const string DenyOnlyPrimarySid = "http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlyprimarysid";
|
||||
|
||||
public const string DenyOnlySid = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/denyonlysid";
|
||||
|
||||
public const string DenyOnlyWindowsDeviceGroup = "http://schemas.microsoft.com/ws/2008/06/identity/claims/denyonlywindowsdevicegroup";
|
||||
|
||||
public const string Dns = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/dns";
|
||||
|
||||
public const string Dsa = "http://schemas.microsoft.com/ws/2008/06/identity/claims/dsa";
|
||||
|
||||
public const string Email = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/email";
|
||||
public const string Email = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress";
|
||||
|
||||
public const string Expiration = "http://schemas.microsoft.com/ws/2008/06/identity/claims/expiration";
|
||||
|
||||
@@ -96,8 +92,6 @@ namespace System.Security.Claims
|
||||
|
||||
public const string PostalCode = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/postalcode";
|
||||
|
||||
public const string PPID = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier";
|
||||
|
||||
public const string PrimaryGroupSid = "http://schemas.microsoft.com/ws/2008/06/identity/claims/primarygroupsid";
|
||||
|
||||
public const string PrimarySid = "http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid";
|
||||
@@ -134,6 +128,16 @@ namespace System.Security.Claims
|
||||
|
||||
public const string WindowsAccountName = "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname";
|
||||
|
||||
public const string WindowsDeviceClaim = "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsdeviceclaim";
|
||||
|
||||
public const string WindowsDeviceGroup = "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsdevicegroup";
|
||||
|
||||
public const string WindowsFqbnVersion = "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsfqbnversion";
|
||||
|
||||
public const string WindowsSubAuthority = "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowssubauthority";
|
||||
|
||||
public const string WindowsUserClaim = "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsuserclaim";
|
||||
|
||||
public const string X500DistinguishedName = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/x500distinguishedname";
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
//
|
||||
// Authors:
|
||||
// Miguel de Icaza (miguel@xamarin.com)
|
||||
// Marek Safar (marek.safar@gmail.com)
|
||||
//
|
||||
// Copyright 2014 Xamarin Inc
|
||||
//
|
||||
@@ -26,10 +27,11 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#if NET_4_5
|
||||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Principal;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace System.Security.Claims {
|
||||
|
||||
[Serializable]
|
||||
@@ -41,9 +43,9 @@ namespace System.Security.Claims {
|
||||
[NonSerializedAttribute]
|
||||
public const string DefaultIssuer = "LOCAL AUTHORITY";
|
||||
|
||||
List<Claim> claims;
|
||||
readonly List<Claim> claims;
|
||||
ClaimsIdentity actor;
|
||||
string auth_type;
|
||||
readonly string auth_type;
|
||||
|
||||
public ClaimsIdentity ()
|
||||
: this (claims: null, authenticationType: null, nameType: null, roleType: null)
|
||||
@@ -72,44 +74,42 @@ namespace System.Security.Claims {
|
||||
public ClaimsIdentity(IEnumerable<Claim> claims, string authenticationType, string nameType, string roleType)
|
||||
: this (identity: null, claims: claims, authenticationType: authenticationType, nameType: nameType, roleType: roleType)
|
||||
{
|
||||
claims = claims == null ? new List<Claim> (): new List<Claim> (claims);
|
||||
|
||||
// Special case: if empty, set to null.
|
||||
if (authenticationType == "")
|
||||
auth_type = null;
|
||||
else
|
||||
auth_type = authenticationType;
|
||||
|
||||
NameClaimType = nameType == null ? DefaultNameClaimType : nameType;
|
||||
RoleClaimType = roleType == null ? DefaultRoleClaimType : roleType;
|
||||
}
|
||||
|
||||
public ClaimsIdentity (IIdentity identity, IEnumerable<Claim> claims)
|
||||
: this (identity, claims, authenticationType: null, nameType: null, roleType: null)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
public ClaimsIdentity (IIdentity identity, IEnumerable<Claim> claims, string authenticationType, string nameType, string roleType)
|
||||
{
|
||||
var ci = identity as ClaimsIdentity;
|
||||
NameClaimType = nameType == null ? DefaultNameClaimType : nameType;
|
||||
RoleClaimType = roleType == null ? DefaultRoleClaimType : roleType;
|
||||
|
||||
NameClaimType = string.IsNullOrEmpty (nameType) ? DefaultNameClaimType : nameType;
|
||||
RoleClaimType = string.IsNullOrEmpty (roleType) ? DefaultRoleClaimType : roleType;
|
||||
auth_type = authenticationType;
|
||||
|
||||
this.claims = new List<Claim> ();
|
||||
if (ci != null){
|
||||
actor = ci.Actor;
|
||||
BootstrapContext = ci.BootstrapContext;
|
||||
foreach (var c in ci.Claims)
|
||||
this.claims.Add (c);
|
||||
|
||||
if (identity != null) {
|
||||
if (string.IsNullOrEmpty (authenticationType))
|
||||
auth_type = identity.AuthenticationType;
|
||||
|
||||
var ci = identity as ClaimsIdentity;
|
||||
if (ci != null) {
|
||||
actor = ci.Actor;
|
||||
BootstrapContext = ci.BootstrapContext;
|
||||
foreach (var c in ci.Claims)
|
||||
this.claims.Add (c);
|
||||
|
||||
Label = ci.Label;
|
||||
NameClaimType = ci.NameClaimType;
|
||||
RoleClaimType = ci.RoleClaimType;
|
||||
auth_type = ci.AuthenticationType;
|
||||
Label = ci.Label;
|
||||
NameClaimType = string.IsNullOrEmpty (nameType) ? ci.NameClaimType : nameType;
|
||||
RoleClaimType = string.IsNullOrEmpty (roleType) ? ci.RoleClaimType : roleType;
|
||||
} else if (!string.IsNullOrEmpty (identity.Name)) {
|
||||
AddDefaultClaim (identity.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (claims != null) {
|
||||
foreach (var c in claims)
|
||||
this.claims.Add (c);
|
||||
AddClaims (claims);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,8 +132,9 @@ namespace System.Security.Claims {
|
||||
return actor;
|
||||
}
|
||||
set {
|
||||
if (actor == this)
|
||||
if (value == this)
|
||||
throw new InvalidOperationException ("can not set the Actor property to this instance");
|
||||
|
||||
actor = value;
|
||||
}
|
||||
}
|
||||
@@ -174,6 +175,10 @@ namespace System.Security.Claims {
|
||||
{
|
||||
if (claim == null)
|
||||
throw new ArgumentNullException ("claim");
|
||||
|
||||
if (claim.Subject != this)
|
||||
claim = claim.Clone (this);
|
||||
|
||||
claims.Add (claim);
|
||||
}
|
||||
|
||||
@@ -181,8 +186,14 @@ namespace System.Security.Claims {
|
||||
{
|
||||
if (claims == null)
|
||||
throw new ArgumentNullException ("claims");
|
||||
|
||||
foreach (var c in claims)
|
||||
this.claims.Add (c);
|
||||
AddClaim (c);
|
||||
}
|
||||
|
||||
internal void AddDefaultClaim (string identityName)
|
||||
{
|
||||
this.claims.Add (new Claim (NameClaimType, identityName, "http://www.w3.org/2001/XMLSchema#string", DefaultIssuer, DefaultIssuer, this));
|
||||
}
|
||||
|
||||
public virtual ClaimsIdentity Clone ()
|
||||
@@ -203,12 +214,12 @@ namespace System.Security.Claims {
|
||||
yield return c;
|
||||
}
|
||||
|
||||
public virtual IEnumerable<Claim> FindAll(string type)
|
||||
public virtual IEnumerable<Claim> FindAll (string type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
foreach (var c in claims)
|
||||
if (c.Type == type)
|
||||
if (string.Equals (c.Type, type, StringComparison.OrdinalIgnoreCase))
|
||||
yield return c;
|
||||
}
|
||||
|
||||
@@ -227,7 +238,7 @@ namespace System.Security.Claims {
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
foreach (var c in claims)
|
||||
if (c.Type == type)
|
||||
if (string.Equals (c.Type, type, StringComparison.OrdinalIgnoreCase))
|
||||
return c;
|
||||
return null;
|
||||
}
|
||||
@@ -249,7 +260,7 @@ namespace System.Security.Claims {
|
||||
if (value == null)
|
||||
throw new ArgumentNullException ("value");
|
||||
foreach (var c in claims){
|
||||
if (c.Type == type && c.Value == value)
|
||||
if (string.Equals (c.Type, type, StringComparison.OrdinalIgnoreCase) && c.Value == value)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
27
mcs/class/corlib/System.Security.Claims/ClaimsPrincipal.cs
Normal file → Executable file
27
mcs/class/corlib/System.Security.Claims/ClaimsPrincipal.cs
Normal file → Executable file
@@ -26,7 +26,7 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#if NET_4_5
|
||||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Principal;
|
||||
using System.Runtime.Serialization;
|
||||
@@ -68,7 +68,7 @@ namespace System.Security.Claims {
|
||||
throw new ArgumentNullException ("identity");
|
||||
|
||||
identities = new List<ClaimsIdentity> ();
|
||||
identities.Add (new ClaimsIdentity (identity));
|
||||
identities.Add (identity as ClaimsIdentity ?? new ClaimsIdentity (identity));
|
||||
}
|
||||
|
||||
public ClaimsPrincipal (IPrincipal principal)
|
||||
@@ -186,6 +186,29 @@ namespace System.Security.Claims {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool HasClaim (string type, string value)
|
||||
{
|
||||
foreach(var claim in Claims){
|
||||
if (claim.Type == type && claim.Value == value)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual Claim FindFirst (string type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
return FindFirst(x => x.Type == type);
|
||||
}
|
||||
|
||||
public virtual IEnumerable<Claim> FindAll (string type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException ("type");
|
||||
return FindAll(x => x.Type == type);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
//
|
||||
// System.Security.Principal.GenericIdentity.cs
|
||||
//
|
||||
// Author:
|
||||
// Authors:
|
||||
// Miguel de Icaza (miguel@ximian.com)
|
||||
// Marek Safar (marek.safar@gmail.com)
|
||||
//
|
||||
// (C) Ximian, Inc. http://www.ximian.com
|
||||
// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
|
||||
@@ -28,12 +29,22 @@
|
||||
//
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
#if NET_4_5
|
||||
using System.Security.Claims;
|
||||
#endif
|
||||
|
||||
namespace System.Security.Principal {
|
||||
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public class GenericIdentity : IIdentity {
|
||||
public class GenericIdentity :
|
||||
#if NET_4_5
|
||||
ClaimsIdentity
|
||||
#else
|
||||
IIdentity
|
||||
#endif
|
||||
{
|
||||
|
||||
// field names are serialization compatible with .net
|
||||
private string m_name;
|
||||
@@ -49,6 +60,10 @@ namespace System.Security.Principal {
|
||||
|
||||
m_name = name;
|
||||
m_type = type;
|
||||
|
||||
#if NET_4_5
|
||||
AddDefaultClaim (name);
|
||||
#endif
|
||||
}
|
||||
|
||||
public GenericIdentity (string name)
|
||||
@@ -56,22 +71,52 @@ namespace System.Security.Principal {
|
||||
{
|
||||
}
|
||||
|
||||
public virtual string AuthenticationType {
|
||||
#if NET_4_5
|
||||
protected GenericIdentity (GenericIdentity identity)
|
||||
: base (identity)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#if NET_4_5
|
||||
override
|
||||
#else
|
||||
virtual
|
||||
#endif
|
||||
public string AuthenticationType {
|
||||
get {
|
||||
return m_type;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string Name {
|
||||
#if NET_4_5
|
||||
override
|
||||
#else
|
||||
virtual
|
||||
#endif
|
||||
public string Name {
|
||||
get {
|
||||
return m_name;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsAuthenticated {
|
||||
#if NET_4_5
|
||||
override
|
||||
#else
|
||||
virtual
|
||||
#endif
|
||||
public bool IsAuthenticated {
|
||||
get {
|
||||
return (m_name.Length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
#if NET_4_5
|
||||
public override IEnumerable<Claim> Claims {
|
||||
get {
|
||||
return base.Claims;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@@ -29,12 +29,21 @@
|
||||
//
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
#if NET_4_5
|
||||
using System.Security.Claims;
|
||||
#endif
|
||||
|
||||
namespace System.Security.Principal {
|
||||
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public class GenericPrincipal : IPrincipal {
|
||||
public class GenericPrincipal :
|
||||
#if NET_4_5
|
||||
ClaimsPrincipal
|
||||
#else
|
||||
IPrincipal
|
||||
#endif
|
||||
{
|
||||
|
||||
// field names are serialization compatible with .net
|
||||
private IIdentity m_identity;
|
||||
@@ -58,11 +67,21 @@ namespace System.Security.Principal {
|
||||
get { return m_roles; }
|
||||
}
|
||||
|
||||
public virtual IIdentity Identity {
|
||||
#if NET_4_5
|
||||
override
|
||||
#else
|
||||
virtual
|
||||
#endif
|
||||
public IIdentity Identity {
|
||||
get { return m_identity; }
|
||||
}
|
||||
|
||||
public virtual bool IsInRole (string role)
|
||||
#if NET_4_5
|
||||
override
|
||||
#else
|
||||
virtual
|
||||
#endif
|
||||
public bool IsInRole (string role)
|
||||
{
|
||||
if (m_roles == null)
|
||||
return false;
|
||||
|
@@ -52,6 +52,11 @@ namespace System.Security.Principal {
|
||||
|
||||
static private IntPtr invalidWindows = IntPtr.Zero;
|
||||
|
||||
#if NET_4_5
|
||||
[NonSerialized]
|
||||
public new const string DefaultIssuer = "AD AUTHORITY";
|
||||
#endif
|
||||
|
||||
[SecurityPermission (SecurityAction.Demand, ControlPrincipal=true)]
|
||||
public WindowsIdentity (IntPtr userToken)
|
||||
: this (userToken, null, WindowsAccountType.Normal, false)
|
||||
|
@@ -30,13 +30,21 @@
|
||||
using System.Collections;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if NET_4_5
|
||||
using System.Security.Claims;
|
||||
#endif
|
||||
|
||||
namespace System.Security.Principal {
|
||||
|
||||
[Serializable]
|
||||
[ComVisible (true)]
|
||||
public class WindowsPrincipal : IPrincipal {
|
||||
|
||||
public class WindowsPrincipal :
|
||||
#if NET_4_5
|
||||
ClaimsPrincipal
|
||||
#else
|
||||
IPrincipal
|
||||
#endif
|
||||
{
|
||||
private WindowsIdentity _identity;
|
||||
// http://groups.google.ca/groups?q=WindowsPrincipal+m_roles&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OghXf4OgCHA.4228%40tkmsftngp08&rnum=4
|
||||
private string [] m_roles;
|
||||
@@ -53,8 +61,12 @@ namespace System.Security.Principal {
|
||||
}
|
||||
|
||||
// properties
|
||||
|
||||
public virtual IIdentity Identity {
|
||||
#if NET_4_5
|
||||
override
|
||||
#else
|
||||
virtual
|
||||
#endif
|
||||
public IIdentity Identity {
|
||||
get { return _identity; }
|
||||
}
|
||||
|
||||
@@ -102,7 +114,12 @@ namespace System.Security.Principal {
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsInRole (string role)
|
||||
#if NET_4_5
|
||||
override
|
||||
#else
|
||||
virtual
|
||||
#endif
|
||||
public bool IsInRole (string role)
|
||||
{
|
||||
if (role == null)
|
||||
return false; // ArgumentNullException
|
||||
|
@@ -1040,17 +1040,12 @@ public abstract class Encoding : ICloneable
|
||||
}
|
||||
|
||||
// Forwarding decoder implementation.
|
||||
private sealed class ForwardingDecoder : Decoder
|
||||
private sealed class ForwardingDecoder : EncodingDecoder
|
||||
{
|
||||
private Encoding encoding;
|
||||
|
||||
// Constructor.
|
||||
public ForwardingDecoder (Encoding enc)
|
||||
: base (enc)
|
||||
{
|
||||
encoding = enc;
|
||||
DecoderFallback fallback = encoding.DecoderFallback;
|
||||
if (fallback != null)
|
||||
Fallback = fallback;
|
||||
}
|
||||
|
||||
// Override inherited methods.
|
||||
@@ -1068,17 +1063,12 @@ public abstract class Encoding : ICloneable
|
||||
} // class ForwardingDecoder
|
||||
|
||||
// Forwarding encoder implementation.
|
||||
private sealed class ForwardingEncoder : Encoder
|
||||
private sealed class ForwardingEncoder : EncodingEncoder
|
||||
{
|
||||
private Encoding encoding;
|
||||
|
||||
// Constructor.
|
||||
public ForwardingEncoder (Encoding enc)
|
||||
: base (enc)
|
||||
{
|
||||
encoding = enc;
|
||||
EncoderFallback fallback = encoding.EncoderFallback;
|
||||
if (fallback != null)
|
||||
Fallback = fallback;
|
||||
}
|
||||
|
||||
// Override inherited methods.
|
||||
|
102
mcs/class/corlib/System.Text/EncodingDecoder.cs
Normal file
102
mcs/class/corlib/System.Text/EncodingDecoder.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
//
|
||||
// System.Text.EncodingDecoder.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marcos Henrich (marcos.henrich@xamarin.com)
|
||||
//
|
||||
// Copyright (C) 2014 Xamarin Inc (http://www.xamarin.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.Runtime.InteropServices;
|
||||
|
||||
namespace System.Text {
|
||||
|
||||
abstract class EncodingDecoder : Decoder {
|
||||
protected readonly Encoding encoding;
|
||||
|
||||
// Constructor.
|
||||
protected EncodingDecoder (Encoding encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
var fallback = encoding.DecoderFallback;
|
||||
if (fallback != null)
|
||||
Fallback = fallback;
|
||||
}
|
||||
|
||||
public unsafe override void Convert (
|
||||
byte* bytes, int byteCount,
|
||||
char* chars, int charCount, bool flush,
|
||||
out int bytesUsed, out int charsUsed, out bool completed)
|
||||
{
|
||||
if (chars == null)
|
||||
throw new ArgumentNullException ("chars");
|
||||
if (bytes == null)
|
||||
throw new ArgumentNullException ("bytes");
|
||||
if (charCount < 0)
|
||||
throw new ArgumentOutOfRangeException ("charCount");
|
||||
if (byteCount < 0)
|
||||
throw new ArgumentOutOfRangeException ("byteCount");
|
||||
|
||||
bytesUsed = encoding.GetByteCount(chars, charCount);
|
||||
|
||||
if (bytesUsed > byteCount) {
|
||||
charsUsed = encoding.GetChars (bytes, byteCount, chars, charCount);
|
||||
bytesUsed = encoding.GetByteCount (chars, charsUsed);
|
||||
} else
|
||||
charsUsed = encoding.GetChars (bytes, bytesUsed, chars, charCount);
|
||||
|
||||
|
||||
completed = bytesUsed == byteCount;
|
||||
}
|
||||
|
||||
public override void Convert (
|
||||
byte [] bytes, int byteIndex, int byteCount,
|
||||
char [] chars, int charIndex, int charCount, bool flush,
|
||||
out int bytesUsed, out int charsUsed, out bool completed)
|
||||
{
|
||||
if (chars == null)
|
||||
throw new ArgumentNullException ("chars");
|
||||
if (bytes == null)
|
||||
throw new ArgumentNullException ("bytes");
|
||||
if (charIndex < 0)
|
||||
throw new ArgumentOutOfRangeException ("charIndex");
|
||||
if (charCount < 0 || chars.Length < charIndex + charCount)
|
||||
throw new ArgumentOutOfRangeException ("charCount");
|
||||
if (byteIndex < 0)
|
||||
throw new ArgumentOutOfRangeException ("byteIndex");
|
||||
if (byteCount < 0 || bytes.Length < byteIndex + byteCount)
|
||||
throw new ArgumentOutOfRangeException ("byteCount");
|
||||
|
||||
bytesUsed = encoding.GetByteCount(chars, charIndex, charCount);
|
||||
|
||||
if (bytesUsed > byteCount) {
|
||||
charsUsed = encoding.GetChars (bytes, byteIndex, byteCount, chars, charIndex);
|
||||
bytesUsed = encoding.GetByteCount (chars, charIndex, charsUsed);
|
||||
} else
|
||||
charsUsed = encoding.GetChars (bytes, byteIndex, bytesUsed, chars, charIndex);
|
||||
|
||||
completed = bytesUsed == byteCount;
|
||||
}
|
||||
}; // class EncodingDecoder
|
||||
|
||||
}; // namespace System.Text
|
99
mcs/class/corlib/System.Text/EncodingEncoder.cs
Normal file
99
mcs/class/corlib/System.Text/EncodingEncoder.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// System.Text.EncodingEncoder.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marcos Henrich (marcos.henrich@xamarin.com)
|
||||
//
|
||||
// Copyright (C) 2014 Xamarin Inc (http://www.xamarin.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.Runtime.InteropServices;
|
||||
|
||||
namespace System.Text {
|
||||
|
||||
abstract class EncodingEncoder : Encoder {
|
||||
protected readonly Encoding encoding;
|
||||
|
||||
// Constructor.
|
||||
protected EncodingEncoder (Encoding encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
var fallback = encoding.EncoderFallback;
|
||||
if (fallback != null)
|
||||
Fallback = fallback;
|
||||
}
|
||||
|
||||
public unsafe override void Convert (
|
||||
char* chars, int charCount,
|
||||
byte* bytes, int byteCount, bool flush,
|
||||
out int charsUsed, out int bytesUsed, out bool completed)
|
||||
{
|
||||
if (chars == null)
|
||||
throw new ArgumentNullException ("chars");
|
||||
if (bytes == null)
|
||||
throw new ArgumentNullException ("bytes");
|
||||
if (charCount < 0)
|
||||
throw new ArgumentOutOfRangeException ("charCount");
|
||||
if (byteCount < 0)
|
||||
throw new ArgumentOutOfRangeException ("byteCount");
|
||||
|
||||
charsUsed = encoding.GetCharCount (bytes, byteCount);
|
||||
|
||||
if (charsUsed > charCount)
|
||||
charsUsed = charCount;
|
||||
|
||||
bytesUsed = encoding.GetBytes (chars, charsUsed, bytes, byteCount);
|
||||
|
||||
completed = charsUsed == charCount;
|
||||
}
|
||||
|
||||
public override void Convert (
|
||||
char [] chars, int charIndex, int charCount,
|
||||
byte [] bytes, int byteIndex, int byteCount, bool flush,
|
||||
out int charsUsed, out int bytesUsed, out bool completed)
|
||||
{
|
||||
if (chars == null)
|
||||
throw new ArgumentNullException ("chars");
|
||||
if (bytes == null)
|
||||
throw new ArgumentNullException ("bytes");
|
||||
if (charIndex < 0)
|
||||
throw new ArgumentOutOfRangeException ("charIndex");
|
||||
if (charCount < 0 || chars.Length < charIndex + charCount)
|
||||
throw new ArgumentOutOfRangeException ("charCount");
|
||||
if (byteIndex < 0)
|
||||
throw new ArgumentOutOfRangeException ("byteIndex");
|
||||
if (byteCount < 0 || bytes.Length < byteIndex + byteCount)
|
||||
throw new ArgumentOutOfRangeException ("byteCount");
|
||||
|
||||
charsUsed = encoding.GetCharCount (bytes, byteIndex, byteCount);
|
||||
|
||||
if (charsUsed > charCount)
|
||||
charsUsed = charCount;
|
||||
|
||||
bytesUsed = encoding.GetBytes (chars, charIndex, charsUsed, bytes, byteIndex);
|
||||
|
||||
completed = charsUsed == charCount;
|
||||
}
|
||||
}; // class EncodingEncoder
|
||||
|
||||
}; // namespace System.Text
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user