/// <summary> ///Throws an exception if the string <param name="allegedWebServiceToken"/> is not valid as a <see cref="WebServiceToken"/> /// </summary> private static Guid DemandValidWebServiceToken(string allegedWebServiceToken, bool isBeingCalledByStaticConstructor) { Guid tokenGuid; Check.Require(GuidUtility.TryParseGuid(allegedWebServiceToken, out tokenGuid), string.Format("The provided token {0} = \"{1}\" is not a GUID." , WebServiceTokenModelBinder.WebServiceTokenParameterName , allegedWebServiceToken)); // Token is valid if we are in a unit-test type situation if (IsValidAsUnitTestToken(tokenGuid, isBeingCalledByStaticConstructor)) { return tokenGuid; } // Parameterzied replacement tokens are valid too (although they result in a WebServiceToken that is deliberately half-baked and person-less. This should be OK // since we don't really want to use it for anything, just immediately replace it after we've generated routes and method signatures. if (IsValidAsParameterizedReplacementToken(tokenGuid)) { return tokenGuid; } Check.Require(tokenGuid != WebServiceTokenGuidForUnitTests, "Code appears to be trying to use the unit test web service token inappropriately, check environments and callers - that GUID is restricted use."); //Check.Require(tokenGuid != WebServiceTokenGuidForParameterizedReplacements, "Code appears to be trying to use the parameterized replacement web service token inappropriately, check environments and callers - that GUID is restricted use."); Check.RequireNotNull(HttpRequestStorage.DatabaseEntities.People.GetPersonByWebServiceAccessToken(tokenGuid), string.Format("The provided token {0} = \"{1}\" is not associated with a person." , WebServiceTokenModelBinder.WebServiceTokenParameterName , allegedWebServiceToken)); return tokenGuid; }
/// <summary> ///Throws an exception if the string <param name="allegedWebServiceToken"/> is not valid as a <see cref="WebServiceToken"/> /// </summary> private static Guid DemandValidWebServiceToken(string allegedWebServiceToken, bool isBeingCalledByStaticConstructor) { Check.Require(GuidUtility.TryParseGuid(allegedWebServiceToken, out var tokenGuid), $"The provided token {WebServiceTokenModelBinder.WebServiceTokenParameterName} = \"{allegedWebServiceToken}\" is not a GUID."); if (IsValidAsUnitTestToken(tokenGuid, isBeingCalledByStaticConstructor)) { return(tokenGuid); } Check.Require(tokenGuid != WebServiceTokenGuidForUnitTests, "Code appears to be trying to use the unit test web service token inappropriately, check environments and callers - that GUID is restricted use."); Check.RequireNotNull(HttpRequestStorage.DatabaseEntities.People.GetPersonByWebServiceAccessToken(tokenGuid), $"The provided token {WebServiceTokenModelBinder.WebServiceTokenParameterName} = \"{allegedWebServiceToken}\" is not associated with a person."); return(tokenGuid); }