示例#1
0
        public void Add(IMemoryCallback callback)
        {
            if (!AvailableScopes.Contains(callback.Scope))
            {
                throw new InvalidOperationException($"{callback.Scope} is not currently supported for callbacks");
            }

            if (!callback.Address.HasValue)
            {
                throw new NotImplementedException("Wildcard callbacks (no address specified) not currently implemented.");
            }

            var container = new CallbackContainer(callback);

            if (container.Callback.Type == MemoryCallbackType.Execute)
            {
                _executeCallback = RunExecCallback;
                _execPcs[callback.Address.Value] = callback;
                MGBAHawk.ZZHacky.BizSetExecCallback(_mgba.Core, _executeCallback);
            }
            else
            {
                MGBAHawk.ZZHacky.BizSetMemCallback(_mgba.Core, container.CallDelegate);
                container.ID = MGBAHawk.ZZHacky.BizSetWatchpoint(_mgba.Core, callback.Address.Value, container.WatchPointType);
            }

            _callbacks.Add(container);
        }
示例#2
0
        public IActionResult Authorization(string clientId, string scopes)
        {
            if (Request.Cookies.ContainsKey(OAUTH2_COOKIE))
            {
                var tokenString = Request.Cookies[OAUTH2_COOKIE];
                var token       = _context.Credential.Find(tokenString);
                if (token != null && token.IsValid())
                {
                    var client = _context.RegisteredClient.Find(clientId);
                    if (client == null)
                    {
                        return(NotFound("Invalid client."));
                    }

                    Dictionary <string, Oauth2Scope> scopeItems = AvailableScopes.GetOauth2Scopes(scopes);
                    if (scopeItems.Count == 0)
                    {
                        return(NotFound("Invalid scopes."));
                    }

                    var authorizationInformation = new AuthorizationInformation
                    {
                        RegisteredClient = client,
                        Oauth2Scopes     = scopeItems
                    };
                    return(View(authorizationInformation));
                }
            }
            return(RedirectToAction("Authentication", new { redirectUrl = Request.GetDisplayUrl() }));
        }
示例#3
0
        public OAuth2ResourceProvider AddRequestScope <TRequest>()
            where TRequest : OAuthRequest, new()
        {
            var request = new TRequest();

            foreach (var scope in request.RequiredScopes)
            {
                if (!AvailableScopes.Contains(scope))
                {
                    throw new InvalidScopeException(string.Format(
                                                        StringResources.ScopeException,
                                                        scope,
                                                        this.GetType().Name));
                }
                if (!Scopes.Contains(scope))
                {
                    Scopes.Add(scope);
                }
            }

            return(this);
        }