//using System; //using System.Data; //using System.Configuration; //using System.Web; //using System.Web.Security; //using System.Web.UI; //using System.Web.UI.WebControls; //using System.Web.UI.WebControls.WebParts; //using System.Web.UI.HtmlControls; //using System.Xml.Serialization; //using System.Xml; //namespace umbraco.webservices //{ // public class authentication // { // /// // /// Standart user-validation. All services must perform this // /// // /// // /// // /// // /// First checks if the webservices are enabled. Then checks if the user is valid // /// (username and password). Finally it checks if the user has access to the specific service // /// // public static void StandartRequestCheck(string username, string password, authentication.EService service) // { // // We check if services are enabled and user has access // if (!umbraco.UmbracoSettings.Webservices.Enabled) // throw new Exception("webservices not enabled"); // // Validating the user // GetUser(username, password); // // Checking if user can use that specific service // if (!authentication.UserHasAccess(username, service)) // throw new Exception("user has not access to this service"); // } // /// // /// Gets the umbraco-user from username and password // /// // /// // /// // /// // public static umbraco.BusinessLogic.User GetUser(string username, string password) // { // umbraco.BusinessLogic.User user; // try // { // user = new umbraco.BusinessLogic.User(username, password); // if (user == null) // throw new Exception("Incorrect credentials. No user found. Call aborted"); // } // catch (Exception ex) // { // throw new Exception("Incorrect credentials. Call aborted (error: " + ex.Message + Environment.NewLine + Environment.NewLine + ex.StackTrace + ")"); // } // return user; // } // /// // /// List of accesible the services // /// // public enum EService // { // DocumentService, // FileService, // StylesheetService, // MemberService, // MaintenanceService, // TemplateService // }; // /// // /// Checks if a user has access to a specific webservice // /// // /// user to check // /// the webservice to check for // /// true, if user has access otherwise false // public static bool UserHasAccess(string username, EService service) // { // switch (service) // { // case EService.DocumentService: // return -1 < Array.IndexOf(umbraco.UmbracoSettings.Webservices.documentServiceUsers, username); // case EService.FileService: // return -1 < Array.IndexOf(umbraco.UmbracoSettings.Webservices.fileServiceUsers, username); // case EService.StylesheetService: // return -1 < Array.IndexOf(umbraco.UmbracoSettings.Webservices.stylesheetServiceUsers, username); // case EService.MemberService : // return -1 < Array.IndexOf(umbraco.UmbracoSettings.Webservices.memberServiceUsers, username); // case EService.MaintenanceService: // return -1 < Array.IndexOf(umbraco.UmbracoSettings.Webservices.maintenanceServiceUsers, username); // case EService.TemplateService : // return -1 < Array.IndexOf(umbraco.UmbracoSettings.Webservices.templateServiceUsers, username); // default: // return false; // } // } // } //}