Home  /  Questions  /  Question



265   99.7
Dec 29, 2010


Question on DPF ActionService ValidRequest method

I'm going through the ActionService WCF service, specifically the ValidRequest method and saw that the section that validates the ClientTag was commented with:

// Validate Client Tag. 
// Hardcoded here. In production this should query a 'client' table in a database.
if ((Validate.ClientTag & validate) == Validate.ClientTag)
{
  if (request.ClientTag != "ABC123")
  {
    response.Acknowledge = AcknowledgeType.Failure;
    response.Message = "Unknown Client Tag";
    return false;
  }
}
Could you expand on how that might be implemented?  I'm trying to work this into a project of mine and wanted to see how a production application would employ this.

Doug
 



588   99.9
Jan 01, 2011
Hi Doug,

Happy New Year!

The "ABC123" value in this case can be in a Settings table in the database as a value for a setting called "ClientTag".  The Settings table might be just a table with two columns (and a rowversion column), called "Name" and "Value".  This can be a table with general collection of settings that can be collected in name/value pairs.

So in this table you can have something like the following:
  • Name = "SiteName", Value = "My Cool Website"
  • Name = "ClientTag", Value = "HJ6Ev6qNMtL?XnHXmGRl1VE@"
  • etc

Then you can simply replace the "ABC123" string with a call to your service or repository that retrieves this value.

I hope this answers your question.

King Wilder
if ((Validate.ClientTag & validate) == Validate.ClientTag)
{
  var setting = settingsDao.GetAll()
     .Where(s => s.Name == "ClientTag").SingleOrDefault();
     
  if (request.ClientTag != setting.Value)
  {
    response.Acknowledge = AcknowledgeType.Failure;
    response.Message = "Unknown Client Tag";
    return false;
  }
}