private sonesGraphDB(Uri myServiceAddress, String myUsername, String myPassword)
        {
            BasicHttpBinding BasicBinding = new BasicHttpBinding();
            BasicBinding.Name = "sonesBasic";
            BasicBinding.MessageEncoding = WSMessageEncoding.Text;
            BasicBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;

            ServiceToken = new ServiceToken();

            try
            {
                var Request = HttpWebRequest.Create(myServiceAddress.ToString());
                var Response = Request.GetResponse();
            }
            catch (Exception ex)
            {
                throw new Exception("The GraphDB remote service is unreachable! Maybe the service was not started.", ex);
            }

            try
            {

                ServiceToken.GraphDSService = ChannelFactory<GraphDS>.CreateChannel(BasicBinding, new EndpointAddress(myServiceAddress));
                ServiceToken.VertexTypeService = ChannelFactory<VertexTypeService>.CreateChannel(BasicBinding, new EndpointAddress(myServiceAddress));
                ServiceToken.VertexInstanceService = ChannelFactory<VertexInstanceService>.CreateChannel(BasicBinding, new EndpointAddress(myServiceAddress));
                ServiceToken.EdgeTypeService = ChannelFactory<EdgeTypeService>.CreateChannel(BasicBinding, new EndpointAddress(myServiceAddress));
                ServiceToken.EdgeInstanceService = ChannelFactory<EdgeInstanceService>.CreateChannel(BasicBinding, new EndpointAddress(myServiceAddress));

            }
            catch (Exception ex)
            {
                throw new Exception("The GraphDB is reachably but there occured an error, creating the native services!", ex);
            }
        }
        private BrowserBasedSecurityContext(string ecsServiceAddress, string applicationName, string partnerName)
        {
            _traceSource.TraceInformation("\nInitialized PartnerClientSecurityToken for partner: ", partnerName);

            _serviceToken = new BrowserBasedServiceToken(ecsServiceAddress, applicationName, partnerName);

        }
 public void SecurityContext_WithECSAddress_GetsTokenAndAuditInfo(string partnerName, string authenticationEndpoint)
 {
     var ecsAddress = "http://devtitan.FCSAmerica.com/EnterpriseConfigurationStore/v1/RESTServices/api/ConfigItems";
     var serviceToken = new ServiceToken(ecsAddress, "McGruff", partnerName);
     var configItems = serviceToken.ConfigItems;
     Assert.IsNotNull(configItems);
     
     Assert.AreEqual(authenticationEndpoint,configItems["v2.AuthenticationEndpoint"]);
 }
        public void SecurityContext_WithECSAddress_GetsTokenAndAuditInfo(string partnerName, string authenticationEndpoint)
        {
            var ecsAddress   = "http://devtitan.FCSAmerica.com/EnterpriseConfigurationStore/v1/RESTServices/api/ConfigItems";
            var serviceToken = new ServiceToken(ecsAddress, "McGruff", partnerName);
            var configItems  = serviceToken.ConfigItems;

            Assert.IsNotNull(configItems);

            Assert.AreEqual(authenticationEndpoint, configItems["v2.AuthenticationEndpoint"]);
        }
Пример #5
0
 /// <summary>
 /// 实例化微信支付服务。
 /// </summary>
 /// <param name="serviceToken">微信服务令牌。</param>
 /// <param name="appId">公众号Id。</param>
 /// <param name="appKey">公众号密钥。</param>
 /// <param name="shopId">商户号。</param>
 /// <param name="shopKey">商户密钥。</param>
 /// <param name="cert">客户端证书。</param>
 public PaymentService(ServiceToken serviceToken, string appId, string appKey, string shopId, string shopKey, X509Certificate2 cert)
     : this(serviceToken, appId, appKey, shopId, shopKey)
 {
     if (cert == null)
     {
         throw new ArgumentNullException("cert");
     }
     Certificate          = cert;
     IsCertificateEnabled = true;
 }
Пример #6
0
        private bool IsValidHeader(ServiceToken header)
        {
            var result = false;

            if (header.Token == ServiceToken)
            {
                result = true;
            }
            return(result);
        }
Пример #7
0
        protected AbstractToken<object> sendRequest(string verb, string protocol, string host, string port, string path)
        {
            var serviceToken = new ServiceToken<object>();

            xmlHttpRequest.open(verb, createUri(protocol, host, port, path), true );
            xmlHttpRequest.onreadystatechange += serviceToken.onReadyStateChange;

            xmlHttpRequest.send("");

            return serviceToken;
        }
Пример #8
0
        protected ServiceToken GetServiceToken(string serviceName)
        {
            // TODO: Service Name should be an enum but it's weird having Service Names in Infrastructure. Need to revisit.
            ServiceToken serviceToken = UserManager.GetServiceToken(serviceName);

            if (serviceToken == null)
            {
                throw new UnauthorizedAPIException();
            }
            return(serviceToken);
        }
Пример #9
0
 /// <summary>
 /// 实例化微信支付服务。
 /// </summary>
 /// <param name="serviceToken">微信服务令牌。</param>
 /// <param name="appId">公众号Id。</param>
 /// <param name="appKey">公众号密钥。</param>
 /// <param name="shopId">商户号。</param>
 /// <param name="shopKey">商户密钥。</param>
 public PaymentService(ServiceToken serviceToken, string appId, string appKey, string shopId, string shopKey)
     : base(serviceToken, appId, appKey)
 {
     if (shopId == null)
     {
         throw new ArgumentNullException("shopId");
     }
     if (shopKey == null)
     {
         throw new ArgumentNullException("shopKey");
     }
     ShopId  = shopId;
     ShopKey = shopKey;
 }
