You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -0,0 +1,38 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="SecUtility.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Util {
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
internal static class SecurityServices {
|
||||
|
||||
// We don't trim the param before checking with password parameters
|
||||
internal static void CheckPasswordParameter(string param, string paramName) {
|
||||
if (param == null) {
|
||||
throw new ArgumentNullException(paramName);
|
||||
}
|
||||
|
||||
CheckForEmptyParameter(param, paramName);
|
||||
}
|
||||
|
||||
internal static void CheckForEmptyOrWhiteSpaceParameter(ref string param, string paramName) {
|
||||
if (param == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
param = param.Trim();
|
||||
CheckForEmptyParameter(param, paramName);
|
||||
}
|
||||
|
||||
internal static void CheckForEmptyParameter(string param, string paramName) {
|
||||
if (param.Length < 1) {
|
||||
throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, ApplicationServicesStrings.Parameter_can_not_be_empty, paramName), paramName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="SystemWebProxy.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Util {
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Web.Security;
|
||||
using System.Security.Permissions;
|
||||
|
||||
// Because this assembly ships in the client SKU, whereas System.Web.dll ships in the Extended SKU, we need to
|
||||
// proxy any usage of System.Web.dll. This allows us to fail gracefully if the Extended SKU is not present.
|
||||
// Users can avoid this failure by overridding all virtual members on both of these types which will prevent
|
||||
// this class, and hence, System.Web.dll, from ever being called.
|
||||
internal static class SystemWebProxy {
|
||||
|
||||
public static readonly IMembershipAdapter Membership = GetMembershipAdapter();
|
||||
|
||||
private static IMembershipAdapter GetMembershipAdapter() {
|
||||
IMembershipAdapter membership = CreateSystemWebMembershipAdapter();
|
||||
if (membership == null) {
|
||||
membership = new DefaultMembershipAdapter();
|
||||
}
|
||||
|
||||
return membership;
|
||||
}
|
||||
|
||||
private static IMembershipAdapter CreateSystemWebMembershipAdapter() {
|
||||
Type type = Type.GetType("System.Web.Security.MembershipAdapter, " + AssemblyRef.SystemWeb, throwOnError:false);
|
||||
if (type != null) {
|
||||
// Running on Extended SKU
|
||||
|
||||
return (IMembershipAdapter)DangerousCreateInstance(type);
|
||||
}
|
||||
|
||||
// Running on Client SKU
|
||||
return null;
|
||||
}
|
||||
|
||||
// Partially trusted callers might not have permissions to create an instance of
|
||||
// System.Web’s MembershipAdapter type (it’s an internal type), so give them access.
|
||||
[ReflectionPermission(SecurityAction.Assert, Flags=ReflectionPermissionFlag.MemberAccess)]
|
||||
private static object DangerousCreateInstance(Type type) {
|
||||
|
||||
return Activator.CreateInstance(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user