public AuthorizationData(Asn1Element element) { for (var c = 0; c < element.Count; c++) { var auth = new AuthorizationData(); for (var i = 0; i < element[c].Count; i++) { var child = element[c][i]; switch (child.ContextSpecificTag) { case 0: auth.AdType = child.AsLong(); break; case 1: auth.Authorizations.Add(new AuthorizationData(child)); break; case 128: // this isn't correct and wont ever be reached auth.Authorizations.Add(new PrivilegedAttributeCertificate(child)); break; default: auth.AdData = child.Value; break; } } Authorizations.Add(auth); } }
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); }
public AuthorizationData(Asn1Element element) { for (var c = 0; c < element.Count; c++) { var child = element[c]; Authorizations.Add(new AuthorizationDataElement(child)); } }
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; } } }
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()); }
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); }
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); }
/// <summary> /// Assign authorizations directly /// </summary> /// <param name="authorizationsId">Authorizations Id</param> /// <returns>Task</returns> public void AssignAuthorizations(IEnumerable <int> authorizationsId) { if (Root) { throw new ForbiddenOperationDomainException("Root user"); } foreach (var id in authorizationsId) { // Skip already added authorizations if (Authorizations.Any(i => i.DefAuthorizationId == id)) { continue; } Authorizations.Add( new UserAuthorization { DefAuthorizationId = id, UserId = Id }); } }