New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional JWT Security Token Support #1337
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement missing exception |
||
{ | ||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement missing exception |
||
{ | ||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement missing 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,7 +204,12 @@ object ConvertToType (object obj, Type targetType) | |
} | ||
|
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Convert object before returning to avoid error when calling code attempts to cast There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have a test case showing this scenario? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added unit test for non-generic Deserialize overload |
||
} | ||
|
||
static object Evaluate (object value) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -833,7 +833,7 @@ bool ProcessCharacter (char ch) | |
|
||
void CreateArray () | ||
{ | ||
var arr = new ArrayList (); | ||
var arr = new List <object> (); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make compatible with MS claims processing code which apparently assumes deserialized json collection can be cast to IEnumerable<object> |
||
PushObject (arr); | ||
} | ||
|
||
|
@@ -865,7 +865,7 @@ void StoreValue (object o) | |
{ | ||
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); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,9 @@ public Claim (string type, string value, string valueType, string issuer, string | |
throw new ArgumentNullException ("type"); | ||
if (value == null) | ||
throw new ArgumentNullException ("value"); | ||
|
||
Properties = new Dictionary <string, string> (); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make compatible with MS code that seems to assume Properties dictionary is initialized. |
||
|
||
Type = type; | ||
Value = value; | ||
ValueType = valueType == null ? ClaimValueTypes.String : valueType; | ||
|
@@ -91,4 +94,4 @@ public override string ToString () | |
} | ||
} | ||
} | ||
#endif | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement missing exception