Exemple #1
0
 /// <summary>
 /// Refreshindicator this instance.
 /// </summary>
 void Refreshindicator(int cod, string producto)
 {
     if (cn.ToString().Contains("HomeAgregaProductoActivity"))
     {
         ActivityContexts.homeAddActivity.UpdateBox(cod, producto);
     }
 }
 /// <summary>
 /// Refreshindicator this instance.
 /// </summary>
 void Refreshindicator()
 {
     if (cn.ToString().Contains("HomeAgregaProductoActivity"))
     {
         ActivityContexts.homeAddActivity.CheckStatusAsync();
     }
 }
Exemple #3
0
 /// <summary>
 /// Refreshindicator this instance.
 /// </summary>
 void Refreshindicator()
 {
     if (cn.ToString().Contains("HomeAgregaProductoActivity"))
     {
         ActivityContexts.homeAddActivity.alertNotificacionRevisarProducto();
     }
 }
Exemple #4
0
 /// <summary> Returns -- Doozy/Engine/Resources/Data/{componentName}/ </summary>
 /// <param name="componentName"></param>
 public static string GetDataPath(ComponentName componentName)
 {
     return(Path.Combine(ENGINE_RESOURCES_DATA_PATH, componentName.ToString()));
 }
 public void convert_component_name_to_string_short_form()
 {
     byte[] key = { 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF };
     ComponentName name = new ComponentName("A", new Version(1, 0, 0, 0), key, null, CultureInfo.GetCultureInfo("en-US"), ProcessorArchitecture.Amd64);
     Assert.That(name.ToString("s"), Is.EqualTo("A=1.0.0.0-20406080a0c0e0ff-en-US-amd64"));
 }
Exemple #6
0
        private void AddJwtAuth(IServiceCollection services)
        {
            services
            .AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme,
                          options =>
            {
                options.RequireHttpsMetadata = true;

                var environment = this.Configuration.GetValue <string>("Environment");
                var client      = this.Configuration.GetValue <string>("Customer");

                this._logger.LogInformation(
                    $"Retrieved configuration (Environment: '{environment}', Customer: '{client}').");

                var clientIssuer           = new ComponentName(environment, client, ScopeType.ClientService);
                var serialisedClientIssuer = clientIssuer.ToString();

                var validIssuers   = new[] { serialisedClientIssuer };
                var validAudiences = new[] { serialisedClientIssuer };

                this._logger.LogInformation(
                    $"JWT configuration (ValidIssuers: '{string.Join(";", validIssuers)}', ValidAudiences: '{string.Join(";", validAudiences)}').");

                var issuerSigningKeys = new List <SecurityKey>();
                var secretKey         = this.Configuration.GetValue <string>("Secret-Key-Jwt");

                if (!string.IsNullOrEmpty(secretKey))
                {
                    issuerSigningKeys.Add(new SymmetricSecurityKey(Encoding.ASCII.GetBytes(secretKey)));
                }
                else
                {
                    this._logger.LogError("No secret key found for JWT");
                    throw new JwtMissingSecurityException();
                }

                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ClockSkew                = TimeSpan.FromMinutes(1),
                    RequireExpirationTime    = true,
                    ValidateLifetime         = true,
                    ValidateIssuer           = true,
                    ValidIssuers             = validIssuers,
                    ValidateAudience         = true,
                    ValidAudiences           = validAudiences,
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKeys        = issuerSigningKeys
                };

                options.Events = new JwtBearerEvents
                {
                    OnAuthenticationFailed = context =>
                    {
                        this._logger.LogWarning(context.Exception, $"Authentication Failed for Identity: {context.Principal?.Identity?.Name}");

                        context.Response.StatusCode = 401;
                        context.Fail("Invalid JWT token");

                        return(Task.CompletedTask);
                    },
                    OnMessageReceived = context =>
                    {
                        this._logger.LogDebug($"Authentication Message Received for Identity: {context.Principal?.Identity?.Name}");
                        return(Task.CompletedTask);
                    },
                    OnTokenValidated = context =>
                    {
                        this._logger.LogDebug($"Authentication Token Validated for Identity: {context.Principal?.Identity?.Name}");
                        return(Task.CompletedTask);
                    }
                };
            });
        }