private BWebServiceResponse OnRequest_Internal(HttpListenerContext _Context, Action <string> _ErrorMessageAction = null) { if (_Context.Request.HttpMethod != "POST" && _Context.Request.HttpMethod != "DELETE") { _ErrorMessageAction?.Invoke("User_UpdateDeleteBaseRight_ForUser: POST and DELETE methods are accepted. But received request method: " + _Context.Request.HttpMethod); return(BWebResponse.MethodNotAllowed("POST and DELETE methods are accepted. But received request method: " + _Context.Request.HttpMethod)); } RequestedUserID = RestfulUrlParameters[RestfulUrlParameter_UsersKey]; RequestedBaseRightWildcard = WebUtility.UrlDecode(RestfulUrlParameters[RestfulUrlParameter_BaseAccessRightsKey]); RequestedBaseRightWildcard_Regex = BUtility.WildCardToRegular(RequestedBaseRightWildcard); if (!Controller_AtomicDBOperation.Get().GetClearanceForDBOperation(InnerProcessor, UserDBEntry.DBSERVICE_USERS_TABLE(), RequestedUserID, _ErrorMessageAction)) { return(BWebResponse.InternalError("Atomic operation control has failed.")); } BWebServiceResponse Result; if (_Context.Request.HttpMethod == "POST") { Result = UpdateBaseRightForUser(_Context, _ErrorMessageAction); } else { Result = DeleteBaseRightForUser(_Context, _ErrorMessageAction); } Controller_AtomicDBOperation.Get().SetClearanceForDBOperationForOthers(InnerProcessor, UserDBEntry.DBSERVICE_USERS_TABLE(), RequestedUserID, _ErrorMessageAction); return(Result); }
public bool GetCallbackFromRequest(out Func <BWebServiceBase> _Initializer, out string _MatchedPrefix, HttpListenerContext _Context) { _Initializer = null; _MatchedPrefix = null; if (_Context == null || Prefixes_SortedByLength == null || Prefixes_SortedByLength.Length == 0 || ListenerInitializer == null) { return(false); } for (var i = (Prefixes_SortedByLength.Length - 1); i >= 0; i--) { var Prefix = Prefixes_SortedByLength[i]; if (Regex.IsMatch(_Context.Request.RawUrl, BUtility.WildCardToRegular(Prefix))) { _MatchedPrefix = Prefix; _Initializer = ListenerInitializer; return(_Initializer != null); } } return(false); }
public static bool CheckBaseFinalFullContainment(List <AccessScope> _BaseScopeList, List <AccessScope> _FinalScopeList) { foreach (var FinalScope in _FinalScopeList) { bool bFound = false; foreach (var BaseScope in _BaseScopeList) { //Checked if (Regex.IsMatch(FinalScope.WildcardPath, BUtility.WildCardToRegular(BaseScope.WildcardPath))) { bool bAccessRightsExist = true; foreach (var FinalAccessRight in FinalScope.AccessRights) { if (!BaseScope.AccessRights.Contains(FinalAccessRight)) { bAccessRightsExist = false; break; } } if (bAccessRightsExist) { bFound = true; break; } } } if (!bFound) { return(false); } } return(true); }