Taylohtio/GeneralApi/GeneralApi.WcfService/CustomCredentialsValidator.cs

24 lines
810 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Security;
using System.ServiceModel.Web;
using TaloyhtioIntegration_resx = Taloyhtio.GeneralApi.Resources.Resources.TaloyhtioIntegration;
using WebException = WcfRestContrib.ServiceModel.Web.Exceptions.WebException;
namespace Taloyhtio.GeneralApi.WcfService
{
public class CustomCredentialsValidator : System.IdentityModel.Selectors.UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (!FormsAuthentication.Authenticate(userName, password))
{
throw new WebException(HttpStatusCode.Forbidden, TaloyhtioIntegration_resx.SecurityNotAuthenticated);
}
}
}
}