コード例 #1
0
 public BookmarkController(IServiceProvider provider)
 {
     _provider      = provider;
     _api           = (EVEStandardAPI)provider.GetService(typeof(EVEStandardAPI));
     _universeCache = provider.GetService <IUniverseCache>();
     _jumpCache     = provider.GetService <IJumpCache>();
 }
コード例 #2
0
        public VerificationWindow(EVEStandardAPI client)
        {
            Log.Info("New Verification Window Opened");
            InitializeComponent();

            _client = client;
        }
コード例 #3
0
        public VerificationWindow(EVEStandardAPI client)
        {
            InitializeComponent();

            _client       = client;
            Authorization = _client.SSOv2.AuthorizeToEVEUri(EsiScopes.Scopes);
        }
コード例 #4
0
ファイル: Startup.cs プロジェクト: wkpatrick/Mining-Foreman
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Initialize the client
            var esiClient = new EVEStandardAPI(
                "EVEStandard",            // User agent
                DataSource.Tranquility,   // Server [Tranquility/Singularity]
                TimeSpan.FromSeconds(30), // Timeout
                Configuration["SSOCallbackUrl"],
                Configuration["ClientId"],
                Configuration["SecretKey"]);

            // Register with DI container
            services.AddSingleton <EVEStandardAPI>(esiClient);
            services.AddSingleton <IHostedService, ESIService>();
            // Add cookie authentication and set the login url
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options => {
                options.LoginPath       = "/Auth/Login";
                options.Cookie.HttpOnly = false;
            });
            services.AddDistributedMemoryCache();
            services.AddSession();
            services.AddCors();
            services.AddControllers();
        }
コード例 #5
0
        public JumpCache(IServiceProvider services)
        {
            _api = (EVEStandardAPI)services.GetService(typeof(EVEStandardAPI));
            _tranquilityDbContext = (TranquilityContext)services.GetService(typeof(TranquilityContext));
            _navigatorDbContext   = (NavigatorContext)services.GetService(typeof(NavigatorContext));

            _solarSystemRepository = new SolarSystemRepository();
        }
コード例 #6
0
ファイル: HomeController.cs プロジェクト: PaiChuuLi/EMS
        public IActionResult Login()
        {
            Emsservice = new scopesservice(Path.Combine(_hostingEnvironment.WebRootPath, @"res\emsscopes.ems"));
            Emsservice.GetScopes();
            EmsIniservice = new iniservice(Path.Combine(_hostingEnvironment.WebRootPath, @"res\cfg.xml"));
            EmsApi        = new EVEStandardAPI("EMS", DataSource.Tranquility, new TimeSpan(0, 5, 0), EmsIniservice.CallbackUrl, EmsIniservice.ClientId, EmsIniservice.SecretKey);
            Model         = EmsApi.SSO.AuthorizeToEVEURI(Emsservice.scopes, "ems");

            return(new RedirectResult(EmsApi.SSO.AuthorizeToEVEURI(Emsservice.scopes, "ems").SignInURI));
        }
コード例 #7
0
ファイル: Startup.cs プロジェクト: aydjay/EVEAsset.Navigator
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            // Add cookie authentication and set the login url
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options => { options.LoginPath = "/Auth/Login"; });

            if (File.Exists(SecretsFileName) == false)
            {
                throw new InvalidOperationException("You need to have a secrets file setup");
            }
            var secrets = JsonConvert.DeserializeObject <Secrets>(File.ReadAllText(SecretsFileName));
            // Register your application at: https://developers.eveonline.com/applications to obtain client ID and secret key and add them to user secrets
            // by right-clicking the solution and selecting Manage User Secrets.
            // Also, modify the callback URL in appsettings.json to match with your environment.

            // Initialize the client
            var esiClient = new EVEStandardAPI(
                "EVEAsset.Navigator",     // User agent
                DataSource.Tranquility,   // Server [Tranquility/Singularity]
                TimeSpan.FromSeconds(30), // Timeout
                Configuration["SSOCallbackUrl"],
                secrets.ClientId,
                secrets.SecretKey);

            // Register with DI container
            services.AddSingleton(esiClient);

            // Session is required
            services.AddSession();

            services.AddMemoryCache();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            var tranquilityContext = new TranquilityContext(new DbContextOptions <TranquilityContext>());

            tranquilityContext.ConfigureServices(services, secrets.SdeConnectionString);

            var navigatorContext = new NavigatorContext(new DbContextOptions <NavigatorContext>());

            navigatorContext.ConfigureServices(services, secrets.NavigatorConnectionString);

            services.AddSingleton(typeof(TranquilityContext), tranquilityContext);
            services.AddSingleton(typeof(NavigatorContext), navigatorContext);
            services.AddSingleton <IUniverseCache, UniverseCache>();
            services.AddSingleton <IStaticDataRepository, StaticDataRepository>();
            services.AddSingleton <IJumpCache, JumpCache>();
        }
