React to ISecureDataFormat changes.

This commit is contained in:
Chris R 2015-10-19 10:06:56 -07:00
parent 1b87767472
commit b437669e93
3 changed files with 31 additions and 0 deletions

View File

@ -9,12 +9,22 @@ namespace MusicStore.Mocks.Common
{ {
private static string _lastSavedAuthenticationProperties; private static string _lastSavedAuthenticationProperties;
public string Protect(AuthenticationProperties data, string purose)
{
return Protect(data);
}
public string Protect(AuthenticationProperties data) public string Protect(AuthenticationProperties data)
{ {
_lastSavedAuthenticationProperties = Serialize(data); _lastSavedAuthenticationProperties = Serialize(data);
return "ValidStateData"; return "ValidStateData";
} }
public AuthenticationProperties Unprotect(string state, string purpose)
{
return Unprotect(state);
}
public AuthenticationProperties Unprotect(string state) public AuthenticationProperties Unprotect(string state)
{ {
return state == "ValidStateData" ? DeSerialize(_lastSavedAuthenticationProperties) : null; return state == "ValidStateData" ? DeSerialize(_lastSavedAuthenticationProperties) : null;

View File

@ -6,15 +6,26 @@ namespace MusicStore.Mocks.OpenIdConnect
internal class CustomStringDataFormat : ISecureDataFormat<string> internal class CustomStringDataFormat : ISecureDataFormat<string>
{ {
private const string _capturedNonce = "635579928639517715.OTRjOTVkM2EtMDRmYS00ZDE3LThhZGUtZWZmZGM4ODkzZGZkMDRlNDhkN2MtOWIwMC00ZmVkLWI5MTItMTUwYmQ4MzdmOWI0"; private const string _capturedNonce = "635579928639517715.OTRjOTVkM2EtMDRmYS00ZDE3LThhZGUtZWZmZGM4ODkzZGZkMDRlNDhkN2MtOWIwMC00ZmVkLWI5MTItMTUwYmQ4MzdmOWI0";
public string Protect(string data) public string Protect(string data)
{ {
return "protectedString"; return "protectedString";
} }
public string Protect(string data, string purpose)
{
return purpose + "protectedString";
}
public string Unprotect(string protectedText) public string Unprotect(string protectedText)
{ {
return protectedText == "protectedString" ? _capturedNonce : null; return protectedText == "protectedString" ? _capturedNonce : null;
} }
public string Unprotect(string protectedText, string purpose)
{
return protectedText == (purpose + "protectedString") ? _capturedNonce : null;
}
} }
} }
#endif #endif

View File

@ -19,11 +19,21 @@ namespace MusicStore.Mocks.Twitter
return "valid_oauth_token"; return "valid_oauth_token";
} }
public string Protect(RequestToken data, string purpose)
{
return Protect(data);
}
public RequestToken Unprotect(string state) public RequestToken Unprotect(string state)
{ {
return state == "valid_oauth_token" ? DeSerialize(_lastSavedRequestToken) : null; return state == "valid_oauth_token" ? DeSerialize(_lastSavedRequestToken) : null;
} }
public RequestToken Unprotect(string state, string purpose)
{
return Unprotect(state);
}
private string Serialize(RequestToken data) private string Serialize(RequestToken data)
{ {
return JsonConvert.SerializeObject(data, Formatting.Indented); return JsonConvert.SerializeObject(data, Formatting.Indented);