コード例 #1
0
 public UserBusiness(IUserRepository repository, SignInConfiguration signInConfiguration, TokenConfiguration tokenConfiguration)
 {
     _repository          = repository;
     _signInConfiguration = signInConfiguration;
     _tokenConfiguration  = tokenConfiguration;
     _converter           = new UserConverter();
 }
コード例 #2
0
        private void InitializeConList()
        {
            try
            {
                _Client = LyncClient.GetClient();
                SignInConfiguration sc = _Client.SignInConfiguration;
                if (sc != null)
                {
                    CurrentUserName = sc.UserName.ToString();
                }
                CurrentUserName  = _Client.Uri.ToString().Replace("sip:", "");
                _ConversationMgr = _Client.ConversationManager;
                _ConversationMgr.ConversationAdded   += ConversationAdd;
                _ConversationMgr.ConversationRemoved += ConversationRemoved;
                conbox1.Items.Add("Pls Select A Item");
                dtConv = new DataTable();
                dtConv.Columns.Add("DisplayName", typeof(string));
                dtConv.Columns.Add("Id", typeof(string));
                foreach (Microsoft.Lync.Model.Conversation.Conversation c in _ConversationMgr.Conversations)
                {
                    string DisplayName = "";

                    foreach (Participant p in c.Participants)
                    {
                        if (!p.IsSelf)
                        {
                            DisplayName += ", " + p.Properties[ParticipantProperty.Name].ToString();
                            // conbox1.Items.Add(p.Properties[ParticipantProperty.Name].ToString());
                        }
                    }
                    if (DisplayName.Length > 3)
                    {
                        DisplayName = DisplayName.Substring(2);
                    }
                    else
                    {
                        DisplayName = "My Self";
                    }

                    dtConv.Rows.Add(DisplayName, c.Properties[ConversationProperty.Id].ToString());

                    //conbox1.Items.Add(c.Properties[ConversationProperty.Id].ToString());
                }
                conbox1.DataSource    = dtConv;
                conbox1.DisplayMember = "DisplayName";
                conbox1.ValueMember   = "Id";
                needUpdated           = true;
                //datagv1.DataBindings();
                datagv1.DataSource = bindingSource1;
                //conbox1.Update();
            }catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
コード例 #3
0
        protected override void InternalProcessRecord()
        {
            SPWebApplication webApp = m_webAppPipeBind.Read();

            SignInConfiguration sc = webApp.GetChild<SignInConfiguration>("SignInConfig");

            if (sc == null)
            {
                sc = new SignInConfiguration("SignInConfig", webApp);
            }

            sc.Update();

            base.WriteObject(sc);
        }
コード例 #4
0
        private void AddAuthetication(IServiceCollection services)
        {
            var signingConfigurations = new SignInConfiguration();

            services.AddSingleton(signingConfigurations);

            var tokenConfigurations = new TokenConfiguration();

            new ConfigureFromConfigurationOptions <TokenConfiguration>(
                Configuration.GetSection("TokenConfigurations")
                )
            .Configure(tokenConfigurations);

            services.AddSingleton(tokenConfigurations);


            services.AddAuthentication(authOptions =>
            {
                authOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                authOptions.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(bearerOptions =>
            {
                var paramsValidation = bearerOptions.TokenValidationParameters;
                paramsValidation.IssuerSigningKey = signingConfigurations.Key;
                paramsValidation.ValidAudience    = tokenConfigurations.Audience;
                paramsValidation.ValidIssuer      = tokenConfigurations.Issuer;

                // Validates the signing of a received token
                paramsValidation.ValidateIssuerSigningKey = true;

                // Checks if a received token is still valid
                paramsValidation.ValidateLifetime = true;

                // Tolerance time for the expiration of a token (used in case
                // of time synchronization problems between different
                // computers involved in the communication process)
                paramsValidation.ClockSkew = TimeSpan.Zero;
            });

            // Enables the use of the token as a means of
            // authorizing access to this project's resources
            services.AddAuthorization(auth =>
            {
                auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()
                               .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme‌​)
                               .RequireAuthenticatedUser().Build());
            });
        }
コード例 #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var connectionString = _configuration["MySqlConnection:MySqlConnectionString"];

            services.AddDbContext <MySQLContext>(options => options.UseMySql(connectionString));

            if (_environment.IsDevelopment())
            {
                try
                {
                    var evolveConnection = new MySql.Data.MySqlClient.MySqlConnection(connectionString);
                    var evolve           = new Evolve.Evolve(evolveConnection, msg => _logger.LogInformation(msg))
                    {
                        Locations       = new[] { "db/migrations" },
                        IsEraseDisabled = true
                    };

                    evolve.Migrate();
                }
                catch (System.Exception ex)
                {
                    _logger.LogCritical("Database migration error", ex);
                    throw;
                }
            }

            var signingConfiguration = new SignInConfiguration();

            services.AddSingleton(signingConfiguration);

            var tokenConfiguration = new TokenConfiguration();

            new ConfigureFromConfigurationOptions <TokenConfiguration>(_configuration.GetSection("TokenConfiguration"))
            .Configure(tokenConfiguration);
            services.AddSingleton(tokenConfiguration);

            services.AddAuthentication(authOptions =>
            {
                authOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                authOptions.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(bearerOptions =>
            {
                var paramValidation = bearerOptions.TokenValidationParameters;
                paramValidation.IssuerSigningKey = signingConfiguration.Key;
                paramValidation.ValidAudience    = tokenConfiguration.Audience;
                paramValidation.ValidIssuer      = tokenConfiguration.Issuer;

                paramValidation.ValidateIssuerSigningKey = true;
                paramValidation.ValidateLifetime         = true;
                paramValidation.ClockSkew = TimeSpan.Zero;
            });

            services.AddAuthorization(auth =>
            {
                auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()
                               .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
                               .RequireAuthenticatedUser().Build()
                               );
            });


            services.AddMvc(options =>
            {
                options.RespectBrowserAcceptHeader = true;
                options.FormatterMappings.SetMediaTypeMappingForFormat("xml", MediaTypeHeaderValue.Parse("text/xml"));
                options.FormatterMappings.SetMediaTypeMappingForFormat("json", MediaTypeHeaderValue.Parse("application/json"));
                options.EnableEndpointRouting = false;
            })
            .AddXmlSerializerFormatters()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddApiVersioning();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "RESTful API with ASP.NET Core", Version = "v1"
                });
            });

            var filterOptions = new HyperMediaFilterOptions();

            filterOptions.ObjectContentResponseEnricherList.Add(new PersonEnricher());
            services.AddSingleton(filterOptions);

            // Dependencies
            services.AddScoped <IPersonBusiness, PersonBusinessImpl>();
            services.AddScoped <IBookBusiness, BookBusinessImpl>();
            services.AddScoped <ILoginBusiness, LoginBusinessImpl>();
            services.AddScoped <IFileBusiness, FileBusinessImpl>();

            services.AddScoped(typeof(IRepository <>), typeof(Repository <>));
            services.AddScoped <IUserRepository, UserRepositoryImpl>();
            services.AddScoped <IPersonRepository, PersonRepositoryImpl>();
        }
コード例 #6
0
 public LoginBusinessImpl(IUserRepository repository, SignInConfiguration signIn, TokenConfiguration token)
 {
     _respository = repository;
     _signin      = signIn;
     _token       = token;
 }