コード例 #8
0
ファイル: AuthController.cs プロジェクト: tgardner851/AuraWeb
        public AuthController(ILogger <CharacterController> logger, IConfiguration configuration, EVEStandardAPI esiClient)
        {
            _Log            = logger;
            _Config         = configuration;
            this._ESIClient = esiClient;

            AdminCharacters = new List <string>();
            string adminCharacterIds = _Config["AdminCharacterIds"];

            AdminCharacters = adminCharacterIds.Split(',').ToList();
        }
コード例 #9
0
ファイル: HomeController.cs プロジェクト: PaiChuuLi/EMS
        public async Task <IActionResult> Callback()
        {
            Emsservice = new scopesservice(Path.Combine(_hostingEnvironment.WebRootPath, @"res\emsscopes.ems"));
            Emsservice.GetScopes();
            EmsIniservice = new iniservice(Path.Combine(_hostingEnvironment.WebRootPath, @"res\cfg.xml"));
            EmsApi        = new EVEStandardAPI("EMS", DataSource.Tranquility, new TimeSpan(0, 5, 0), EmsIniservice.CallbackUrl, EmsIniservice.ClientId, EmsIniservice.SecretKey);
            Model         = EmsApi.SSO.AuthorizeToEVEURI(Emsservice.scopes, "ems");

            Model.AuthorizationCode = Request.Query["code"];
            Model.ReturnedState     = Request.Query["state"];
            //Model.ExpectedState= "ems";
            AccessTokenDetails token = await EmsApi.SSO.VerifyAuthorizationAsync(Model);

            ViewData["access_token"]  = token.AccessToken;
            ViewData["expires_in"]    = token.ExpiresIn;
            ViewData["refresh_token"] = token.RefreshToken;
            ViewData["expires"]       = token.Expires;
            CharacterDetails character = await EmsApi.SSO.GetCharacterDetailsAsync(token.AccessToken);

            ViewData["CharacterID"]        = character.CharacterID;
            ViewData["CharacterName"]      = character.CharacterName;
            ViewData["ExpiresOn"]          = character.ExpiresOn;
            ViewData["Scopes"]             = character.Scopes;
            ViewData["TokenType"]          = character.TokenType;
            ViewData["CharacterOwnerHash"] = character.CharacterOwnerHash;

            AuthDTO authDTOems = new AuthDTO
            {
                AccessToken = token,
                Character   = character
            };
            List <CharacterMining> mininglist = new List <CharacterMining>();
            long pages = 0;

            try
            {
                (mininglist, pages) = await EmsApi.Industry.CharacterMiningLedgerV1Async(authDTOems, 1);
            }
            catch (Exception e)
            {
                ViewData["emessage"] = e.Message.ToString();;
                ViewData["error"]    = e.ToString();;
                ViewData["data"]     = e.Data.ToString();
                return(View());
            }
            mininglist.ToArray();
            string image  = "https://imageserver.eveonline.com/Character/" + character.CharacterID + "_512.jpg";
            Uri    imguri = new Uri(image);

            ViewData["image"] = imguri;
            return(View(mininglist));
        }
コード例 #10
0
        public MarketController(ILogger <MarketController> logger, IConfiguration configuration, EVEStandardAPI _ESIClient)
        {
            _Log            = logger;
            _Config         = configuration;
            this._ESIClient = _ESIClient;

            string dbFileName  = _Config["DBFileName"];
            string sdeFileName = _Config["SDEFileName"];
            string sdeTempCompressedFileName = _Config["SDETempCompressedFileName"];
            string sdeTempFileName           = _Config["SDETempFileName"];
            string sdeDownloadUrl            = _Config["SDEDownloadURL"];

            _DBService = new DBService(_Log, dbFileName, sdeFileName, sdeTempCompressedFileName, sdeTempFileName, sdeDownloadUrl);
        }
コード例 #11
0
        public UniverseCache(IServiceProvider services)
        {
            _cache     = services.GetService <IMemoryCache>();
            _api       = (EVEStandardAPI)services.GetService(typeof(EVEStandardAPI));
            _dbContext = (TranquilityContext)services.GetService(typeof(TranquilityContext));

            if (!_cache.TryGetValue(MemoryCacheKeys.UniverseMapping, out List <UniverseIdsToNames> _universeMapping))
            {
                _universeMapping = new List <UniverseIdsToNames>();
                _cache.Set(MemoryCacheKeys.UniverseMapping, _universeMapping, new MemoryCacheEntryOptions
                {
                    Priority = CacheItemPriority.NeverRemove
                });

                //Prepopulate the in memory cache with all the known solar systems
                _universeMapping.AddRange(GetSolarSystems());
            }
        }
