Permalink
Browse files

A few moves/changes following previous patch review

* 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 a22389f commit 21d2c6aedb993eb201e88e6c0a4cce9be8d76825 Sebastien Pouliot committed Oct 12, 2010
@@ -291,7 +291,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 = \
@@ -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 ();
@@ -37,6 +37,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Configuration;
+using System.Web.Util;
namespace System.Web.Handlers {
#if SYSTEM_WEB_EXTENSIONS
@@ -1,5 +1,5 @@
//
-// System.Web.Security.MembershipEncryptionHelper
+// System.Web.Security.MembershipHelper
//
// Authors:
// Ben Maurer (bmaurer@users.sourceforge.net)
@@ -27,10 +27,11 @@
// 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.Configuration.Provider;
using System.Security.Cryptography;
using System.Web.Configuration;
+using System.Web.Util;
namespace System.Web.Security
{
@@ -32,6 +32,7 @@
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Configuration;
+using System.Web.Util;
using System.IO;
using System.Text;
@@ -28,7 +28,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 {
@@ -1,5 +1,5 @@
//
-// System.Web.Configuration.MachineKeySection
+// System.Web.Util.MachineKeySectionUtils
//
// Authors:
// Chris Toshok (toshok@ximian.com)
@@ -34,12 +34,13 @@
using System.Configuration.Provider;
using System.Security.Cryptography;
using System.Text;
+using System.Web.Configuration;
#if NET_2_0
-namespace System.Web.Configuration {
+namespace System.Web.Util {
- internal static class MachineKeySectionUtils {
+ static class MachineKeySectionUtils {
static byte ToHexValue (char c, bool high)
{
byte v;
@@ -183,7 +183,6 @@ System.Web.Configuration_2.0/LowerCaseStringConverter.cs
System.Web.Configuration_2.0/MachineKeyCompatibilityMode.cs
System.Web.Configuration_2.0/MachineKeyRegistryStorage.cs
System.Web.Configuration_2.0/MachineKeySection.cs
-System.Web.Configuration_2.0/MachineKeySectionUtils.cs
System.Web.Configuration_2.0/MachineKeyValidation.cs
System.Web.Configuration_2.0/MachineKeyValidationConverter.cs
System.Web.Configuration_2.0/MembershipSection.cs
@@ -1169,6 +1168,7 @@ System.Web.Util/HttpEncoder.cs
System.Web.Util/ICalls.cs
System.Web.Util/IWebObjectFactory.cs
System.Web.Util/IWebPropertyAccessor.cs
+System.Web.Util/MachineKeySectionUtils.cs
System.Web.Util/RuntimeHelpers.cs
System.Web.Util/SearchPattern.cs
System.Web.Util/SerializationHelper.cs
@@ -89,7 +89,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
@@ -551,6 +550,7 @@ System.Web.UI.WebControls/WebControlCas.cs
System.Web.UI.WebControls/XmlCas.cs
System.Web.UI.WebControls/XmlDataSourceCas.cs
System.Web.Util/HttpEncoderTest.cs
+System.Web.Util/MachineKeySectionUtilsTest.cs
System.Web.Util/RequestValidatorTest.cs
System.Web.Util/TransactionsCas.cs
System.Web.Util/UrlUtilsTest.cs
@@ -120,6 +120,27 @@ public void Validation_Custom ()
// cannot be set directly
}
+ [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,9 +29,10 @@
using System;
using System.IO;
using System.Web.Configuration;
+using System.Web.Util;
using NUnit.Framework;
-namespace MonoTests.System.Web.Configuration {
+namespace MonoTests.System.Web.Util {
[TestFixture]
public class MachineKeySectionUtilsTest {

0 comments on commit 21d2c6a

Please sign in to comment.