Fix line endings. Add test for JavaScriptSerializer.Deserialize(string input, Type targetType).
<Compile Include="Assembly\AssemblyInfo.cs" />\r
<Compile Include="System.IdentityModel\CookieTransform.cs" />\r
<Compile Include="System.IdentityModel\OpenObject.cs" />\r
+ <Compile Include="System.IdentityModel\SignatureVerificationFailedException.cs" />\r
<Compile Include="System.IdentityModel.Claims\Claim.cs" />\r
<Compile Include="System.IdentityModel.Claims\ClaimSet.cs" />\r
<Compile Include="System.IdentityModel.Claims\ClaimTypes.cs" />\r
<Compile Include="System.IdentityModel.Tokens\SecurityToken.cs" />\r
<Compile Include="System.IdentityModel.Tokens\SecurityTokenDescriptor.cs" />\r
<Compile Include="System.IdentityModel.Tokens\SecurityTokenException.cs" />\r
- <Compile Include="System.IdentityModel.Tokens\SecurityTokenHandler.cs" />\r
+ <Compile Include="System.IdentityModel.Tokens\SecurityTokenExpiredException.cs" />\r
+ <Compile Include="System.IdentityModel.Tokens\SecurityTokenHandler.cs" />\r
<Compile Include="System.IdentityModel.Tokens\SecurityTokenHandlerCollection.cs" />\r
<Compile Include="System.IdentityModel.Tokens\SecurityTokenHandlerConfiguration.cs" />\r
+ <Compile Include="System.IdentityModel.Tokens\SecurityTokenNotYetValidException.cs" />\r
+ <Compile Include="System.IdentityModel.Tokens\SecurityTokenReplayDetectedException.cs" />\r
<Compile Include="System.IdentityModel.Tokens\SecurityTokenTypes.cs" />\r
<Compile Include="System.IdentityModel.Tokens\SecurityTokenValidationException.cs" />\r
<Compile Include="System.IdentityModel.Tokens\SessionSecurityToken.cs" />\r
<Compile Include="System.IdentityModel.Tokens\X509SubjectKeyIdentifierClause.cs" />\r
<Compile Include="System.IdentityModel.Tokens\X509ThumbprintKeyIdentifierClause.cs" />\r
<Compile Include="System.IdentityModel.Tokens\X509WindowsSecurityToken.cs" />\r
- <Compile Include="System.Security.Claims\AuthenticationTypes.cs" />\r <Compile Include="System.ServiceModel.Security\X509CertificateValidationMode.cs" />\r
+ <Compile Include="System.Security.Claims\AuthenticationTypes.cs" />\r
+ <Compile Include="System.ServiceModel.Security\X509CertificateValidationMode.cs" />\r
</ItemGroup>\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
Other similar extension points exist, see Microsoft.Common.targets.\r
</Target>\r
-->\r
<PropertyGroup>\r
- <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
-
- </PreBuildEvent>
- <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
-
- </PreBuildEvent>
+ <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">\r
+\r
+ </PreBuildEvent>\r
+ <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
+\r
+ </PreBuildEvent>\r
+\r
+ <PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">\r
+\r
+ </PostBuildEvent>\r
+ <PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
\r
- <PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
-
- </PostBuildEvent>
- <PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">
-
</PostBuildEvent>\r
</PropertyGroup>\r
<ItemGroup>\r
<Folder Include="Properties\" />\r
</ItemGroup>\r
</Project>\r
-
+\r
--- /dev/null
+//
+// SecurityTokenExpiredException.cs
+//
+// Author:
+// Noesis Labs (Ryan.Melena@noesislabs.com)
+//
+// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.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.
+//
+#if NET_4_5
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.IdentityModel.Tokens
+{
+ public class SecurityTokenExpiredException : SecurityTokenValidationException
+ {
+ public SecurityTokenExpiredException()
+ : base("ID4181: The security token has expired.")
+ { }
+
+ public SecurityTokenExpiredException(string message)
+ : base(message)
+ { }
+
+ public SecurityTokenExpiredException(string message, Exception innerException)
+ : base(message, innerException)
+ { }
+
+ public SecurityTokenExpiredException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ { }
+ }
+}
+#endif
--- /dev/null
+//
+// SecurityTokenNotYetValidException.cs
+//
+// Author:
+// Noesis Labs (Ryan.Melena@noesislabs.com)
+//
+// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.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.
+//
+#if NET_4_5
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.IdentityModel.Tokens
+{
+ public class SecurityTokenNotYetValidException : SecurityTokenValidationException
+ {
+ public SecurityTokenNotYetValidException()
+ : base("ID4182: The security token is not valid yet.")
+ { }
+
+ public SecurityTokenNotYetValidException(string message)
+ : base(message)
+ { }
+
+ public SecurityTokenNotYetValidException(string message, Exception innerException)
+ : base(message, innerException)
+ { }
+
+ public SecurityTokenNotYetValidException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ { }
+ }
+}
+#endif
--- /dev/null
+//
+// SecurityTokenReplayDetectedException.cs
+//
+// Author:
+// Noesis Labs (Ryan.Melena@noesislabs.com)
+//
+// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.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.
+//
+#if NET_4_5
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.IdentityModel.Tokens
+{
+ public class SecurityTokenReplayDetectedException : SecurityTokenValidationException
+ {
+ public SecurityTokenReplayDetectedException()
+ : base("ID1070: Replay has been detected for a SecurityToken.")
+ { }
+
+ public SecurityTokenReplayDetectedException(string message)
+ : base(message)
+ { }
+
+ public SecurityTokenReplayDetectedException(string message, Exception innerException)
+ : base(message, innerException)
+ { }
+
+ public SecurityTokenReplayDetectedException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ { }
+ }
+}
+#endif
Assembly/AssemblyInfo.cs
System.IdentityModel/CookieTransform.cs
System.IdentityModel/OpenObject.cs
+System.IdentityModel/SignatureVerificationFailedException.cs
System.IdentityModel.Claims/Claim.cs
System.IdentityModel.Claims/ClaimSet.cs
System.IdentityModel.Claims/ClaimTypes.cs
System.IdentityModel.Tokens/SecurityToken.cs
System.IdentityModel.Tokens/SecurityTokenDescriptor.cs
System.IdentityModel.Tokens/SecurityTokenException.cs
+System.IdentityModel.Tokens/SecurityTokenExpiredException.cs
System.IdentityModel.Tokens/SecurityTokenHandler.cs
System.IdentityModel.Tokens/SecurityTokenHandlerCollection.cs
System.IdentityModel.Tokens/SecurityTokenHandlerConfiguration.cs
+System.IdentityModel.Tokens/SecurityTokenNotYetValidException.cs
+System.IdentityModel.Tokens/SecurityTokenReplayDetectedException.cs
System.IdentityModel.Tokens/SecurityTokenTypes.cs
System.IdentityModel.Tokens/SecurityTokenValidationException.cs
System.IdentityModel.Tokens/SessionSecurityToken.cs
System.IdentityModel.Tokens/X509ThumbprintKeyIdentifierClause.cs
System.IdentityModel.Tokens/X509WindowsSecurityToken.cs
System.Security.Claims/AuthenticationTypes.cs
-System.ServiceModel.Security/X509CertificateValidationMode.cs
\ No newline at end of file
+System.ServiceModel.Security/X509CertificateValidationMode.cs
--- /dev/null
+//
+// SignatureVerificationFailedException.cs
+//
+// Author:
+// Noesis Labs (Ryan.Melena@noesislabs.com)
+//
+// Copyright (C) 2014 Noesis Labs, LLC https://noesislabs.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.
+//
+#if NET_4_5
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.IdentityModel
+{
+ public class SignatureVerificationFailedException : Exception
+ {
+ public SignatureVerificationFailedException()
+ : base("ID4038: Signature verification failed.")
+ { }
+
+ public SignatureVerificationFailedException(string message)
+ : base(message)
+ { }
+
+ public SignatureVerificationFailedException(string message, Exception innerException)
+ : base(message, innerException)
+ { }
+
+ public SignatureVerificationFailedException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ { }
+ }
+}
+#endif
}
public object Deserialize (string input, Type targetType) {
- return DeserializeObjectInternal (input);
+ object obj = DeserializeObjectInternal (input);
+
+ if (obj == null)
+ return Activator.CreateInstance (targetType);
+
+ return ConvertToType (obj, targetType);
}
static object Evaluate (object value) {
void CreateArray ()
{
- var arr = new ArrayList ();
+ var arr = new List <object> ();
PushObject (arr);
}
{
Dictionary <string, object> dict = PeekObject () as Dictionary <string, object>;
if (dict == null) {
- ArrayList arr = PeekObject () as ArrayList;
+ List <object> arr = PeekObject () as List <object>;
if (arr == null)
throw new InvalidOperationException ("Internal error: current object is not a dictionary or an array.");
arr.Add (o);
//object oo = ser.DeserializeObject ("{value:'Purple\\r \\n monkey\\'s:\\tdishwasher'}");
}
+ [Test]
+ public void TestDeserializeNonGenericOverload()
+ {
+ JavaScriptSerializer ser = new JavaScriptSerializer();
+ Assert.IsNull(ser.Deserialize("", typeof(X)));
+
+ X s = new X();
+ s.Init();
+ string x = ser.Serialize(s);
+
+ Assert.AreEqual("{\"z\":8,\"ch\":\"v\",\"ch_null\":null,\"str\":\"vwF59g\",\"b\":253,\"sb\":-48,\"sh\":-32740,\"ush\":65511,\"i\":-234235453,\"ui\":4294733061,\"l\":-9223372036854775780,\"ul\":18446744073709551612,\"f\":NaN,\"f1\":-Infinity,\"f2\":Infinity,\"f3\":-3.40282347E+38,\"f4\":3.40282347E+38,\"d\":NaN,\"d1\":-Infinity,\"d2\":Infinity,\"d3\":-1.7976931348623157E+308,\"d4\":1.7976931348623157E+308,\"de\":-1,\"de1\":0,\"de2\":1,\"de3\":-79228162514264337593543950335,\"de4\":79228162514264337593543950335,\"g\":\"000000ea-0002-0162-0102-030405060708\",\"nb\":null,\"dbn\":null,\"uri\":\"http://kostat@mainsoft/adfasdf/asdfasdf.aspx/asda/ads?a=b&c=d\",\"hash\":{\"mykey\":{\"BB\":10}},\"point\":{\"IsEmpty\":false,\"X\":150,\"Y\":150},\"MyEnum\":[1,10,345],\"MyEnum1\":[1,10,345],\"AA\":5,\"AA1\":[{\"BB\":10},{\"BB\":10}],\"BB\":18446744073709551610,\"YY\":[{\"BB\":10},{\"BB\":10}]}", x, "#A1");
+
+ X n = ser.Deserialize(x, typeof(X)) as X;
+ Assert.AreEqual(s, n, "#A2");
+ }
+
[Test]
public void TestDeserializeTypeResolver ()
{
throw new ArgumentNullException ("type");
if (value == null)
throw new ArgumentNullException ("value");
+
+ Properties = new Dictionary <string, string> ();
+
Type = type;
Value = value;
ValueType = valueType == null ? ClaimValueTypes.String : valueType;
}
}
}
-#endif
\ No newline at end of file
+#endif