Permalink
Browse files

[asp.net] A few moves/changes following previous patch review

Backport of commit 21d2c6a

    * Makefile: Compile tests with TEST defined (to include System.Web.Util.
    MachineKeySectionUtils unit tests)
    * System.Web.dll.sources: Move MachineKeySectionUtils.cs from System.
    Web.Configuration_2.0 to System.Web.Util
    * System.Web_test.dll.sources: Move MachineKeySectionUtilsTest.cs from
    System.Web.Configuration_2.0 to System.Web.Util

    * System.Web.Configuration_2.0/MachineKeySection.cs: Adjust using
    clauses. Uncomment some code. Fix TripleDES versus 3DES for Validation
    under NET_4_0. Remove 'private' on fields/methods.
    * System.Web.Handlers/AssemblyResourceLoader.cs: Adjust using clauses
    * System.Web.Security/MembershipHelper.cs: Adjust using clauses
    * System.Web.Security/RolePrincipal.cs: Adjust using clauses
    * System.Web.SessionState_2.0/SessionId.cs: Adjust using clauses
    * System.Web.UI/LosFormatter.cs: Adjust using clauses.
    * System.Web.Util/MachineKeySectionUtils.cs: Moved from System.Web.
    Configuration_2.0. Rename namespace and remove 'internal' on type
    declaration

    * Test/System.Web.Util/MachineKeySectionUtilsTest.cs: Moved from Test/
    System.Web.Configuration/MachineKeySectionTest.cs. Add test case for
    TripleDES versus 3DES
  • Loading branch information...
