/// <summary> /// Virtual method.Can be overriden with the custom Authorization. /// </summary> /// <param name="deviceIdentifier"></param> /// <param name="user"></param> /// <param name="password"></param> /// <param name="filterContext"></param> /// <returns></returns> protected override bool OnAuthorizeUser(string deviceIdentifier, string user, string password, System.Web.Http.Controllers.HttpActionContext filterContext) { if (!base.OnAuthorizeUser(deviceIdentifier, user, password, filterContext)) { return(false); } SOFTTEK.SCMS.Entity.Security.User userCredentials = new SOFTTEK.SCMS.Entity.Security.User { DeviceIdentifier = deviceIdentifier, NetworkAccount = user, Password = password }; SOFTTEK.SCMS.Foundation.Business.BusinessContext ctx = new SOFTTEK.SCMS.Foundation.Business.BusinessContext { SecurityContext = new Foundation.Security.SecurityContext { DeviceID = userCredentials.DeviceIdentifier, ClientID = userCredentials.NetworkAccount, AuthorizationTicket = userCredentials.NetworkAccount, AppID = new System.Configuration.AppSettingsReader().GetValue("S_SRA_APP_idENTIFIER", typeof(string)).ToString() } }; SOFTTEK.SCMS.Business.Security.SecurityBO securityProvider = new Business.Security.SecurityBO(ctx); if (securityProvider.Authorize(userCredentials) != null) { return(true); } return(false); }
// POST api/security public IHttpActionResult Post([FromBody] SOFTTEK.SCMS.Entity.Security.User user) { IHttpActionResult result = Conflict(); SOFTTEK.SCMS.Foundation.Business.BusinessContext ctx = new SOFTTEK.SCMS.Foundation.Business.BusinessContext { SecurityContext = new Foundation.Security.SecurityContext { DeviceID = user.DeviceIdentifier, ClientID = user.NetworkAccount, AuthorizationTicket = user.NetworkAccount, AppID = new System.Configuration.AppSettingsReader().GetValue("S_SRA_APP_idENTIFIER", typeof(string)).ToString() } }; SOFTTEK.SCMS.Business.Security.SecurityBO secManagerBO = new Business.Security.SecurityBO(ctx); SOFTTEK.SCMS.Entity.Security.Token authorizationToken = secManagerBO.Authorize(user); if (authorizationToken != null) { result = Json(authorizationToken); } return(result); }