public static bool HaveAuthorization(int userId, Authorizations authorization, Bm2sBO.Utils.Modules module) { User user = new User(); user.Request.Ids.Add(userId); user.Get(); return ModuleUtils.HaveAuthorization(user.Response.Users.FirstOrDefault(), authorization, module); }
public IHttpActionResult Put(int id, [FromBody] Authorizations access) { try { using (IntegraContext integ = new IntegraContext()) { var resp = integ.Authorizations.FirstOrDefault(e => e.AccessServiceId == id); if (resp == null) { return(Content(HttpStatusCode.NotFound, "Authorization with ID " + id.ToString() + " not found to update")); } else { resp.Id = access.Id; resp.Descrip = access.Descrip; integ.SaveChanges(); return(Ok(resp)); } } } catch (Exception ex) { return(Content(HttpStatusCode.NotFound, ex.Message)); } }
public CommandAttribute(string commands, Authorizations level, string format = "") : base() { Commands = commands.ToUpper().Split(' '); Level = level; Format = format; }
/// <summary> /// Inserts the authorization. /// </summary> /// <param name="clientsid">The clientsid.</param> /// <param name="apilibraryids">The apilibraryids.</param> /// <returns></returns> /// 创建人:李允智 /// 创建时间:2016/2/2 /// 描述:插入权限 public string InsertAuthorization(string clientsid, string apilibraryids) { try { Authorizations authorization = AuthorizationsCore.GetInstance().GetAuthorization(clientsid); if (string.IsNullOrEmpty(apilibraryids)) { AuthorizationsCore.GetInstance().DeleteAuthorization(authorization.id); } else { if (authorization != null) { AuthorizationsCore.GetInstance().DeleteAuthorization(authorization.id); } authorization = new Authorizations(); authorization.apilibraryids = apilibraryids; authorization.clientsid = clientsid; AuthorizationsCore.GetInstance().InsertAuthorization(authorization); } comm.success = true; comm.message = "保存成功"; } catch (Exception) { comm.success = false; comm.message = "保存失败"; } return(JsonHelper.SerializeObject(comm)); }
public IHttpActionResult UpdateItem(Authorizations authorizations) { //Inicializo mi conexión a SAP SAPConnection conncetion = new SAPConnection(); SAPbobsCOM.Company company = conncetion.OpenConnection(); SAPbobsCOM.CompanyService oCompanyService = company.GetCompanyService(); SAPbobsCOM.ApprovalRequestsService approvalSrv = oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.ApprovalRequestsService); ApprovalRequestParams oParams = approvalSrv.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams) as ApprovalRequestParams; oParams.Code = authorizations.WddCode; ApprovalRequest oData = approvalSrv.GetApprovalRequest(oParams); //Agregar una autorización oData.ApprovalRequestDecisions.Add(); oData.ApprovalRequestDecisions.Item(0).ApproverUserName = "******"; oData.ApprovalRequestDecisions.Item(0).ApproverPassword = "******"; oData.ApprovalRequestDecisions.Item(0).Status = BoApprovalRequestDecisionEnum.ardApproved; oData.ApprovalRequestDecisions.Item(0).Remarks = authorizations.Remarks; //Actualizar la autorización approvalSrv.UpdateRequest(oData); return(Ok(responseCall)); }
public IHttpActionResult UpdateItems([FromBody] Authorizations authorizations) { //Inicializo mi conexión a SAP SAPConnection conncetion = new SAPConnection(); SAPbobsCOM.Company company = conncetion.OpenConnection(authorizations.dbname, authorizations.userSap, authorizations.userSapPass); SAPbobsCOM.CompanyService oCompanyService = company.GetCompanyService(); SAPbobsCOM.ApprovalRequestsService approvalSrv = oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.ApprovalRequestsService); ApprovalRequestParams oParams = approvalSrv.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams) as ApprovalRequestParams; oParams.Code = authorizations.WddCode; ApprovalRequest oData = approvalSrv.GetApprovalRequest(oParams); //Agregar una autorización oData.ApprovalRequestDecisions.Add(); oData.ApprovalRequestDecisions.Item(0).ApproverUserName = authorizations.userSap; oData.ApprovalRequestDecisions.Item(0).ApproverPassword = authorizations.userSapPass; //Autorizar if (authorizations.Status == "Y") { oData.ApprovalRequestDecisions.Item(0).Status = BoApprovalRequestDecisionEnum.ardApproved; } else if (authorizations.Status == "N") { oData.ApprovalRequestDecisions.Item(0).Status = BoApprovalRequestDecisionEnum.ardNotApproved; } oData.ApprovalRequestDecisions.Item(0).Remarks = authorizations.Remarks; //Actualizar la autorización approvalSrv.UpdateRequest(oData); return(Ok(authorizations)); }
public Authorization AddAuthorization(Type parentType, PropertyInfo propertyInfo) { var authFieldName = $"{parentType.FullName}.{propertyInfo.Name}"; var typeAttribute = parentType.GetCustomAttributes(typeof(AuthorizeAttribute)).FirstOrDefault() as AuthorizeAttribute; if (propertyInfo.GetMethod == null || !propertyInfo.GetMethod.IsPublic) { return(null); } var propertyAttribute = propertyInfo.GetCustomAttributes(typeof(AuthorizeAttribute)).FirstOrDefault() as AuthorizeAttribute; if (typeAttribute == null && propertyAttribute == null) { if (AllowMissingAuthorizations) { return(null); } throw new Exception($"Property and it's class does not have any Authorize attribute. Property: {authFieldName}"); } var authorization = Authorization.Create(authFieldName, (propertyAttribute ?? typeAttribute).Claims); Authorizations.Add(authorization); return(authorization); }
private async Task CreateAuthorizationAsync( [NotNull] AuthenticationTicket ticket, [NotNull] OpenIddictOptions options, [NotNull] HttpContext context, [NotNull] OpenIdConnectRequest request) { var descriptor = new OpenIddictAuthorizationDescriptor { Principal = ticket.Principal, Status = OpenIddictConstants.Statuses.Valid, Subject = ticket.Principal.GetClaim(OpenIdConnectConstants.Claims.Subject), Type = OpenIddictConstants.AuthorizationTypes.AdHoc }; foreach (var property in ticket.Properties.Items) { descriptor.Properties.Add(property); } foreach (var scope in ticket.GetScopes()) { descriptor.Scopes.Add(scope); } // If the client application is known, bind it to the authorization. if (!string.IsNullOrEmpty(request.ClientId)) { var application = await Applications.FindByClientIdAsync(request.ClientId, context.RequestAborted); if (application == null) { throw new InvalidOperationException("The client application cannot be retrieved from the database."); } descriptor.ApplicationId = await Applications.GetIdAsync(application, context.RequestAborted); } var authorization = await Authorizations.CreateAsync(descriptor, context.RequestAborted); if (authorization != null) { var identifier = await Authorizations.GetIdAsync(authorization, context.RequestAborted); if (string.IsNullOrEmpty(request.ClientId)) { Logger.LogInformation("An ad hoc authorization was automatically created and " + "associated with an unknown application: {Identifier}.", identifier); } else { Logger.LogInformation("An ad hoc authorization was automatically created and " + "associated with the '{ClientId}' application: {Identifier}.", request.ClientId, identifier); } // Attach the unique identifier of the ad hoc authorization to the authentication ticket // so that it is attached to all the derived tokens, allowing batched revocations support. ticket.SetProperty(OpenIddictConstants.Properties.AuthorizationId, identifier); } }
public AuthorizationLevel GetAuthorizationLevel(Authorizations operation) { if (authorizationLevels.ContainsKey(operation)) { return(authorizationLevels[operation]); } throw new AuthorizitionNotDefinedException(); }
public ChannelModeAttribute(Modes mode, ModeSyntax syntax, Authorizations level, char prefix = (char)0) : base() { Mode = mode; Syntax = syntax; Level = level; Prefix = prefix == 0 ? (char?)null : prefix; }
public void Delete(Authorization auth) { if (Authorizations.Remove(auth)) { auth.Invalidated -= OnAuthorizationInvalidated; Save(); } }
/// <summary> /// Remove authorizations /// </summary> /// <param name="authorizationsId">User authorizations id</param> /// <returns></returns> public void RemoveAuthorizations(IEnumerable <int> authorizationsId) { if (Root) { throw new ForbiddenOperationDomainException("Root user"); } Authorizations.RemoveAll(userAuth => authorizationsId.Contains(userAuth.DefAuthorizationId)); }
public AuthorizationData(Asn1Element element) { for (var c = 0; c < element.Count; c++) { var child = element[c]; Authorizations.Add(new AuthorizationDataElement(child)); } }
public Authenticator Decode(Asn1Element asn1Element) { Asn1Element childNode = asn1Element[0]; for (var i = 0; i < childNode.Count; i++) { var node = childNode[i]; switch (node.ContextSpecificTag) { case 0: VersionNumber = node[0].AsLong(); break; case 1: Realm = node[0].AsString(); break; case 2: CName = new PrincipalName().Decode(node[0], Realm); break; case 3: Checksum = node[0].Value; break; case 4: CuSec = node[0].AsLong(); break; case 5: CTime = node[0].AsDateTimeOffset(); break; case 6: SubSessionKey = new EncryptionKey().Decode(node[0]); break; case 7: SequenceNumber = node[0].AsLong(); break; case 8: var parent = node[0]; for (var p = 0; p < parent.Count; p++) { var azElements = AuthorizationDataElement.ParseElements(parent[p]); Authorizations.AddRange(azElements); } break; } } return(this); }
protected UserSurrogate(HostMask mask, Authorizations level) { Mask = mask; Level = Level; Password = null; LastSeen = DateTime.MaxValue; Modes = new Dictionary<Modes, string>(); Properties = new Dictionary<string, object>(); Flags = new List<string>(); }
protected UserSurrogate(HostMask mask, Authorizations level) { Mask = mask; Level = Level; Password = null; LastSeen = DateTime.MaxValue; Modes = new Dictionary <Modes, string>(); Properties = new Dictionary <string, object>(); Flags = new List <string>(); }
public async Task <bool> Login(string Email, string Password) { bool Result = false; bool fSpecialLogin = (Email != this.Email); if (Authorization == null || fSpecialLogin) { string Json = string.Format( "{{" + "\"email\":\"{0}\"," + "\"password\":\"{1}\"" + "}}", Email, Password); StringContent Content = new StringContent(Json); Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage Response = await new HttpClient().PostAsync(sBaseUrl + "account/login", Content); await DebugHttpCall(Json, Response); if (Response.StatusCode == HttpStatusCode.OK) { string Resp = await Response.Content.ReadAsStringAsync(); IEnumerable <string> Authorizations; if (Response.Headers.TryGetValues("Authorization", out Authorizations)) { IEnumerator <string> Auth = Authorizations.GetEnumerator(); Auth.MoveNext(); Authorization = Auth.Current; } JObject jData = JObject.Parse(Resp); sOrgId = (string)jData["org"]["id"]; sUserId = (string)jData["user"]["id"]; sBaseUrl = string.Format(@"https://api.sling.is/v1/{0}/", sOrgId); if (!fSpecialLogin) { HttpContext.Current.Session["SlingAuth"] = Authorization; HttpContext.Current.Session["SlingOrg"] = sOrgId; HttpContext.Current.Session["SlingUser"] = sUserId; } } } if (Authorization != null && Authorization.Length > 0) { Result = true; } return(Result); }
public Authenticator(Asn1Element asn1Element) { Asn1Element childNode = asn1Element[0]; for (var i = 0; i < childNode.Count; i++) { var node = childNode[i]; switch (node.ContextSpecificTag) { case 0: VersionNumber = node[0].AsLong(); break; case 1: Realm = node[0].AsString(); break; case 2: CName = new PrincipalName(node); break; case 3: Checksum = node[0].Value; break; case 4: CuSec = node[0].AsLong(); break; case 5: CTime = node[0].AsDateTimeOffset(); break; case 6: Subkey = node[0][1][0].Value; break; case 7: SequenceNumber = node[0].AsLong(); break; case 8: // this is not right. its ASN.1 plus vendor-specific data var parent = node[0]; for (var p = 0; p < parent.Count; p++) { var child = parent[p]; Authorizations.Add(new AuthorizationData(parent)); } break; } } }
public UserAuthorize GetAuthorizeByProgramID(string programId) { UserAuthorize authorize = null; if (Authorizations != null) { authorize = Authorizations.Where(a => a.ProgramId.Equals(programId)).FirstOrDefault(); } return(authorize); }
public static IState Instance(Confirm promptMessage, Authorizations authorizations) { AuthorizationType = authorizations; ReturnConfirm = promptMessage.ReturnConfirm; ReturnCancel = promptMessage.ReturnCancel; ReturnConfirmWithArgs = promptMessage.ReturnConfirmWithArgs; data = promptMessage.Data; promptMessage.ReturnConfirm = new StateInstance(CheckAuthorization); return(States.ConfirmCashier.Instance(promptMessage)); }
public bool Authorize(string name) { var authorization = Authorizations.FirstOrDefault(a => a.TargetName == name); var authorizationAllowed = authorization != null && authorization.Authorize(CurrentRoles); if (!authorizationAllowed && authorization == null && AllowMissingAuthorizations) { authorizationAllowed = true; } return(authorizationAllowed); }
public void SetStatusFromAuthorizations() { if (Authorizations.All(a => a.Status == AuthorizationStatus.Valid)) { SetStatus(OrderStatus.Ready); } if (Authorizations.Any(a => a.Status.IsInvalid())) { SetStatus(OrderStatus.Invalid); } }
protected UserBase(ServerBase server, Locations location, HostMask mask, Authorizations level) : base(mask, level) { Server = server; Location = location; Channels = new Dictionary <string, ChannelBase>(); SessionFlags = new List <string>(); if (mask.Nickname != "*" && mask.Nickname != null) { Id = mask.Nickname.ToLower(); } }
private void LastFmLoginService_UserLogout(ILastFmLoginService sender, EventArgs e) { var item = Authorizations.FirstOrDefault(s => s.ServiceName == "last.fm"); if (item == null) { return; } Authorizations.Remove(item); Authorizations.Add(_lastFmLoginService.GetServiceAuthorization()); }
/// <summary> /// Get all of the non-BCBA Authorizations that were active at the specified reference date /// </summary> public List <Authorizations.Authorization> GetActiveNonBCBAAuthorizations(DateTime refDate) { var auths = Authorizations .Where(x => x.EndDate >= refDate && x.StartDate <= refDate && x.AuthorizationCode.Code == "GENERAL") .ToList(); return(auths); }
private void btnRegister_Click(object sender, EventArgs e) { DataRow studentData = ((DataRowView)cboStudent.SelectedItem).Row; DataRow sectionData = ((DataRowView)cboRegCrn.SelectedItem).Row; Authorizations newAuth = new Authorizations() { Sid = studentData.Field <short>("sid"), Crn = sectionData.Field <int>("crn"), //Term = sectionData.Field<string>("term"), //Year = sectionData.Field<short>("year"), AuthType = "" }; Sections newSec = new Sections() { //Cap = sectionData.Field<short>("cap"), Auth = sectionData.Field <string>("auth") }; Sections newSec2 = new Sections() { //Cap = sectionData.Field<short>("cap"), Crn = sectionData.Field <int>("crn") }; Enrolls newEnroll = new Enrolls() { Sid = studentData.Field <short>("sid"), Term = sectionData.Field <string>("term"), Year = sectionData.Field <short>("year"), Crn = sectionData.Field <int>("crn") }; if (newSec.Auth.ToString() == "N" || (_sid.Sid == newAuth.Sid && newAuth.Crn == newSec2.Crn)) { //register in the class if (Create <Enrolls>(newEnroll)) { MessageBox.Show("You enrolled in " + newEnroll.Crn); RefreshCurrentSchedule(); } } else { //deny class registration MessageBox.Show("Registration denied for " + newEnroll.Crn); } }
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { var auth = (VKAuthorization)_vkLoginService.GetServiceAuthorization(); Authorizations.Add(auth); Authorizations.Add(_lastFmLoginService.GetServiceAuthorization()); _lastFmLoginService.UserLogout += LastFmLoginService_UserLogout; LoadVKUserName(auth); AvailableLanguages = _locService.GetAvailableLanguages(); base.OnNavigatedTo(e, viewModelState); }
/// <summary> /// Get all of the Authorizations that were active at the specified reference date /// </summary> public List <Authorizations.Authorization> GetActiveAuthorizations(DateTime refDate) { if (Authorizations == null || Authorizations.Count == 0) { return(new List <Authorizations.Authorization>()); } var auths = Authorizations .Where(x => x.EndDate >= refDate.Date && x.StartDate <= refDate.Date) .ToList(); return(auths); }
public GitHubApi(IHttpClient client) { this.client = client; client.BeforeRequest += ClientOnBeforeRequest; client.AfterRequest += ClientOnAfterRequest; Repositories = new Repositories(client); Gists = new Gists(client); Issues = new Issues(client); Milestones = new Milestones(client); Labels = new Labels(client); Users = new Users(client); Authorizations = new Authorizations(client); Keys = new Keys(client); }
private void GrantAuth_Click(object sender, EventArgs e) { DataRow studentData = ((DataRowView)authStudentComboBox.SelectedItem).Row; DataRow sectionData = ((DataRowView)authSectionComboBox.SelectedItem).Row; string authtype = standardAuth.Checked ? "AUTH" : "OVFL"; Authorizations newAuth = new Authorizations() { Sid = studentData.Field <short>("sid"), Crn = sectionData.Field <int>("crn"), Term = sectionData.Field <string>("term"), Year = sectionData.Field <short>("year"), AuthType = authtype }; List <Authorizations> auth = DataAccess.Retrieve <Authorizations>(new ConditionList() { Conditions = new List <Condition>() { new Condition("sid", Condition.Operators.Equal, newAuth.Sid.ToString()), new Condition("crn", Condition.Operators.Equal, newAuth.Crn.ToString()), new Condition("term", Condition.Operators.Equal, newAuth.Term), new Condition("year", Condition.Operators.Equal, newAuth.Year.ToString()), new Condition("authType", Condition.Operators.Equal, authtype) } }); if (auth.Count <= 0) { ClearErrors(); if (Create <Authorizations>(newAuth)) { MessageBox.Show(studentData.Field <string>("fname") + " " + studentData.Field <string>("lname") + " successfully authorized for " + sectionData.Field <string>("cprefix") + sectionData.Field <Int16>("cno").ToString(), null, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(LastError); } } else { MessageBox.Show("This student is already authorized for this section.", null, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public IExposureConfiguration Authorize(string role = null, string policy = null) { if (role != null) { Authorizations.Add(new UserRoleAuthorization(role)); } else if (policy != null) { Authorizations.Add(new UserPolicyAuthorization(policy)); } else { Authorizations.Add(new UserAuthenticatedAuthorization()); } return(this); }
public List <Authorizations> GetAuthorizations() { DA_Worker_Details dm = new DA_Worker_Details(); ListDictionary Params = new ListDictionary(); DataSet ds = dm.GetAuthorizations(Params); List <Authorizations> l = new List <Authorizations>(); Authorizations f; foreach (DataRow item in ds.Tables[0].Rows) { f = new Authorizations(); f.Code = BLCtrl.getInt(item, "Code", 0); f.Authorization = BLCtrl.getString(item, "Authorization", ""); l.Add(f); } return(l); }
public IHttpActionResult CreateAccessPoint([FromBody] Authorizations access) { try { using (IntegraContext integ = new IntegraContext()) { integ.Authorizations.Add(access); integ.SaveChanges(); var mess = Request.CreateResponse(HttpStatusCode.Created, access); mess.Headers.Location = new Uri(Request.RequestUri + access.AccessServiceId.ToString()); return(Ok(mess)); } } catch (Exception ex) { return(Content(HttpStatusCode.NotFound, ex.Message)); } }
public CaseAuthorization GetCaseAuthForService(Service service, int authClassID) { // service will have a pre-mapped authClassID, we need to match that up with // whatever's on file for the cases authorizations var classedAuths = Authorizations.Where(x => x.AuthClass.ID == authClassID).ToList(); if (classedAuths == null || classedAuths.Count == 0) { return(null); } if (classedAuths.Count == 1) { return(classedAuths[0]); } // there's more than one auth matching the required class // let's grab the latest ending one... return(classedAuths.OrderByDescending(x => x.EndDate).FirstOrDefault()); }
public static bool HaveAuthorization(Bm2s.Poco.Common.User.User user, Authorizations authorization, Bm2sBO.Utils.Modules module) { return user != null && (user.IsAdministrator || ModuleUtils.ModulesAuthorization(user.Id).Any(item => item.Code.ToLower() == (authorization.ToString() + "_" + module.ToString()).ToLower() && (!item.EndingDate.HasValue || item.EndingDate.Value < DateTime.Now.Date))); }
public static bool HaveAuthorization(Authorizations authorization, Bm2sBO.Utils.Modules module) { return ModuleUtils.HaveAuthorization(UserUtils.CurrentUser.Id, authorization, module); }