Пример #10
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ServiceToken = await _context.ServiceToken.FirstOrDefaultAsync(m => m.ID == id);

            if (ServiceToken == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #11
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ServiceToken = await _context.ServiceToken.FindAsync(id);

            if (ServiceToken != null)
            {
                _context.ServiceToken.Remove(ServiceToken);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Пример #12
0
        public ServiceToken GetServiceToken(string serviceName)
        {
            IAuthorizationManager authorizationManager = new ERMSAuthorizationManager();

            // Initialize or Validate Token. If expired, refresh.
            IdentityContainer identityContainer = IdentityContainer;
            UserIdentity      user         = identityContainer.UserIdentity;
            ServiceToken      serviceToken = identityContainer.GetToken(serviceName);

            if (string.Equals(serviceName, "ERMS") && !authorizationManager.ValidateToken(serviceToken?.AuthenticationToken, user.EnvironmentName))
            {
                serviceToken = authorizationManager.GetServiceToken(user.UserName, user.DomainName, user.EnvironmentName, user.ApplicationName);
                identityContainer.SetToken(serviceName, serviceToken);
                UpdateIdentityContainer(identityContainer);
            }

            return(serviceToken);
        }
Пример #13
0
        public async Task <ActionResult <dynamic> > Login(Usuario usuario)
        {
            var usuarioBanco = await _context.Usuarios.Where(s => s.Login == usuario.Login &&
                                                             s.Senha == usuario.Senha).FirstOrDefaultAsync();

            if (usuarioBanco == null)
            {
                return(NotFound(new { message = "Deu erro aí fera. Usuário ou senha inválidos." }));
            }

            var token = ServiceToken.GerarToken(usuarioBanco);

            usuarioBanco.Senha = "";
            return(new
            {
                Usuario = usuarioBanco,
                token = token
            });
        }
        public static void UnbindFromService(ServiceToken token)
        {
            if (token is null)
            {
                return;
            }

            var wrapper = token.Wrapper;
            var conn    = _connectionMap[wrapper];

            if (conn is null)
            {
                return;
            }
            _connectionMap.Remove(wrapper);
            wrapper.UnbindService(conn);
            if (_connectionMap.Count == 0)
            {
                Service = null;
            }
        }
Пример #15
0
        private void SignInToService()
        {
            if (serviceToken == null)
            {
                string      userName = ConfigurationManager.AppSettings.Get("ApiUsername");
                string      password = ConfigurationManager.AppSettings.Get("ApiPassword");
                RestRequest request  = new RestRequest("token");
                request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
                request.AddParameter("grant_type", "password");
                request.AddParameter("username", userName);
                request.AddParameter("password", password);

                var responce = restClient.Post <ServiceToken>(request);

                if (!responce.IsSuccessful)
                {
                    Debug.WriteLine($"Unable to aquire bearer token for user {userName}");
                }

                serviceToken = responce.Data;
            }
        }
 protected EdgeTypeStore(ServiceToken myServiceToken)
 {
     ServiceToken = myServiceToken;
 }
 protected VertexTypeCreator(ServiceToken myServiceToken)
 {
     ServiceToken = myServiceToken;
 }
 protected EdgeTypeCreator(ServiceToken myServiceToken)
 {
     ServiceToken = myServiceToken;
 }
Пример #19
0
 /// <summary>
 /// 实例化公众服务。
 /// </summary>
 /// <param name="serviceToken">服务令牌。</param>
 /// <param name="appId">公众号Id。</param>
 /// <param name="appKey">公众号密钥。</param>
 public PublicService(ServiceToken serviceToken, string appId, string appKey)
     : base(serviceToken, appId, appKey)
 {
     MessageManager = new MessageManager();
 }
Пример #20
0
 /// <summary>
 /// 实例化公众服务。
 /// </summary>
 /// <param name="serviceToken">服务令牌。</param>
 /// <param name="appId">公众号Id。</param>
 /// <param name="appKey">公众号密钥。</param>
 /// <param name="appToken">消息令牌。</param>
 /// <param name="appAESKey">消息AES密钥。</param>
 public PublicService(ServiceToken serviceToken, string appId, string appKey, string appToken, string appAESKey)
     : this(serviceToken, appId, appKey)
 {
     AppToken  = appToken;
     AppAESKey = appAESKey;
 }
 private BrowserBasedSecurityContext(string ecsServiceAddress, string applicationName, string partnerName, ITokenCache tokenCache)
 {
     _traceSource.TraceInformation("\nInitialized PartnerClientSecurityToken for partner: ", partnerName);
     _serviceToken = new BrowserBasedServiceToken(ecsServiceAddress, applicationName, partnerName, tokenCache);
 }
Пример #22
0
 /// <summary>
 /// 实例化微信支付服务。
 /// </summary>
 /// <param name="serviceToken">微信服务令牌。</param>
 /// <param name="appId">公众号Id。</param>
 /// <param name="appKey">公众号密钥。</param>
 /// <param name="shopId">商户号。</param>
 /// <param name="shopKey">商户密钥。</param>
 /// <param name="certPath">客户端证书路径。</param>
 /// <param name="certPassword">客户端证书密码。</param>
 public PaymentService(ServiceToken serviceToken, string appId, string appKey, string shopId, string shopKey, string certPath, string certPassword)
     : this(serviceToken, appId, appKey, shopId, shopKey, new X509Certificate2(certPath, certPassword))
 {
 }
 protected VertexTypeStore(ServiceToken myServiceToken)
 {
     ServiceToken = myServiceToken;
 }