コード例 #12
0
ファイル: Startup.cs プロジェクト: tgardner851/AuraWeb
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            // Add cookie authentication and set the login url
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath = "/Auth/Login";
            });

            // Register your application at: https://developers.eveonline.com/applications to obtain client ID and secret key and add them to user secrets
            // by right-clicking the solution and selecting Manage User Secrets.
            // Also, modify the callback URL in appsettings.json to match with your environment.

            // Initialize the client
            var esiClient = new EVEStandardAPI(
                "AuraWeb",                          // User agent
                DataSource.Tranquility,             // Server [Tranquility/Singularity]
                TimeSpan.FromSeconds(30),           // Timeout
                Configuration["SSOCallbackUrl"],
                Configuration["ClientId"],
                Configuration["SecretKey"]);

            // Register with DI container
            services.AddSingleton <EVEStandardAPI>(esiClient);

            services.AddDistributedMemoryCache();

            // Session is required
            services.AddSession();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddSingleton <IConfiguration>(Configuration);

            services.AddHangfire(c => c.UseMemoryStorage());
        }
コード例 #13
0
        public AuthDTO GetAuth(EVEStandardAPI esiClient)
        {
            int characterId = Int32.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            // This only here to force checking of auth
            ESIModelDTO <EVEStandard.Models.CharacterInfo> characterInfo = esiClient.Character.GetCharacterPublicInfoV4Async(characterId).Result;

            var auth = new AuthDTO
            {
                AccessToken = new AccessTokenDetails
                {
                    AccessToken  = User.FindFirstValue("AccessToken"),
                    ExpiresUtc   = DateTime.Parse(User.FindFirstValue("AccessTokenExpiry")),
                    RefreshToken = User.FindFirstValue("RefreshToken")
                },
                CharacterId = characterId,
                Scopes      = User.FindFirstValue("Scopes")
            };

            return(auth);
        }
コード例 #14
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                // This is set to false to allow the SSOState cookie to be persisted in the user's session cookie as\
                // required by the auth security check. If you need to set this value to true you should refer to
                // https://docs.microsoft.com/en-us/aspnet/core/security/gdpr for additiona guidance.
                options.CheckConsentNeeded    = context => false;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            // Add cookie authentication and set the login url
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath = "/Auth/Login";
            });

            // Register your application at: https://developers.eveonline.com/applications to obtain client ID and secret key and add them to user secrets
            // by right-clicking the solution and selecting Manage User Secrets.
            // Also, modify the callback URL in appsettings.json to match with your environment.

            // Initialize the client
            var esiClient = new EVEStandardAPI(
                "EVEStandard",                      // User agent
                DataSource.Tranquility,             // Server [Tranquility/Singularity]
                TimeSpan.FromSeconds(30),           // Timeout
                Configuration["SSOCallbackUrl"],
                Configuration["ClientId"],
                Configuration["SecretKey"]);

            // Register with DI container
            services.AddSingleton <EVEStandardAPI>(esiClient);

            // Session is required
            services.AddSession();

            services.AddControllersWithViews();
        }
コード例 #15
0
 public LoyaltyController(IServiceProvider provider)
 {
     _api = (EVEStandardAPI)provider.GetService(typeof(EVEStandardAPI));
     _tranquilityDbContext = (TranquilityContext)provider.GetService(typeof(TranquilityContext));
 }
コード例 #16
0
 public ESIService(ILogger <ESIService> logger, EVEStandardAPI esiClient)
 {
     _logger        = logger;
     this.esiClient = esiClient;
 }
コード例 #17
0
 public HomeController(EVEStandardAPI api)
 {
     _api = api;
 }
コード例 #18
0
ファイル: Auth.cs プロジェクト: wkpatrick/Mining-Foreman
 public AuthController(EVEStandardAPI esiClient)
 {
     this.esiClient = esiClient;
 }
コード例 #19
0
 public VerificationWindow(EVEStandardAPI client)
 {
     InitializeComponent();
     _client = client;
 }
コード例 #20
0
 public EsiTokenRefreshMiddleware(EVEStandardAPI esiClient, RequestDelegate next)
 {
     _esiClient = esiClient;
     _next      = next;
 }
コード例 #21
0
 public SecureController(EVEStandardAPI esiClient)
 {
     this.esiClient = esiClient;
 }
コード例 #22
0
ファイル: NewsController.cs プロジェクト: tgardner851/AuraWeb
 public NewsController(ILogger <NewsController> logger, IConfiguration configuration, EVEStandardAPI esiClient)
 {
     _Log            = logger;
     _Config         = configuration;
     this._ESIClient = esiClient;
 }