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
252
mcs/class/referencesource/System.Web.ApplicationServices/ApplicationServicesStrings.Designer.cs
generated
Normal file
252
mcs/class/referencesource/System.Web.ApplicationServices/ApplicationServicesStrings.Designer.cs
generated
Normal file
@@ -0,0 +1,252 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17617
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class ApplicationServicesStrings {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal ApplicationServicesStrings() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("System.Web.ApplicationServicesStrings", typeof(ApplicationServicesStrings).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You must specify a non-autogenerated machine key to store passwords in the encrypted format. Either specify a different passwordFormat, or change the machineKey configuration to use a non-autogenerated decryption key..
|
||||
/// </summary>
|
||||
internal static string Can_not_use_encrypted_passwords_with_autogen_keys {
|
||||
get {
|
||||
return ResourceManager.GetString("Can_not_use_encrypted_passwords_with_autogen_keys", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The host forbids the use of custom loaders..
|
||||
/// </summary>
|
||||
internal static string CustomLoader_ForbiddenByHost {
|
||||
get {
|
||||
return ResourceManager.GetString("CustomLoader_ForbiddenByHost", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The provided type '{0}' must implement the ICustomLoader interface..
|
||||
/// </summary>
|
||||
internal static string CustomLoader_MustImplementICustomLoader {
|
||||
get {
|
||||
return ResourceManager.GetString("CustomLoader_MustImplementICustomLoader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The assembly '{0}' did not contain an assembly-level CustomLoaderAttribute..
|
||||
/// </summary>
|
||||
internal static string CustomLoader_NoAttributeFound {
|
||||
get {
|
||||
return ResourceManager.GetString("CustomLoader_NoAttributeFound", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Custom loaders can only be used by fully-trusted applications (<trust level="Full" />)..
|
||||
/// </summary>
|
||||
internal static string CustomLoader_NotInFullTrust {
|
||||
get {
|
||||
return ResourceManager.GetString("CustomLoader_NotInFullTrust", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The E-mail address is already in use..
|
||||
/// </summary>
|
||||
internal static string Membership_DuplicateEmail {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_DuplicateEmail", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The provider user key is already in use..
|
||||
/// </summary>
|
||||
internal static string Membership_DuplicateProviderUserKey {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_DuplicateProviderUserKey", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The username is already in use..
|
||||
/// </summary>
|
||||
internal static string Membership_DuplicateUserName {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_DuplicateUserName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The password-answer supplied is invalid..
|
||||
/// </summary>
|
||||
internal static string Membership_InvalidAnswer {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_InvalidAnswer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The E-mail supplied is invalid..
|
||||
/// </summary>
|
||||
internal static string Membership_InvalidEmail {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_InvalidEmail", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The password supplied is invalid. Passwords must conform to the password strength requirements configured for the default provider..
|
||||
/// </summary>
|
||||
internal static string Membership_InvalidPassword {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_InvalidPassword", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The provider user key supplied is invalid. It must be of type System.Guid..
|
||||
/// </summary>
|
||||
internal static string Membership_InvalidProviderUserKey {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_InvalidProviderUserKey", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The password-question supplied is invalid. Note that the current provider configuration requires a valid password question and answer. As a result, a CreateUser overload that accepts question and answer parameters must also be used..
|
||||
/// </summary>
|
||||
internal static string Membership_InvalidQuestion {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_InvalidQuestion", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The username supplied is invalid..
|
||||
/// </summary>
|
||||
internal static string Membership_InvalidUserName {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_InvalidUserName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No Error..
|
||||
/// </summary>
|
||||
internal static string Membership_no_error {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_no_error", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The membership provider name specified is invalid..
|
||||
/// </summary>
|
||||
internal static string Membership_provider_name_invalid {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_provider_name_invalid", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The user was rejected..
|
||||
/// </summary>
|
||||
internal static string Membership_UserRejected {
|
||||
get {
|
||||
return ResourceManager.GetString("Membership_UserRejected", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The parameter '{0}' must not be empty..
|
||||
/// </summary>
|
||||
internal static string Parameter_can_not_be_empty {
|
||||
get {
|
||||
return ResourceManager.GetString("Parameter_can_not_be_empty", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This member is not supported on the .NET Framework Client Profile..
|
||||
/// </summary>
|
||||
internal static string Platform_not_supported {
|
||||
get {
|
||||
return ResourceManager.GetString("Platform_not_supported", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The Provider encountered an unknown error..
|
||||
/// </summary>
|
||||
internal static string Provider_Error {
|
||||
get {
|
||||
return ResourceManager.GetString("Provider_Error", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Provider must implement the class '{0}'..
|
||||
/// </summary>
|
||||
internal static string Provider_must_implement_type {
|
||||
get {
|
||||
return ResourceManager.GetString("Provider_must_implement_type", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MembershipPasswordCompatibilityMode.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Configuration {
|
||||
public enum MembershipPasswordCompatibilityMode
|
||||
{
|
||||
Framework20 = 0,
|
||||
Framework40 = 1,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="CustomLoaderAttribute.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Hosting {
|
||||
using System;
|
||||
|
||||
// Used to locate a custom loader implementation within a bin-deployed assembly.
|
||||
|
||||
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)]
|
||||
public sealed class CustomLoaderAttribute : Attribute {
|
||||
public CustomLoaderAttribute(Type customLoaderType) {
|
||||
if (customLoaderType == null) {
|
||||
throw new ArgumentNullException("customLoaderType");
|
||||
}
|
||||
|
||||
// CustomLoaderHelper will verify that the type implements the correct interface.
|
||||
CustomLoaderType = customLoaderType;
|
||||
}
|
||||
|
||||
public Type CustomLoaderType { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="CustomLoaderHelper.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Hosting {
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Remoting;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
// Used to locate a custom loader implementation within a bin-deployed assembly.
|
||||
|
||||
internal sealed class CustomLoaderHelper : MarshalByRefObject {
|
||||
|
||||
// the first framework version where the custom loader feature was implemented
|
||||
private static readonly string _customLoaderTargetFrameworkName = new FrameworkName(".NETFramework", new Version(4, 5, 1)).ToString();
|
||||
|
||||
private static readonly string _customLoaderAssemblyName = typeof(CustomLoaderHelper).Assembly.FullName;
|
||||
private static readonly string _customLoaderTypeName = typeof(CustomLoaderHelper).FullName;
|
||||
private static readonly Guid IID_ICustomLoader = new Guid("50A3CE65-2F9F-44E9-9094-32C6C928F966");
|
||||
|
||||
// Instances of this type should only ever be created via reflection (see call to CreateObjectAndUnwrap
|
||||
// in GetCustomLoader).
|
||||
private CustomLoaderHelper() { }
|
||||
|
||||
internal static IObjectHandle GetCustomLoader(ICustomLoaderHelperFunctions helperFunctions, string appConfigMetabasePath, string configFilePath, string customLoaderPhysicalPath, out AppDomain newlyCreatedAppDomain) {
|
||||
// Step 1: Does the host allow custom loaders?
|
||||
|
||||
bool? customLoaderIsEnabled = helperFunctions.CustomLoaderIsEnabled;
|
||||
if (customLoaderIsEnabled.HasValue) {
|
||||
if ((bool)customLoaderIsEnabled) {
|
||||
// The custom loader is enabled; move on to the next step.
|
||||
}
|
||||
else {
|
||||
// The custom loader is disabled, fail.
|
||||
throw new NotSupportedException(ApplicationServicesStrings.CustomLoader_ForbiddenByHost);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// The host hasn't set a policy, so we'll fall back to our default logic of checking the application's trust level.
|
||||
if (!IsFullyTrusted(helperFunctions, appConfigMetabasePath)) {
|
||||
throw new NotSupportedException(ApplicationServicesStrings.CustomLoader_NotInFullTrust);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Create the new AD
|
||||
|
||||
string binFolderPhysicalPath = helperFunctions.MapPath("/bin/");
|
||||
|
||||
AppDomainSetup setup = new AppDomainSetup() {
|
||||
PrivateBinPathProbe = "*", // disable loading from app base
|
||||
PrivateBinPath = binFolderPhysicalPath,
|
||||
ApplicationBase = helperFunctions.AppPhysicalPath,
|
||||
TargetFrameworkName = _customLoaderTargetFrameworkName
|
||||
};
|
||||
|
||||
if (configFilePath != null) {
|
||||
setup.ConfigurationFile = configFilePath;
|
||||
}
|
||||
|
||||
AppDomain newAppDomainForCustomLoader = AppDomain.CreateDomain("aspnet-custom-loader-" + Guid.NewGuid(), null, setup);
|
||||
try {
|
||||
// Step 3: Instantiate helper in new AD so that we can get a reference to the loader
|
||||
CustomLoaderHelper helper = (CustomLoaderHelper)newAppDomainForCustomLoader.CreateInstanceAndUnwrap(_customLoaderAssemblyName, _customLoaderTypeName,
|
||||
ignoreCase: false,
|
||||
bindingAttr: BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance | BindingFlags.Instance,
|
||||
binder: null,
|
||||
args: null,
|
||||
culture: null,
|
||||
activationAttributes: null);
|
||||
ObjectHandle ohCustomLoader = helper.GetCustomLoaderImpl(customLoaderPhysicalPath);
|
||||
|
||||
// If we got this far, success!
|
||||
newlyCreatedAppDomain = newAppDomainForCustomLoader;
|
||||
return ohCustomLoader;
|
||||
}
|
||||
catch {
|
||||
// If something went wrong, kill the new AD.
|
||||
AppDomain.Unload(newAppDomainForCustomLoader);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private ObjectHandle GetCustomLoaderImpl(string customLoaderPhysicalPath) {
|
||||
// Step 4: Find the implementation in the custom loader assembly
|
||||
|
||||
// Since we have set the private bin path, we can use this call to Assembly.Load
|
||||
// to avoid the load-from context, which has weird behaviors.
|
||||
AssemblyName customLoaderAssemblyName = AssemblyName.GetAssemblyName(customLoaderPhysicalPath);
|
||||
Assembly customLoaderAssembly = Assembly.Load(customLoaderAssemblyName);
|
||||
CustomLoaderAttribute customLoaderAttribute = customLoaderAssembly.GetCustomAttribute<CustomLoaderAttribute>();
|
||||
|
||||
if (customLoaderAttribute == null) {
|
||||
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, ApplicationServicesStrings.CustomLoader_NoAttributeFound, customLoaderAssemblyName));
|
||||
}
|
||||
|
||||
// Step 5: Instantiate the custom loader and return a reference back to native code
|
||||
|
||||
object customLoader = Activator.CreateInstance(customLoaderAttribute.CustomLoaderType);
|
||||
|
||||
// This check isn't strictly necessary since the unmanaged layer will handle QueryInterface failures
|
||||
// appropriately, but we have an opportunity to provide a better error message at this layer.
|
||||
if (!ObjectImplementsComInterface(customLoader, IID_ICustomLoader)) {
|
||||
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, ApplicationServicesStrings.CustomLoader_MustImplementICustomLoader, customLoader.GetType()));
|
||||
}
|
||||
|
||||
return new ObjectHandle(customLoader);
|
||||
}
|
||||
|
||||
private static bool IsFullyTrusted(ICustomLoaderHelperFunctions helperFunctions, string appConfigMetabasePath) {
|
||||
// The managed configuration system hasn't yet been instantiated but the IIS native config system understands
|
||||
// ASP.NET configuration and honors hierarchy and section locking.
|
||||
|
||||
try {
|
||||
// Must exactly match <trust level="Full" />, as this is what ApplicationManager expects.
|
||||
string trustLevel = helperFunctions.GetTrustLevel(appConfigMetabasePath);
|
||||
return String.Equals("Full", trustLevel, StringComparison.Ordinal);
|
||||
}
|
||||
catch {
|
||||
// If any of the sections are locked or there is a config error, bail.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ObjectImplementsComInterface(object o, Guid iid) {
|
||||
IntPtr pUnknown = IntPtr.Zero;
|
||||
IntPtr pInterface = IntPtr.Zero;
|
||||
|
||||
try {
|
||||
pUnknown = Marshal.GetIUnknownForObject(o); // AddRef
|
||||
int hr = Marshal.QueryInterface(pUnknown, ref iid, out pInterface); // AddRef
|
||||
return (hr == 0 && pInterface != IntPtr.Zero);
|
||||
}
|
||||
finally {
|
||||
if (pUnknown != IntPtr.Zero) {
|
||||
Marshal.Release(pUnknown);
|
||||
}
|
||||
if (pInterface != IntPtr.Zero) {
|
||||
Marshal.Release(pInterface);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ICustomLoaderHelperFunctions.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Hosting {
|
||||
using System;
|
||||
|
||||
internal interface ICustomLoaderHelperFunctions {
|
||||
string AppPhysicalPath { get; }
|
||||
bool? CustomLoaderIsEnabled { get; } // true = always enabled, false = always disabled, null = check trust level
|
||||
|
||||
string GetTrustLevel(string appConfigMetabasePath);
|
||||
string MapPath(string relativePath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("System.Web, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")]
|
||||
|
||||
[module: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly",
|
||||
MessageId = "non-autogenerated", Scope = "resource", Target = "System.Web.ApplicationServicesStrings.resources",
|
||||
Justification = "The use of the word is correct in a technical context.")]
|
||||
|
||||
[module: SuppressMessage("Microsoft.Naming", "CA1701:ResourceStringCompoundWordsShouldBeCasedCorrectly",
|
||||
MessageId = "username", Scope = "resource", Target = "System.Web.ApplicationServicesStrings.resources",
|
||||
Justification = "The use of the word is correct in a technical context.")]
|
||||
@@ -0,0 +1,34 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="DefaultMembershipAdapter.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
using System;
|
||||
|
||||
internal class DefaultMembershipAdapter : IMembershipAdapter {
|
||||
public DefaultMembershipAdapter() {
|
||||
}
|
||||
|
||||
public MembershipProviderCollection Providers {
|
||||
get { throw new PlatformNotSupportedException(ApplicationServicesStrings.Platform_not_supported); }
|
||||
}
|
||||
|
||||
public int UserIsOnlineTimeWindow {
|
||||
get { throw new PlatformNotSupportedException(ApplicationServicesStrings.Platform_not_supported); }
|
||||
}
|
||||
|
||||
public bool IsDecryptionKeyAutogenerated {
|
||||
get { throw new PlatformNotSupportedException(ApplicationServicesStrings.Platform_not_supported); }
|
||||
}
|
||||
|
||||
public bool UsingCustomEncryption {
|
||||
get { throw new PlatformNotSupportedException(ApplicationServicesStrings.Platform_not_supported); }
|
||||
}
|
||||
|
||||
public byte[] EncryptOrDecryptData(bool encrypt, byte[] buffer, bool useLegacyMode) {
|
||||
throw new PlatformNotSupportedException(ApplicationServicesStrings.Platform_not_supported);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="IMembershipAdapter.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
using System;
|
||||
|
||||
internal interface IMembershipAdapter {
|
||||
MembershipProviderCollection Providers {
|
||||
get;
|
||||
}
|
||||
|
||||
int UserIsOnlineTimeWindow {
|
||||
get;
|
||||
}
|
||||
|
||||
bool IsDecryptionKeyAutogenerated {
|
||||
get;
|
||||
}
|
||||
|
||||
bool UsingCustomEncryption {
|
||||
get;
|
||||
}
|
||||
|
||||
byte[] EncryptOrDecryptData(bool encrypt, byte[] buffer, bool useLegacyMode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MembershipCreateStatus.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
public enum MembershipCreateStatus {
|
||||
|
||||
Success = 0,
|
||||
|
||||
InvalidUserName = 1, // invalid user name
|
||||
|
||||
InvalidPassword = 2, // new password was not accepted (invalid format)
|
||||
|
||||
InvalidQuestion = 3, // new question was not accepted (invalid format)
|
||||
|
||||
InvalidAnswer = 4, // new passwordAnswer was not acceppted (invalid format)
|
||||
|
||||
InvalidEmail = 5, // new email was not accepted (invalid format)
|
||||
|
||||
DuplicateUserName = 6, // username already exists
|
||||
|
||||
DuplicateEmail = 7, // email already exists
|
||||
|
||||
UserRejected = 8, // provider rejected user (for some user-specific reason)
|
||||
|
||||
InvalidProviderUserKey = 9, // new provider user key was not accepted (invalid format)
|
||||
|
||||
DuplicateProviderUserKey = 10, // provider user key already exists
|
||||
|
||||
ProviderError = 11 // provider-specific error (couldn't map onto this enumeration)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MembershipCreateStatus.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Permissions;
|
||||
|
||||
[Serializable]
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
public class MembershipCreateUserException : Exception {
|
||||
|
||||
public MembershipCreateUserException(MembershipCreateStatus statusCode)
|
||||
: base(GetMessageFromStatusCode(statusCode)) {
|
||||
_StatusCode = statusCode;
|
||||
}
|
||||
|
||||
public MembershipCreateUserException(String message)
|
||||
: base(message) { }
|
||||
|
||||
|
||||
protected MembershipCreateUserException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context) {
|
||||
_StatusCode = (MembershipCreateStatus)info.GetInt32("_StatusCode");
|
||||
}
|
||||
|
||||
public MembershipCreateUserException() { }
|
||||
|
||||
public MembershipCreateUserException(String message, Exception innerException)
|
||||
: base(message, innerException) { }
|
||||
|
||||
private MembershipCreateStatus _StatusCode = MembershipCreateStatus.ProviderError;
|
||||
|
||||
public MembershipCreateStatus StatusCode { get { return _StatusCode; } }
|
||||
|
||||
[PermissionSet(SecurityAction.LinkDemand, Unrestricted = true)]
|
||||
// This is a Level 1 transparency assembly, so we can't use [SecurityCritical] directly as this public member
|
||||
// will still be safe-critical. However, the [PermissionSet] above provides equivalent link-time protection
|
||||
// as [SecurityCritical] does in a Level 2 transparency assembly.
|
||||
public override void GetObjectData(SerializationInfo info, StreamingContext context) {
|
||||
base.GetObjectData(info, context);
|
||||
info.AddValue("_StatusCode", _StatusCode);
|
||||
}
|
||||
|
||||
internal static string GetMessageFromStatusCode(MembershipCreateStatus statusCode) {
|
||||
switch (statusCode) {
|
||||
case MembershipCreateStatus.Success:
|
||||
return ApplicationServicesStrings.Membership_no_error;
|
||||
|
||||
case MembershipCreateStatus.InvalidUserName:
|
||||
return ApplicationServicesStrings.Membership_InvalidUserName;
|
||||
|
||||
case MembershipCreateStatus.InvalidPassword:
|
||||
return ApplicationServicesStrings.Membership_InvalidPassword;
|
||||
|
||||
case MembershipCreateStatus.InvalidQuestion:
|
||||
return ApplicationServicesStrings.Membership_InvalidQuestion;
|
||||
|
||||
case MembershipCreateStatus.InvalidAnswer:
|
||||
return ApplicationServicesStrings.Membership_InvalidAnswer;
|
||||
|
||||
case MembershipCreateStatus.InvalidEmail:
|
||||
return ApplicationServicesStrings.Membership_InvalidEmail;
|
||||
|
||||
case MembershipCreateStatus.InvalidProviderUserKey:
|
||||
return ApplicationServicesStrings.Membership_InvalidProviderUserKey;
|
||||
|
||||
case MembershipCreateStatus.DuplicateUserName:
|
||||
return ApplicationServicesStrings.Membership_DuplicateUserName;
|
||||
|
||||
case MembershipCreateStatus.DuplicateEmail:
|
||||
return ApplicationServicesStrings.Membership_DuplicateEmail;
|
||||
|
||||
case MembershipCreateStatus.DuplicateProviderUserKey:
|
||||
return ApplicationServicesStrings.Membership_DuplicateProviderUserKey;
|
||||
|
||||
case MembershipCreateStatus.UserRejected:
|
||||
return ApplicationServicesStrings.Membership_UserRejected;
|
||||
}
|
||||
|
||||
return ApplicationServicesStrings.Provider_Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MembershipPasswordException.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Permissions;
|
||||
|
||||
[Serializable]
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
public class MembershipPasswordException : Exception
|
||||
{
|
||||
|
||||
public MembershipPasswordException(String message) : base(message)
|
||||
{ }
|
||||
|
||||
|
||||
protected MembershipPasswordException(SerializationInfo info, StreamingContext context) : base(info, context)
|
||||
{ }
|
||||
|
||||
public MembershipPasswordException()
|
||||
{ }
|
||||
|
||||
public MembershipPasswordException(String message, Exception innerException) : base(message, innerException)
|
||||
{ }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MembershipPasswordFormat.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
public enum MembershipPasswordFormat {
|
||||
|
||||
// The password is stored in cleartext in the database.
|
||||
Clear = 0,
|
||||
|
||||
// The password is cryptographically hashed and stored in the database.
|
||||
Hashed = 1,
|
||||
|
||||
// The password is encrypted using reversible encryption (using <machineKey>) and stored in the database.
|
||||
Encrypted = 2,
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MembershipProvider.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
using System.Web;
|
||||
using System.Security.Principal;
|
||||
using System.Collections.Specialized;
|
||||
using System.Security.Permissions;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Configuration.Provider;
|
||||
using System.Text;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Util;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
/// <devdoc>
|
||||
/// <para>[To be supplied.]</para>
|
||||
/// </devdoc>
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
public abstract class MembershipProvider : ProviderBase
|
||||
{
|
||||
//
|
||||
// Property Section
|
||||
//
|
||||
|
||||
|
||||
// Public properties
|
||||
public abstract bool EnablePasswordRetrieval { get; }
|
||||
|
||||
public abstract bool EnablePasswordReset { get; }
|
||||
|
||||
public abstract bool RequiresQuestionAndAnswer { get; }
|
||||
|
||||
public abstract string ApplicationName { get; set; }
|
||||
|
||||
public abstract int MaxInvalidPasswordAttempts { get; }
|
||||
|
||||
public abstract int PasswordAttemptWindow { get; }
|
||||
|
||||
public abstract bool RequiresUniqueEmail { get; }
|
||||
|
||||
public abstract MembershipPasswordFormat PasswordFormat { get; }
|
||||
|
||||
public abstract int MinRequiredPasswordLength { get; }
|
||||
|
||||
public abstract int MinRequiredNonAlphanumericCharacters { get; }
|
||||
|
||||
public abstract string PasswordStrengthRegularExpression { get; }
|
||||
|
||||
//
|
||||
// Method Section
|
||||
//
|
||||
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract MembershipUser CreateUser( string username,
|
||||
string password,
|
||||
string email,
|
||||
string passwordQuestion,
|
||||
string passwordAnswer,
|
||||
bool isApproved,
|
||||
object providerUserKey,
|
||||
out MembershipCreateStatus status );
|
||||
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer);
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract string GetPassword(string username, string answer);
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract bool ChangePassword(string username, string oldPassword, string newPassword);
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract string ResetPassword(string username, string answer);
|
||||
|
||||
public abstract void UpdateUser(MembershipUser user);
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract bool ValidateUser(string username, string password);
|
||||
|
||||
|
||||
public abstract bool UnlockUser( string userName );
|
||||
|
||||
public abstract MembershipUser GetUser( object providerUserKey, bool userIsOnline );
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract MembershipUser GetUser(string username, bool userIsOnline);
|
||||
|
||||
// GetUser() can throw 1 type of exception:
|
||||
// 1. ArgumentException is thrown if:
|
||||
// A. Username is null, is empty, contains commas, or is longer than 256 characters
|
||||
internal MembershipUser GetUser(string username, bool userIsOnline, bool throwOnError) {
|
||||
MembershipUser user = null;
|
||||
|
||||
try {
|
||||
user = GetUser(username, userIsOnline);
|
||||
}
|
||||
catch (ArgumentException) {
|
||||
if (throwOnError) throw;
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
public abstract string GetUserNameByEmail(string email);
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract bool DeleteUser(string username, bool deleteAllRelatedData);
|
||||
|
||||
|
||||
public abstract MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords);
|
||||
|
||||
|
||||
public abstract int GetNumberOfUsersOnline();
|
||||
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords);
|
||||
|
||||
public abstract MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords);
|
||||
|
||||
protected virtual byte[] EncryptPassword( byte[] password)
|
||||
{
|
||||
return EncryptPassword(password, MembershipPasswordCompatibilityMode.Framework20);
|
||||
}
|
||||
|
||||
protected virtual byte[] EncryptPassword( byte[] password, MembershipPasswordCompatibilityMode legacyPasswordCompatibilityMode)
|
||||
{
|
||||
if (SystemWebProxy.Membership.IsDecryptionKeyAutogenerated)
|
||||
throw new ProviderException(ApplicationServicesStrings.Can_not_use_encrypted_passwords_with_autogen_keys);
|
||||
|
||||
return SystemWebProxy.Membership.EncryptOrDecryptData(true, password, legacyPasswordCompatibilityMode == MembershipPasswordCompatibilityMode.Framework20);
|
||||
}
|
||||
|
||||
protected virtual byte[] DecryptPassword( byte[] encodedPassword )
|
||||
{
|
||||
if (SystemWebProxy.Membership.IsDecryptionKeyAutogenerated)
|
||||
throw new ProviderException(ApplicationServicesStrings.Can_not_use_encrypted_passwords_with_autogen_keys);
|
||||
|
||||
try {
|
||||
return SystemWebProxy.Membership.EncryptOrDecryptData(false, encodedPassword, false);
|
||||
} catch {
|
||||
if (!SystemWebProxy.Membership.UsingCustomEncryption)
|
||||
throw;
|
||||
}
|
||||
return SystemWebProxy.Membership.EncryptOrDecryptData(false, encodedPassword, true);
|
||||
}
|
||||
|
||||
//
|
||||
// Event Section
|
||||
//
|
||||
|
||||
public event MembershipValidatePasswordEventHandler ValidatingPassword
|
||||
{
|
||||
add
|
||||
{
|
||||
_EventHandler += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_EventHandler -= value;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnValidatingPassword( ValidatePasswordEventArgs e )
|
||||
{
|
||||
if( _EventHandler != null )
|
||||
{
|
||||
_EventHandler( this, e );
|
||||
}
|
||||
}
|
||||
|
||||
private MembershipValidatePasswordEventHandler _EventHandler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MembershipProviderCollection.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
|
||||
using System;
|
||||
using System.Configuration.Provider;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// This has no hosting permission demands because of DevDiv Bugs 31461: ClientAppSvcs: ASP.net Provider support
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
public sealed class MembershipProviderCollection : ProviderCollection {
|
||||
|
||||
public override void Add(ProviderBase provider) {
|
||||
if (provider == null) {
|
||||
throw new ArgumentNullException("provider");
|
||||
}
|
||||
|
||||
if (!(provider is MembershipProvider)) {
|
||||
throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, ApplicationServicesStrings.Provider_must_implement_type, typeof(MembershipProvider).ToString()), "provider");
|
||||
}
|
||||
|
||||
base.Add(provider);
|
||||
}
|
||||
|
||||
new public MembershipProvider this[string name] {
|
||||
get {
|
||||
return (MembershipProvider)base[name];
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTo(MembershipProvider[] array, int index) {
|
||||
base.CopyTo(array, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,391 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MembershipUser.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
using System.Web;
|
||||
using System.Configuration.Provider;
|
||||
using System.Security.Principal;
|
||||
using System.Security.Permissions;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Web.Util;
|
||||
|
||||
/// <devdoc>
|
||||
/// <para>[To be supplied.]</para>
|
||||
/// </devdoc>
|
||||
[Serializable]
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
public class MembershipUser
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
// Public methods
|
||||
|
||||
public virtual string UserName{
|
||||
get { return _UserName;}}
|
||||
|
||||
public virtual object ProviderUserKey{
|
||||
get { return _ProviderUserKey;}}
|
||||
|
||||
|
||||
public virtual string Email{
|
||||
get { return _Email;}
|
||||
set { _Email = value; }}
|
||||
|
||||
|
||||
public virtual string PasswordQuestion{
|
||||
get { return _PasswordQuestion;}}
|
||||
|
||||
|
||||
public virtual string Comment{
|
||||
get { return _Comment;}
|
||||
set { _Comment = value;}}
|
||||
|
||||
|
||||
public virtual bool IsApproved{
|
||||
get { return _IsApproved;}
|
||||
set { _IsApproved = value; } }
|
||||
|
||||
public virtual bool IsLockedOut
|
||||
{
|
||||
get { return _IsLockedOut; }
|
||||
}
|
||||
|
||||
public virtual DateTime LastLockoutDate
|
||||
{
|
||||
get { return _LastLockoutDate.ToLocalTime(); }
|
||||
}
|
||||
|
||||
public virtual DateTime CreationDate {
|
||||
get { return _CreationDate.ToLocalTime(); }
|
||||
}
|
||||
|
||||
public virtual DateTime LastLoginDate {
|
||||
get { return _LastLoginDate.ToLocalTime(); }
|
||||
set { _LastLoginDate = value.ToUniversalTime(); } }
|
||||
|
||||
|
||||
public virtual DateTime LastActivityDate {
|
||||
get { return _LastActivityDate.ToLocalTime(); }
|
||||
set { _LastActivityDate = value.ToUniversalTime(); } }
|
||||
|
||||
|
||||
public virtual DateTime LastPasswordChangedDate {
|
||||
get { return _LastPasswordChangedDate.ToLocalTime(); }
|
||||
}
|
||||
|
||||
public virtual bool IsOnline {
|
||||
get {
|
||||
TimeSpan ts = new TimeSpan(0, SystemWebProxy.Membership.UserIsOnlineTimeWindow, 0);
|
||||
DateTime dt = DateTime.UtcNow.Subtract(ts);
|
||||
return LastActivityDate.ToUniversalTime() > dt;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return UserName;
|
||||
}
|
||||
|
||||
public virtual string ProviderName
|
||||
{
|
||||
get { return _ProviderName; }
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// CTor
|
||||
|
||||
public MembershipUser(
|
||||
string providerName,
|
||||
string name,
|
||||
object providerUserKey,
|
||||
string email,
|
||||
string passwordQuestion,
|
||||
string comment,
|
||||
bool isApproved,
|
||||
bool isLockedOut,
|
||||
DateTime creationDate,
|
||||
DateTime lastLoginDate,
|
||||
DateTime lastActivityDate,
|
||||
DateTime lastPasswordChangedDate,
|
||||
DateTime lastLockoutDate )
|
||||
{
|
||||
if ( providerName == null || SystemWebProxy.Membership.Providers[providerName] == null )
|
||||
{
|
||||
throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, ApplicationServicesStrings.Membership_provider_name_invalid), "providerName" );
|
||||
}
|
||||
|
||||
if( name != null )
|
||||
{
|
||||
name = name.Trim();
|
||||
}
|
||||
|
||||
if( email != null )
|
||||
{
|
||||
email = email.Trim();
|
||||
}
|
||||
|
||||
if( passwordQuestion != null )
|
||||
{
|
||||
passwordQuestion = passwordQuestion.Trim();
|
||||
}
|
||||
|
||||
_ProviderName = providerName;
|
||||
_UserName = name;
|
||||
_ProviderUserKey = providerUserKey;
|
||||
_Email = email;
|
||||
_PasswordQuestion = passwordQuestion;
|
||||
_Comment = comment;
|
||||
_IsApproved = isApproved;
|
||||
_IsLockedOut = isLockedOut;
|
||||
|
||||
// VSWhidbey 451539: We should use UTC internally for all dates, and return local for public apis
|
||||
_CreationDate = creationDate.ToUniversalTime();
|
||||
_LastLoginDate = lastLoginDate.ToUniversalTime();
|
||||
_LastActivityDate = lastActivityDate.ToUniversalTime();
|
||||
_LastPasswordChangedDate = lastPasswordChangedDate.ToUniversalTime();
|
||||
_LastLockoutDate = lastLockoutDate.ToUniversalTime();
|
||||
}
|
||||
|
||||
|
||||
protected MembershipUser() { } // Default CTor: Callable by derived class only.
|
||||
|
||||
internal virtual void Update()
|
||||
{
|
||||
SystemWebProxy.Membership.Providers[ProviderName].UpdateUser(this);
|
||||
UpdateSelf();
|
||||
}
|
||||
|
||||
public virtual string GetPassword()
|
||||
{
|
||||
return SystemWebProxy.Membership.Providers[ProviderName].GetPassword(UserName, null);
|
||||
}
|
||||
|
||||
public virtual string GetPassword(string passwordAnswer)
|
||||
{
|
||||
return SystemWebProxy.Membership.Providers[ProviderName].GetPassword(UserName, passwordAnswer);
|
||||
}
|
||||
|
||||
internal string GetPassword(bool throwOnError) {
|
||||
return GetPassword(null, /* useAnswer */ false, throwOnError);
|
||||
}
|
||||
|
||||
internal string GetPassword(string answer, bool throwOnError) {
|
||||
return GetPassword(answer, /* useAnswer */ true, throwOnError);
|
||||
}
|
||||
|
||||
// GetPassword() can throw 3 types of exception:
|
||||
// 1. ArgumentException is thrown if:
|
||||
// A. Answer is null, empty, or longer than 128 characters
|
||||
// 2. ProviderException is thrown if the user does not exist when the stored procedure
|
||||
// is run. The only way this could happen is in a race condition, where the user
|
||||
// is deleted in the middle of the MembershipProvider.ChangePassword() method.
|
||||
// 3. MembershipPasswordException is thrown if the user is locked out, or the answer
|
||||
// is incorrect.
|
||||
private string GetPassword(string answer, bool useAnswer, bool throwOnError) {
|
||||
string password = null;
|
||||
|
||||
try {
|
||||
if (useAnswer) {
|
||||
password = GetPassword(answer);
|
||||
}
|
||||
else {
|
||||
password = GetPassword();
|
||||
}
|
||||
}
|
||||
catch (ArgumentException) {
|
||||
if (throwOnError) throw;
|
||||
}
|
||||
catch (MembershipPasswordException) {
|
||||
if (throwOnError) throw;
|
||||
}
|
||||
catch (ProviderException) {
|
||||
if (throwOnError) throw;
|
||||
}
|
||||
|
||||
return password;
|
||||
}
|
||||
|
||||
public virtual bool ChangePassword(string oldPassword, string newPassword)
|
||||
{
|
||||
SecurityServices.CheckPasswordParameter(oldPassword, "oldPassword");
|
||||
SecurityServices.CheckPasswordParameter(newPassword, "newPassword");
|
||||
|
||||
if (!SystemWebProxy.Membership.Providers[ProviderName].ChangePassword(UserName, oldPassword, newPassword))
|
||||
return false;
|
||||
UpdateSelf();
|
||||
//_LastPasswordChangedDate = Membership.Providers[ ProviderName ].GetUser( UserName, false ).LastPasswordChangedDate;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ChangePassword() can throw 3 types of exception:
|
||||
// 1. ArgumentException is thrown if:
|
||||
// A. OldPassword or NewPassword is null, empty, or longer than 128 characters
|
||||
// B. NewPassword shorter than MinRequiredPasswordLength, or NewPassword contains
|
||||
// less non-alphanumeric characters than MinRequiredNonAlphanumericCharacters,
|
||||
// or NewPassword does not match PasswordStrengthRegularExpression.
|
||||
// C. A developer adds a listener to the MembershipProvider.ValidatingPassword event,
|
||||
// and sets e.Cancel to true, and e.FailureInformation is null.
|
||||
// 2. ProviderException is thrown if the user does not exist when the stored procedure
|
||||
// is run. The only way this could happen is in a race condition, where the user
|
||||
// is deleted in the middle of the MembershipProvider.ChangePassword() method.
|
||||
// 3. It appears that MembershipProviderException currently cannot be thrown, but
|
||||
// there is a codepath that throws this exception, so we should catch it here anyway.
|
||||
internal bool ChangePassword(string oldPassword, string newPassword, bool throwOnError) {
|
||||
bool passwordChanged = false;
|
||||
|
||||
try {
|
||||
passwordChanged = ChangePassword(oldPassword, newPassword);
|
||||
}
|
||||
catch (ArgumentException) {
|
||||
if (throwOnError) throw;
|
||||
}
|
||||
catch (MembershipPasswordException) {
|
||||
if (throwOnError) throw;
|
||||
}
|
||||
catch (ProviderException) {
|
||||
if (throwOnError) throw;
|
||||
}
|
||||
|
||||
return passwordChanged;
|
||||
}
|
||||
|
||||
public virtual bool ChangePasswordQuestionAndAnswer(string password, string newPasswordQuestion, string newPasswordAnswer)
|
||||
{
|
||||
SecurityServices.CheckPasswordParameter(password, "password");
|
||||
SecurityServices.CheckForEmptyOrWhiteSpaceParameter(ref newPasswordQuestion, "newPasswordQuestion");
|
||||
SecurityServices.CheckForEmptyOrWhiteSpaceParameter(ref newPasswordAnswer, "newPasswordAnswer");
|
||||
|
||||
if (!SystemWebProxy.Membership.Providers[ProviderName].ChangePasswordQuestionAndAnswer(UserName, password, newPasswordQuestion, newPasswordAnswer))
|
||||
return false;
|
||||
UpdateSelf();
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual string ResetPassword(string passwordAnswer)
|
||||
{
|
||||
string pass = SystemWebProxy.Membership.Providers[ProviderName].ResetPassword(UserName, passwordAnswer);
|
||||
if (!String.IsNullOrEmpty(pass)) {
|
||||
UpdateSelf();
|
||||
//_LastPasswordChangedDate = Membership.Providers[ProviderName].GetUser(UserName, false).LastPasswordChangedDate;
|
||||
}
|
||||
return pass;
|
||||
}
|
||||
|
||||
public virtual string ResetPassword()
|
||||
{
|
||||
return ResetPassword(null);
|
||||
}
|
||||
|
||||
internal string ResetPassword(bool throwOnError) {
|
||||
return ResetPassword(null, /* useAnswer */ false, throwOnError);
|
||||
}
|
||||
|
||||
internal string ResetPassword(string passwordAnswer, bool throwOnError) {
|
||||
return ResetPassword(passwordAnswer, /* useAnswer */ true, throwOnError);
|
||||
}
|
||||
|
||||
// MembershipProvider.ResetPassword() can throw 3 types of exception:
|
||||
// 1. ArgumentException is thrown if:
|
||||
// A. Answer is null, empty, or longer than 128 characters
|
||||
// 2. ProviderException is thrown if:
|
||||
// A. The user does not exist when the stored procedure is run. The only way
|
||||
// this could happen is in a race condition, where the user is deleted in
|
||||
// the middle of the MembershipProvider.ChangePassword() method.
|
||||
// B. A developer adds a listener to the MembershipProvider.ValidatingPassword event,
|
||||
// and sets e.Cancel to true, and e.FailureInformation is null.
|
||||
// 3. MembershipPasswordException is thrown if the user is locked out, or the answer
|
||||
// is incorrect.
|
||||
private string ResetPassword(string passwordAnswer, bool useAnswer, bool throwOnError) {
|
||||
string password = null;
|
||||
|
||||
try {
|
||||
if (useAnswer) {
|
||||
password = ResetPassword(passwordAnswer);
|
||||
}
|
||||
else {
|
||||
password = ResetPassword();
|
||||
}
|
||||
}
|
||||
catch (ArgumentException) {
|
||||
if (throwOnError) throw;
|
||||
}
|
||||
catch (MembershipPasswordException) {
|
||||
if (throwOnError) throw;
|
||||
}
|
||||
catch (ProviderException) {
|
||||
if (throwOnError) throw;
|
||||
}
|
||||
|
||||
return password;
|
||||
}
|
||||
|
||||
public virtual bool UnlockUser()
|
||||
{
|
||||
if (SystemWebProxy.Membership.Providers[ProviderName].UnlockUser(UserName))
|
||||
{
|
||||
UpdateSelf();
|
||||
return !IsLockedOut;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
private void UpdateSelf()
|
||||
{
|
||||
MembershipUser mu = SystemWebProxy.Membership.Providers[ProviderName].GetUser(UserName, false);
|
||||
if (mu != null) {
|
||||
try {
|
||||
_LastPasswordChangedDate = mu.LastPasswordChangedDate.ToUniversalTime();
|
||||
} catch (NotSupportedException) {}
|
||||
try {
|
||||
LastActivityDate = mu.LastActivityDate;
|
||||
} catch (NotSupportedException) {}
|
||||
try {
|
||||
LastLoginDate = mu.LastLoginDate;
|
||||
} catch (NotSupportedException) {}
|
||||
try {
|
||||
_CreationDate = mu.CreationDate.ToUniversalTime();
|
||||
} catch (NotSupportedException) { }
|
||||
try {
|
||||
_LastLockoutDate = mu.LastLockoutDate.ToUniversalTime();
|
||||
} catch (NotSupportedException) { }
|
||||
try {
|
||||
_IsLockedOut = mu.IsLockedOut;
|
||||
} catch (NotSupportedException) { }
|
||||
try {
|
||||
IsApproved = mu.IsApproved;
|
||||
} catch (NotSupportedException) { }
|
||||
try {
|
||||
Comment = mu.Comment;
|
||||
} catch (NotSupportedException) { }
|
||||
try {
|
||||
_PasswordQuestion = mu.PasswordQuestion;
|
||||
} catch (NotSupportedException) { }
|
||||
try {
|
||||
Email = mu.Email;
|
||||
} catch (NotSupportedException) { }
|
||||
try {
|
||||
_ProviderUserKey = mu.ProviderUserKey;
|
||||
} catch (NotSupportedException) { }
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////
|
||||
// private Data
|
||||
private string _UserName;
|
||||
private object _ProviderUserKey;
|
||||
private string _Email;
|
||||
private string _PasswordQuestion;
|
||||
private string _Comment;
|
||||
private bool _IsApproved;
|
||||
private bool _IsLockedOut;
|
||||
private DateTime _LastLockoutDate;
|
||||
private DateTime _CreationDate;
|
||||
private DateTime _LastLoginDate;
|
||||
private DateTime _LastActivityDate;
|
||||
private DateTime _LastPasswordChangedDate;
|
||||
private string _ProviderName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MembershipUserCollection.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Configuration.Provider;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
[Serializable]
|
||||
public sealed class MembershipUserCollection : IEnumerable, ICollection {
|
||||
private Hashtable _Indices = null;
|
||||
private ArrayList _Values = null;
|
||||
private bool _ReadOnly = false;
|
||||
|
||||
public MembershipUserCollection() {
|
||||
_Indices = new Hashtable(10, StringComparer.CurrentCultureIgnoreCase);
|
||||
_Values = new ArrayList();
|
||||
}
|
||||
|
||||
public void Add(MembershipUser user) {
|
||||
if (user == null) {
|
||||
throw new ArgumentNullException("user");
|
||||
}
|
||||
|
||||
if (_ReadOnly)
|
||||
throw new NotSupportedException();
|
||||
|
||||
int pos = _Values.Add(user);
|
||||
try {
|
||||
_Indices.Add(user.UserName, pos);
|
||||
}
|
||||
catch {
|
||||
_Values.RemoveAt(pos);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(string name) {
|
||||
if (_ReadOnly)
|
||||
throw new NotSupportedException();
|
||||
|
||||
object pos = _Indices[name];
|
||||
if (pos == null || !(pos is int))
|
||||
return;
|
||||
int ipos = (int)pos;
|
||||
if (ipos >= _Values.Count)
|
||||
return;
|
||||
_Values.RemoveAt(ipos);
|
||||
_Indices.Remove(name);
|
||||
ArrayList al = new ArrayList();
|
||||
foreach (DictionaryEntry de in _Indices)
|
||||
if ((int)de.Value > ipos)
|
||||
al.Add(de.Key);
|
||||
foreach (string key in al)
|
||||
_Indices[key] = ((int)_Indices[key]) - 1;
|
||||
}
|
||||
|
||||
public MembershipUser this[string name] {
|
||||
get {
|
||||
object pos = _Indices[name];
|
||||
if (pos == null || !(pos is int))
|
||||
return null;
|
||||
int ipos = (int)pos;
|
||||
if (ipos >= _Values.Count)
|
||||
return null;
|
||||
return (MembershipUser)_Values[ipos];
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator GetEnumerator() {
|
||||
return _Values.GetEnumerator();
|
||||
}
|
||||
|
||||
public void SetReadOnly() {
|
||||
if (_ReadOnly)
|
||||
return;
|
||||
_ReadOnly = true;
|
||||
_Values = ArrayList.ReadOnly(_Values);
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
_Values.Clear();
|
||||
_Indices.Clear();
|
||||
}
|
||||
|
||||
public int Count { get { return _Values.Count; } }
|
||||
|
||||
public bool IsSynchronized { get { return false; } }
|
||||
|
||||
public object SyncRoot { get { return this; } }
|
||||
|
||||
|
||||
void ICollection.CopyTo(Array array, int index) {
|
||||
_Values.CopyTo(array, index);
|
||||
}
|
||||
|
||||
public void CopyTo(MembershipUser[] array, int index) {
|
||||
_Values.CopyTo(array, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="MembershipValidatePasswordEventHandler.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* MembershipValidatePasswordEventHandler class
|
||||
*
|
||||
* Copyright (c) 1999 Microsoft Corporation
|
||||
*/
|
||||
namespace System.Web.Security
|
||||
{
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
public delegate void MembershipValidatePasswordEventHandler( Object sender, ValidatePasswordEventArgs e );
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="RoleProvider.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Web.Security {
|
||||
using System.Web;
|
||||
using System.Security.Principal;
|
||||
using System.Security.Permissions;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration.Provider;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
/// <devdoc>
|
||||
/// <para>[To be supplied.]</para>
|
||||
/// </devdoc>
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
public abstract class RoleProvider : ProviderBase
|
||||
{
|
||||
|
||||
public abstract string ApplicationName { get; set; }
|
||||
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract bool IsUserInRole(string username, string roleName);
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract string[] GetRolesForUser(string username);
|
||||
|
||||
public abstract void CreateRole(string roleName);
|
||||
|
||||
public abstract bool DeleteRole(string roleName, bool throwOnPopulatedRole);
|
||||
|
||||
public abstract bool RoleExists(string roleName);
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "usernames", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract void AddUsersToRoles(string[] usernames, string[] roleNames);
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "usernames", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract void RemoveUsersFromRoles(string[] usernames, string[] roleNames);
|
||||
|
||||
public abstract string[] GetUsersInRole(string roleName);
|
||||
|
||||
public abstract string[] GetAllRoles();
|
||||
|
||||
[SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "username", Justification="This version is required to maintain backwards binary compatibility")]
|
||||
public abstract string[] FindUsersInRole(string roleName, string usernameToMatch);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="ValidatePasswordEventArgs.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* ValidatePasswordEventArgs class
|
||||
*
|
||||
* Copyright (c) 1999 Microsoft Corporation
|
||||
*/
|
||||
namespace System.Web.Security
|
||||
{
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[TypeForwardedFrom("System.Web, Version=2.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")]
|
||||
public sealed class ValidatePasswordEventArgs : EventArgs
|
||||
{
|
||||
private string _userName;
|
||||
private string _password;
|
||||
private bool _isNewUser;
|
||||
private bool _cancel;
|
||||
private Exception _failureInformation;
|
||||
|
||||
public ValidatePasswordEventArgs(
|
||||
string userName,
|
||||
string password,
|
||||
bool isNewUser )
|
||||
{
|
||||
_userName = userName;
|
||||
_password = password;
|
||||
_isNewUser = isNewUser;
|
||||
_cancel = false;
|
||||
}
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get{ return _userName; }
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get{ return _password; }
|
||||
}
|
||||
|
||||
public bool IsNewUser
|
||||
{
|
||||
get{ return _isNewUser; }
|
||||
}
|
||||
|
||||
public bool Cancel
|
||||
{
|
||||
get{ return _cancel; }
|
||||
set{ _cancel = value; }
|
||||
}
|
||||
|
||||
public Exception FailureInformation
|
||||
{
|
||||
get{ return _failureInformation; }
|
||||
set{ _failureInformation = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user