Beispiel #1
0
        public static void AddBceidSoapClient(this IServiceCollection services, IConfiguration config)
        {
            services.AddScoped <BCeIDServiceSoapClient>(provider =>
            {
                var username = config.GetValue <string>("BCEID_USER");
                var password = config.GetValue <string>("BCEID_PASSWORD");
                var url      = config.GetValue <string>("BCEID_URL");
                var osid     = config.GetValue <string>("BCEID_OSID");

                var binding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
                binding.Security.Transport.ProxyCredentialType  = HttpProxyCredentialType.Basic;

                var client = new BCeIDServiceSoapClient(EndpointConfiguration.BCeIDServiceSoap12);
                client.ClientCredentials.UserName.UserName = username;
                client.ClientCredentials.UserName.Password = password;
                client.Endpoint.Binding = binding;
                client.Endpoint.Address = new EndpointAddress(url);
                client.Osid             = osid;

                return(client);
            });

            services.AddScoped <IBceidApi, BceidApi>();
        }
        public static void AddBceidSoapClient(this IServiceCollection services, IConfiguration config)
        {
            services.AddSingleton <BCeIDServiceSoapClient>(provider =>
            {
                var username      = config.GetValue <string>("ServiceAccount:User");
                var password      = config.GetValue <string>("ServiceAccount:Password");
                var url           = config.GetValue <string>("BCEID:Url");
                var osid          = config.GetValue <string>("BCEID:OSID");
                var cacheLifeSpan = config.GetValue <int>("BCEID:CacheLifespan");

                var binding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
                binding.Security.Transport.ProxyCredentialType  = HttpProxyCredentialType.Basic;

                var client = new BCeIDServiceSoapClient(EndpointConfiguration.BCeIDServiceSoap12);
                client.ClientCredentials.UserName.UserName = username;
                client.ClientCredentials.UserName.Password = password;
                client.Endpoint.Binding = binding;
                client.Endpoint.Address = new EndpointAddress(url);
                client.Osid             = osid;
                client.CacheLifespan    = cacheLifeSpan == 0 ? 60 : cacheLifeSpan; //60 minutes default

                return(client);
            });

            services.AddSingleton <IBceidApi, BceidApi>();
        }
Beispiel #3
0
        public void ConfigureServices(ConfigurationServices configurationServices)
        {
            var services      = configurationServices.Services;
            var configuration = configurationServices.Configuration;

            services.Configure <BCeIDWebServiceOptions>(configuration.GetSection("bceidWebService"));
            services.AddTransient <IBCeIDServiceSecurityContextProvider, BCeIDServiceSecurityContextProvider>();
            services.AddScoped <BCeIDServiceSoap>(sp =>
            {
                var options = sp.GetRequiredService <IOptions <BCeIDWebServiceOptions> >().Value;
                var client  = new BCeIDServiceSoapClient(new BasicHttpBinding()
                {
                    Security = new BasicHttpSecurity
                    {
                        Transport = new HttpTransportSecurity {
                            ClientCredentialType = HttpClientCredentialType.Basic
                        },
                        Mode = BasicHttpSecurityMode.Transport
                    }
                },
                                                         new EndpointAddress(options.Url));

                client.ClientCredentials.UserName.UserName = options.ServiceAccountUser;
                client.ClientCredentials.UserName.Password = options.ServiceAccountPassword;

                return(client);
            });
            services.AddTransient <ITeamRepository, TeamRepository>();
            services.AddTransient <IUserRepository, UserRepository>();
        }
Beispiel #4
0
 public BceidApi(BCeIDServiceSoapClient client)
 {
     _client         = client;
     _accountCache   = new Dictionary <string, BceidAccount>();
     _timer          = new System.Timers.Timer();
     _timer.Elapsed += new ElapsedEventHandler(RefreshCache);
     _timer.Interval = TimeSpan.FromMinutes(_client.CacheLifespan).TotalMilliseconds;
     _timer.Enabled  = true;
 }
Beispiel #5
0
        public async Task <BCeIDBusiness> ProcessBusinessQuery(string guid)
        {
            if (String.IsNullOrEmpty(url))
            {
                return(null);
            }

            // create the SOAP client
            //var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            BasicHttpsBinding binding = new BasicHttpsBinding {
                MaxReceivedMessageSize = int.MaxValue
            };

            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            binding.CloseTimeout = new TimeSpan(0, 10, 0);
            EndpointAddress address = new EndpointAddress(url);
            var             client  = new BCeIDServiceSoapClient(binding, address);

            client.ClientCredentials.UserName.UserName = user;
            client.ClientCredentials.UserName.Password = password;

            var n_guid = NormalizeGuid(guid);

            // SOAP request and parameters
            var myparams = new AccountDetailRequest();

            myparams.onlineServiceId          = svcid;
            myparams.requesterUserGuid        = n_guid;
            myparams.requesterAccountTypeCode = BCeIDAccountTypeCode.Business;
            myparams.userGuid        = n_guid;
            myparams.accountTypeCode = BCeIDAccountTypeCode.Business;

            try
            {
                var response = await client.getAccountDetailAsync(myparams);

                if (response.code == ResponseCode.Success)
                {
                    var          business = new BCeIDBusiness();
                    BCeIDAccount account  = response.account;

                    business.contactEmail = account.contact.email.value;
                    business.contactPhone = account.contact.telephone.value;

                    business.individualFirstname       = account.individualIdentity.name.firstname.value;
                    business.individualMiddlename      = account.individualIdentity.name.middleName.value;
                    business.individualOtherMiddlename = account.individualIdentity.name.otherMiddleName.value;
                    business.individualSurname         = account.individualIdentity.name.surname.value;

                    business.businessTypeName        = account.business.type.name;
                    business.businessTypeDescription = account.business.type.description;
                    business.businessTypeCode        = account.business.type.code.ToString();
                    business.businessTypeOther       = account.business.businessTypeOther.value;
                    business.legalName                   = account.business.legalName.value;
                    business.businessNumber              = account.business.businessNumber.value;
                    business.incorporationNumber         = account.business.incorporationNumber.value;
                    business.jurisdictionOfIncorporation = account.business.jurisdictionOfIncorporation.value;
                    business.addressLine1                = account.business.address.addressLine1.value;
                    business.addressLine2                = account.business.address.addressLine2.value;
                    business.addressCity                 = account.business.address.city.value;
                    business.addressProv                 = account.business.address.province.value;
                    business.addressPostal               = account.business.address.postal.value;
                    business.addressCountry              = account.business.address.country.value;
                    business.userId = account.userId.value;

                    return(business);
                }
            }
            catch (Exception)
            {
                // ignore errors and just return null
            }

            return(null);
        }
Beispiel #6
0
 public BceidApi(BCeIDServiceSoapClient client)
 {
     _client = client;
 }