WSE: Custom TokenManager
We have a client, we have a service, now we need to be able to secure the lines of communication. So let's build a Token Manager that will use the previously described database. I'm not going to go over creating the new methods. If you're reading this, I'm assuming that this is old hat. What I did do was to create a method that returns a strongly-typed datatable with all of the account information given a username and password. Check out the code below:
namespace WebService
{
public class TokenManager : UsernameTokenManager
{
public TokenManager()
{
}
public TokenManager(XmlNodeList nodes)
: base(nodes)
{
}
protected override string AuthenticateToken(UsernameToken token)
{
DataAccess.WebDataSetTableAdapters.AccountTableAdapter ta = new
DataAccess.WebDataSetTableAdapters.AccountTableAdapter();
DataAccess.WebDataSet.AccountDataTable dt =
ta.GetDataByUsernamePassword(token.Username, token.Password);
if (dt.Rows.Count == 1)
{
return token.Password;
}
else
{
throw new Exception("SHAME ON YOU, INVALID USER!!!");
}
}
}
}






0 Comments:
Post a Comment
<< Home