1 parent f5501ef commit 237a4339206978242e83849bfdeb86ec95660a29 @grendello grendello committed Nov 26, 2010
@@ -279,7 +279,7 @@ TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -doc:$(test_lib:.dll=.xml) -nowarn:219,169,159
$(foreach file,$(NUNIT_APP_GLOBALRESOURCES_FILES),$(shell echo $(file) | sed -e 's;\(.*\)/\(.*\);/resource:\1/\2,App_GlobalResources/\2 ;g'))
ifeq (net_2_0, $(PROFILE))
-TEST_MCS_FLAGS += -r:System.Web.Extensions.dll
+TEST_MCS_FLAGS += -r:System.Web.Extensions.dll -d:TEST
endif
EXTRA_DISTFILES = $(RESOURCE_FILES_2) $(RESOURCE_FILES_1) $(TEST_RESOURCE_FILES) UplevelHelperDefinitions.xml $(RESX_DIST) \
@@ -34,6 +34,7 @@
using System.Configuration;
using System.Xml;
using System.Security.Cryptography;
+using System.Web.Util;
namespace System.Web.Configuration
{
@@ -35,6 +35,7 @@
using System.ComponentModel;
using System.Configuration;
using System.Security.Cryptography;
+using System.Web.Util;
namespace System.Web.Configuration {
@@ -127,7 +128,7 @@ protected override void Reset (ConfigurationElement parentElement)
get { return (string) base [decryptionKeyProp];}
set {
base[decryptionKeyProp] = value;
-// SetDecryptionKey (value);
+ SetDecryptionKey (value);
}
}
@@ -138,7 +139,10 @@ protected override void Reset (ConfigurationElement parentElement)
set {
if (value == MachineKeyValidation.Custom)
throw new ArgumentException ();
-// ValidationAlgorithm = value.ToString ();
+
+ string algo = value.ToString ();
+ // enum and accept values differs for TripleDES
+ ValidationAlgorithm = (algo == "TripleDES") ? "3DES" : algo;
}
}
@@ -175,7 +179,7 @@ protected override void Reset (ConfigurationElement parentElement)
get { return (string) base [validationKeyProp];}
set {
base[validationKeyProp] = value;
-// SetValidationKey (value);
+ SetValidationKey (value);
}
}
@@ -188,10 +192,10 @@ protected override void Reset (ConfigurationElement parentElement)
get { return WebConfigurationManager.GetSection ("system.web/machineKey") as MachineKeySection; }
}
- private byte[] decryption_key;
- private byte[] validation_key;
- private SymmetricAlgorithm decryption_template;
- private KeyedHashAlgorithm validation_template;
+ byte[] decryption_key;
+ byte[] validation_key;
+ SymmetricAlgorithm decryption_template;
+ KeyedHashAlgorithm validation_template;
internal SymmetricAlgorithm GetDecryptionAlgorithm ()
{
@@ -200,7 +204,7 @@ internal SymmetricAlgorithm GetDecryptionAlgorithm ()
}
// not to be reused outside algorithm and key validation purpose
- private SymmetricAlgorithm DecryptionTemplate {
+ SymmetricAlgorithm DecryptionTemplate {
get {
if (decryption_template == null)
decryption_template = GetDecryptionAlgorithm ();
@@ -238,7 +242,7 @@ internal KeyedHashAlgorithm GetValidationAlgorithm ()
}
// not to be reused outside algorithm and key validation purpose
- private KeyedHashAlgorithm ValidationTemplate {
+ KeyedHashAlgorithm ValidationTemplate {
get {
if (validation_template == null)
validation_template = GetValidationAlgorithm ();
@@ -34,6 +34,7 @@
using System.Web.Configuration;
using System.Security.Cryptography;
using System.Text;
+using System.Web.Util;
namespace System.Web.Security
{
@@ -34,6 +34,7 @@
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Configuration;
+using System.Web.Util;
using System.IO;
using System.Text;
@@ -29,6 +29,7 @@
using System.Text;
using System.Security.Cryptography;
using System.Web.Configuration;
+using System.Web.Util;
namespace System.Web.SessionState {
@@ -32,7 +32,7 @@
using System.IO;
using System.Security.Permissions;
using System.Text;
-using System.Web.Configuration;
+using System.Web.Util;
namespace System.Web.UI {
@@ -36,8 +36,9 @@
#endif
using System.Security.Cryptography;
using System.Text;
+using System.Web.Configuration;
-namespace System.Web.Configuration {
+namespace System.Web.Util {
internal static class MachineKeySectionUtils {
static byte ToHexValue (char c, bool high)
@@ -200,7 +200,7 @@ System.Web.Configuration_2.0/IConfigMapPathFactory.cs
System.Web.Configuration_2.0/IRemoteWebConfigurationHostServer.cs
System.Web.Configuration_2.0/LowerCaseStringConverter.cs
System.Web.Configuration_2.0/MachineKeySection.cs
-System.Web.Configuration_2.0/MachineKeySectionUtils.cs
+
System.Web.Configuration_2.0/MachineKeyValidationConverter.cs
System.Web.Configuration_2.0/MembershipSection.cs
System.Web.Configuration_2.0/MonoSettingsSection.cs
@@ -1194,6 +1194,7 @@ System.Web.Util/Helpers.cs
System.Web.Util/ICalls.cs
System.Web.Util/IWebObjectFactory.cs
System.Web.Util/IWebPropertyAccessor.cs
+System.Web.Util/MachineKeySectionUtils.cs
System.Web.Util/SearchPattern.cs
System.Web.Util/SerializationHelper.cs
System.Web.Util/StrUtils.cs
@@ -86,7 +86,6 @@ System.Web.Configuration/DeploymentSectionTest.cs
System.Web.Configuration/GlobalizationSectionTest.cs
System.Web.Configuration/HostingEnvironmentSectionTest.cs
System.Web.Configuration/MachineKeySectionTest.cs
-System.Web.Configuration/MachineKeySectionUtilsTest.cs
System.Web.Configuration/MachineKeyValidationConverterTest.cs
System.Web.Configuration/NullableStringValidatorTest.cs
System.Web.Configuration/ProfilePropertySettingsTest.cs
@@ -528,6 +527,7 @@ System.Web.UI.WebControls/WebColorConverterCas.cs
System.Web.UI.WebControls/WebControlCas.cs
System.Web.UI.WebControls/XmlCas.cs
System.Web.UI.WebControls/XmlDataSourceCas.cs
+System.Web.Util/MachineKeySectionUtilsTest.cs
System.Web.Util/TransactionsCas.cs
System.Web.Util/UrlUtilsTest.cs
System.Web.Util/WorkItemCas.cs
@@ -121,6 +121,27 @@ public void Validation_Custom ()
}
[Test]
+ public void Validation ()
+ {
+ MachineKeySection section = new MachineKeySection ();
+ section.Validation = MachineKeyValidation.AES;
+ Assert.AreEqual ("AES", section.ValidationAlgorithm, "AES");
+ section.Validation = MachineKeyValidation.HMACSHA256;
+ Assert.AreEqual ("HMACSHA256", section.ValidationAlgorithm, "HMACSHA256");
+ section.Validation = MachineKeyValidation.HMACSHA384;
+ Assert.AreEqual ("HMACSHA384", section.ValidationAlgorithm, "HMACSHA384");
+ section.Validation = MachineKeyValidation.HMACSHA512;
+ Assert.AreEqual ("HMACSHA512", section.ValidationAlgorithm, "HMACSHA512");
+ section.Validation = MachineKeyValidation.MD5;
+ Assert.AreEqual ("MD5", section.ValidationAlgorithm, "MD5");
+ section.Validation = MachineKeyValidation.SHA1;
+ Assert.AreEqual ("SHA1", section.ValidationAlgorithm, "SHA1");
+ // special case, enum value and algorithm names differs
+ section.Validation = MachineKeyValidation.TripleDES;
+ Assert.AreEqual ("3DES", section.ValidationAlgorithm, "3DES");
+ }
+
+ [Test]
[ExpectedException (typeof (ArgumentException))]
public void ValidationAlgorithm ()
{
@@ -29,6 +29,7 @@
using System;
using System.IO;
using System.Web.Configuration;
+using System.Web.Util;
using NUnit.Framework;
namespace MonoTests.System.Web.Configuration {

0 comments on commit 237a433

Please sign in to comment.