public override void Bind(Google.ProtocolBuffers.IRpcController controller, BindRequest request, Action <BindResponse> done) { var requestedServiceIDs = new List <uint>(); foreach (var serviceHash in request.ImportedServiceHashList) { var serviceID = Service.GetByHash(serviceHash); Logger.Trace("Bind() [export] Hash: 0x{0} ID: 0x{1} Service: {2} ", serviceHash.ToString("X8"), serviceID.ToString("X2"), Service.GetByID(serviceID) != null ? Service.GetByID(serviceID).GetType().Name : "N/A"); requestedServiceIDs.Add(serviceID); } // read services supplied by client.. foreach (var service in request.ExportedServiceList.Where(service => !Client.Services.ContainsValue(service.Id))) { if (Client.Services.ContainsKey(service.Hash)) { continue; } Client.Services.Add(service.Hash, service.Id); Logger.Trace(string.Format("Bind() [import] Hash: 0x{0} ID: 0x{1}", service.Hash.ToString("X8"), service.Id.ToString("X2"))); } var builder = BindResponse.CreateBuilder(); foreach (var serviceId in requestedServiceIDs) { builder.AddImportedServiceId(serviceId); } done(builder.Build()); }
protected override void beforeEach() { var repo = new MockRepository(); _bindings = new List <ITemplate>(); _bindings.AddRange(Enumerable.Range(1, 5).Select(x => repo.DynamicMock <ITemplate>())); _logger = MockFor <ISparkLogger>(); _sharedTemplateLocator = MockFor <ISharedTemplateLocator>(); _template = MockFor <ITemplate>(); _template.Stub(x => x.Descriptor).PropertyBehavior(); _template.Stub(x => x.FilePath).Return("Fubu.spark"); _template.Stub(x => x.RootPath).Return("/App/Views"); _template.Stub(x => x.Origin).Return("Host"); _template.Descriptor = new ViewDescriptor(_template); ClassUnderTest.BindingsName = "bindings"; _request = new BindRequest { TemplateRegistry = new TemplateRegistry(new[] { _template }.Union(_bindings)), Target = _template, ViewModelType = typeof(ProductModel).FullName, Logger = _logger, }; _sharedTemplateLocator .Expect(x => x.LocateBindings(ClassUnderTest.BindingsName, _template, _request.TemplateRegistry)) .Return(_bindings); _logger .Expect(x => x.Log(Arg.Is(_template), Arg <string> .Is.Anything, Arg <string> .Is.Anything)) .Repeat.Times(_bindings.Count); }
/// <summary> /// Attempts a login with the given credentials /// </summary> /// <param name="domainUser">The domain qualified user</param> /// <param name="credentials">The associated credentials</param> /// <param name="token"></param> /// <returns>True if the login was successful</returns> public async Task <bool> TryBindAsync(string domainUser, string credentials, CancellationToken token) { var op = new BindRequest { Name = domainUser, Authentication = new SimpleAuthentication { Credentials = credentials } }; foreach (var msg in await _connection.TryQueueOperation(op, token)) { var res = msg as BindResponse; if (res != null && res.ResultCode == 0) { _state = LDAPSessionState.Bound; var dn = res.MatchedDN; _current = new LDAPObject { DistinguishedName = dn, Domain = string.Join(",", dn.Split(',') .Where(s => s.StartsWith("dc=", true, CultureInfo.InvariantCulture)).ToArray()) }; return(true); } } return(false); }
public static void OnBindRequest(Client pClient, Header pHeader, MemoryStream pData) { BindRequest bindRequest = new BindRequest(); if (!bindRequest.Read(pData)) { return; } BindResponse bindResponse = new BindResponse(); foreach (uint hash in bindRequest.ImportedServiceHashes) { uint serviceId = 0; if (Program.GetClientServiceId(hash, out serviceId) && !pClient.ImportedServices.Contains(serviceId)) { if (pClient.PermittedServices.Contains(serviceId)) { pClient.Log(ELogLevel.Debug, "Importing Service {0}", serviceId); pClient.ImportedServices.Add(serviceId); bindResponse.ImportedServiceIds.Add(serviceId); } else { pClient.RequestedServices.Add(new Tuple <uint, uint>(serviceId, pHeader.Token)); } } } if (bindResponse.HasImportedServiceIds) { MemoryStream response = new MemoryStream(128); bindResponse.Write(response); pClient.SendResponse(pHeader.Token, 0, 0, null, response); } }
private BindRequest CreateBindRequest(List <ServiceDescriptor> imports, List <ServiceDescriptor> exports) { BindRequest bindRequest = new BindRequest(); foreach (ServiceDescriptor serviceDescriptor in imports) { bindRequest.AddImportedServiceHash(serviceDescriptor.Hash); } uint num = 0u; foreach (ServiceDescriptor serviceDescriptor2 in exports) { num = (serviceDescriptor2.Id = num + 1u); BoundService boundService = new BoundService(); boundService.SetId(serviceDescriptor2.Id); boundService.SetHash(serviceDescriptor2.Hash); bindRequest.AddExportedService(boundService); this.m_rpcConnection.serviceHelper.AddExportedService(serviceDescriptor2.Id, serviceDescriptor2); this.m_logSource.LogDebug("Exporting service id={0} name={1}", new object[] { serviceDescriptor2.Id, serviceDescriptor2.Name }); } return(bindRequest); }
public override void Bind(Google.ProtocolBuffers.IRpcController controller, BindRequest request, Action<BindResponse> done) { var requestedServiceIDs = new List<uint>(); foreach (var serviceHash in request.ImportedServiceHashList) { var serviceID = Service.GetByHash(serviceHash); Logger.Trace("Bind() {0} [export] Hash: 0x{1} Id: 0x{2} Service: {3} ", this.Client, serviceHash.ToString("X8"), serviceID.ToString("X2"), Service.GetByID(serviceID) != null ? Service.GetByID(serviceID).GetType().Name : "N/A"); requestedServiceIDs.Add(serviceID); } // read services supplied by client.. foreach (var service in request.ExportedServiceList.Where(service => !Client.Services.ContainsValue(service.Id))) { if (Client.Services.ContainsKey(service.Hash)) continue; Client.Services.Add(service.Hash, service.Id); Logger.Trace(string.Format("Bind() {0} [import] Hash: 0x{1} Id: 0x{2}", this.Client, service.Hash.ToString("X8"), service.Id.ToString("X2"))); } var builder = BindResponse.CreateBuilder(); foreach (var serviceId in requestedServiceIDs) builder.AddImportedServiceId(serviceId); done(builder.Build()); }
public void does_not_bind_files_other_than_spark() { var request = new BindRequest { Target = new Template("_partial.html", "", "testing") }; ClassUnderTest.CanBind(request).ShouldBeFalse(); }
public void if_template_is_valid_for_binding_then_binder_can_be_applied() { var request = new BindRequest { Target = new Template("Fubu.spark", "", "testing"), }; ClassUnderTest.CanBind(request).ShouldBeTrue(); }
public void bind_partials() { var request = new BindRequest <IRazorTemplate> { Target = new Template("_partial.cshtml", "", "testing") }; ClassUnderTest.CanBind(request).ShouldBeTrue(); }
public void does_not_bind_partials() { var request = new BindRequest { Target = new Template("_partial.spark", "", "testing") }; ClassUnderTest.CanBind(request).ShouldBeFalse(); }
public void assign_descriptor_as_an_instance_of_viewdescriptor() { var request = new BindRequest { Target = new Template("Fubu.spark", "", "testing"), }; ClassUnderTest.Bind(request); request.Target.Descriptor.ShouldBeOfType <ViewDescriptor>(); }
public void does_not_bind_if_descriptor_is_already_set() { var request = new BindRequest <IRazorTemplate> { Target = new Template("Fubu.cshtml", "", "testing") }; request.Target.Descriptor = new ViewDescriptor <IRazorTemplate>(request.Target); ClassUnderTest.CanBind(request).ShouldBeFalse(); }
protected override void beforeEach() { Services.Inject <ISharedTemplateLocator>(new SharedTemplateLocator()); _request = new BindRequest { TemplateRegistry = _templateRegistry = createTemplates(), Master = "application", Logger = MockFor <ISparkLogger>(), ViewModelType = typeof(ProductModel).FullName }; }
public void OnBindAccount(string account, string password, ServerCallbackDelegate callback) { BindRequest bind = new BindRequest(); bind.account = _account; bind.password = _password; bind.newAccount = account; bind.newPassword = password; SendCommand(bind, callback); }
protected override void OnDragEnd(BindRequest request) { // 드래그로 대상과 연결됨 if (request.Target != null) { return; } Storyboard storyboard = parentLayer.Storyboard; storyboard.OpenComponentBox(this.Renderer.Model); }
internal BindRequest CreatePdu() { BindRequest req = CreateBindBdu(); req.AddressNpi = vAddressNpi; req.AddressTon = vAddressTon; req.SystemID = vSystemID; req.Password = vPassword; req.SystemType = vSystemType; req.InterfaceVersion = vInterfaceVersion == InterfaceVersion.v33 ? (byte)0x33 : (byte)0x34; return(req); }
/// <summary> /// Adds a binding from the cluster to the destination <see cref="ZigBeeEndpoint">. /// /// <param name="address">the destination <see cref="IeeeAddress"></param> /// <param name="endpointId">the destination endpoint ID</param> /// <returns>command Task</returns> /// </summary> public Task <CommandResult> Bind(IeeeAddress address, ushort networkAddress, byte endpointId) { BindRequest command = new BindRequest(); command.SrcAddress = _zigbeeEndpoint.GetIeeeAddress(); command.SrcEndpoint = _zigbeeEndpoint.EndpointId; command.BindCluster = _clusterId; command.DstAddrMode = 3; // 64 bit addressing command.DstAddress = address; command.DestinationAddress = new ZigBeeEndpointAddress(networkAddress, endpointId); command.DstEndpoint = endpointId; return(_zigbeeEndpoint.SendTransaction(command, new BindRequest())); }
/// <summary> /// Creates a sicily package discovery BindRequest packet. /// </summary> /// <param name="context">The user context which contains message ID.</param> /// <returns>The sicily package discovery BindRequest.</returns> internal override AdtsBindRequestPacket CreateSicilyPackageDiscoveryBindRequest(AdtsLdapContext context) { BindRequest_authentication authentication = new BindRequest_authentication(); authentication.SetData(BindRequest_authentication.sicilyPackageDiscovery, new Asn1OctetString(new byte[0])); BindRequest bindRequest = new BindRequest( new Asn1Integer((long)version), new LDAPDN(string.Empty), // For Sicily package discovery, DN is not required. authentication); return(CreateBindRequestPacket(context, bindRequest)); }
public override async Task <bool> OnAuthenticationRequest(ClientContext context, IAuthenticationEvent authenticationEvent) { BindRequest bindRequest = new BindRequest { UserIdentity = ExtractUserIdentity(authenticationEvent.Rdn), IsEncryptedRequest = context.HasEncryptedConnection, Password = authenticationEvent.Password, IpAddress = context.IpAddress.ToString(), }; var response = await _ldapClient.ExecuteBindRequestAsync(bindRequest); return(response.WasBindSuccessful); }
protected override void beforeEach() { _template = new Template("", "", ""); _descriptor = new ViewDescriptor(_template); _template.Descriptor = _descriptor; _request = new BindRequest { Target = _template, ViewModelType = "FubuMVC.Spark.Tests.SparkModel.Binding.Baz", Types = typePool(), Logger = MockFor <ISparkLogger>() }; }
/// <summary> /// Creates a sicily response BindRequest packet. Usually it's the last packet of authentication during /// the bind process. /// </summary> /// <param name="context">The user context which contains message ID.</param> /// <param name="credential">The credential to be sent, it can be calculated with SSPI.</param> /// <returns>The packet that contains the request.</returns> internal override AdtsBindRequestPacket CreateSicilyResponseBindRequest( AdtsLdapContext context, byte[] credential) { BindRequest_authentication authentication = new BindRequest_authentication(); authentication.SetData(BindRequest_authentication.sicilyResponse, new Asn1OctetString(credential ?? (new byte[0]))); BindRequest bindRequest = new BindRequest( new Asn1Integer((long)version), new LDAPDN(string.Empty), authentication); return(CreateBindRequestPacket(context, bindRequest)); }
/// <summary> /// Creates a BindRequest with simple bind. /// </summary> /// <param name="context">The user context which contains message ID.</param> /// <param name="name"> /// The name field of BindRequest, see TD Section 5.1.1.1.1 for full list of legal names. /// </param> /// <param name="password">The password credential of the object.</param> /// <returns>The packet that contains the request.</returns> internal override AdtsBindRequestPacket CreateSimpleBindRequest( AdtsLdapContext context, string name, string password) { BindRequest_authentication authentication = new BindRequest_authentication(); authentication.SetData(BindRequest_authentication.simple, new Asn1OctetString(password ?? string.Empty)); BindRequest bindRequest = new BindRequest( new Asn1Integer((long)version), new LDAPDN(name ?? string.Empty), authentication); return(CreateBindRequestPacket(context, bindRequest)); }
public override void Bind(IRpcController controller, BindRequest request, Action<BindResponse> done) { var response = BindResponse.CreateBuilder(); // export all services requested by the client and add their id to the response foreach (var import in request.ImportedServiceHashList) { var index = client.ExportService(import); response.AddImportedServiceId(index); } // store which services the client exports to us foreach (var export in request.ExportedServiceList) { client.ImportService(export.Hash, export.Id); } done(response.Build()); }
/// <summary> /// Creates a sicily BindRequest packet. /// </summary> /// <param name="context">The user context which contains message ID.</param> /// <param name="authName">Authentication name of the request.</param> /// <param name="credential">The credential to be sent, it can be calculated with SSPI.</param> /// <returns>The packet that contains the request.</returns> internal override AdtsBindRequestPacket CreateSicilyNegotiateBindRequest( AdtsLdapContext context, string authName, byte[] credential) { AuthenticationChoice authentication = new AuthenticationChoice(); authentication.SetData(AuthenticationChoice.sicilyNegotiate, new Asn1OctetString(credential ?? (new byte[0]))); BindRequest bindRequest = new BindRequest( new Asn1Integer((long)version), new LDAPDN(authName ?? string.Empty), authentication); return(CreateBindRequestPacket(context, bindRequest)); }
/// <summary> /// Creates a BindRequestPacket with context and BindRequest. /// </summary> /// <param name="context">The context.</param> /// <param name="bindRequest">The BindRequest message.</param> /// <returns>The BindRequestPacket.</returns> private AdtsBindRequestPacket CreateBindRequestPacket( AdtsLdapContext context, BindRequest bindRequest) { LDAPMessage_protocolOp operation = new LDAPMessage_protocolOp(); operation.SetData(LDAPMessage_protocolOp.bindRequest, bindRequest); LDAPMessage message = new LDAPMessage(new MessageID(context.MessageId), operation); AdtsBindRequestPacket packet = new AdtsBindRequestPacket(); packet.ldapMessagev2 = message; packet.messageId = context.MessageId; return(packet); }
protected override void beforeEach() { _template = new Template("", "", ""); _descriptor = new ViewDescriptor <IRazorTemplate>(_template); _template.Descriptor = _descriptor; _request = new BindRequest <IRazorTemplate> { Target = _template, Parsing = new Parsing { ViewModelType = "FubuMVC.Razor.Tests.RazorModel.Binding.Generic<FubuMVC.Razor.Tests.RazorModel.Binding.Baz>", }, Types = typePool(), Logger = MockFor <ITemplateLogger>() }; }
public override void Bind(IRpcController controller, BindRequest request, Action <BindResponse> done) { var newResponse = BindResponse.CreateBuilder(); foreach (var hash in request.ImportedServiceHashList) { newResponse.AddImportedServiceId(client.LoadImportedService(hash)); } foreach (var s in request.ExportedServiceList) { client.LoadExportedService(s.Hash, s.Id); } var response = newResponse.Build(); done(response); }
public override void Bind(IRpcController controller, BindRequest request, Action<BindResponse> done) { var newResponse = BindResponse.CreateBuilder(); foreach (var hash in request.ImportedServiceHashList) { newResponse.AddImportedServiceId(client.LoadImportedService(hash)); } foreach (var s in request.ExportedServiceList) { client.LoadExportedService(s.Hash, s.Id); } var response = newResponse.Build(); done(response); }
protected override void beforeEach() { _template = new Template("", "", ""); _descriptor = new SparkDescriptor(_template); _template.Descriptor = _descriptor; _parsing = new Parsing { ViewModelType = "FubuMVC.Spark.Tests.SparkModel.Binding.Baz" }; _request = new BindRequest <ITemplate> { Target = _template, Parsing = _parsing, Types = typePool(), Logger = MockFor <ITemplateLogger>() }; }
public override void Bind(IRpcController controller, BindRequest request, Action <BindResponse> done) { var response = BindResponse.CreateBuilder(); // export all services requested by the client and add their id to the response foreach (var import in request.ImportedServiceHashList) { var index = client.ExportService(import); response.AddImportedServiceId(index); } // store which services the client exports to us foreach (var export in request.ExportedServiceList) { client.ImportService(export.Hash, export.Id); } done(response.Build()); }
/// <summary> /// Creates a BindRequest with SASL bind. This method is for LDAP v3 only. /// Note that for GSS-SPNEGO with NTLM, two rounds of bind requests is required. /// </summary> /// <param name="context">The user context which contains message ID.</param> /// <param name="mechanism">Authentication mechanism used, e.g., GSS-SPNEGO, etc.</param> /// <param name="credential">The credential to be sent, it can be calculated with SSPI.</param> /// <returns>The packet that contains the request.</returns> internal override AdtsBindRequestPacket CreateSaslBindRequest( AdtsLdapContext context, string mechanism, byte[] credential) { AuthenticationChoice authentication = new AuthenticationChoice(); authentication.SetData( AuthenticationChoice.sasl, new SaslCredentials( new LDAPString(mechanism ?? string.Empty), new Asn1OctetString(credential ?? (new byte[0])))); BindRequest bindRequest = new BindRequest( new Asn1Integer((long)version), new LDAPDN(new byte[0]), // For SASL, DN is not required. authentication); return(CreateBindRequestPacket(context, bindRequest)); }
private void BindSession(SessionBindInfo bindInfo, int timeOut) { _vTcpIpSession.SessionClosed += TcpIpSessionClosedEventHandler; BindRequest bindReq = bindInfo.CreatePdu(); _vTrans.Send(bindReq); BindResponse bindResp = null; try { bindResp = (BindResponse)_vRespHandler.WaitResponse(bindReq, timeOut); } catch (SmppResponseTimedOutException ex) { throw new SmppBindException(ex); } if (bindResp.Header.ErrorCode != 0) { throw new SmppBindException(bindResp.Header.ErrorCode); } //Copy settings _vSmscId = bindResp.SystemId; _vSystemId = bindInfo.SystemId; _vPassword = bindInfo.Password; _vAddressTon = bindInfo.AddressTon; _vAddressNpi = bindInfo.AddressNpi; //Start timer _vTimer.Start(); _vIsAlive = true; switch (bindReq.Header.CommandType) { case CommandType.BindTransceiver: ChangeState(SmppSessionState.Transceiver); break; case CommandType.BindReceiver: ChangeState(SmppSessionState.Receiver); break; case CommandType.BindTransmitter: ChangeState(SmppSessionState.Transmitter); break; } }
/// <summary> /// Creates a BindRequest with simple bind for Active Directory Domain Services(AD DS). /// </summary> /// <param name="context">The user context which contains message ID.</param> /// <param name="username">User name which doesn't include domain prefix.</param> /// <param name="password">Password of user.</param> /// <param name="domainNetbiosName">NetBIOS domain name(with suffix like ".com" removed).</param> /// <returns>The packet that contains the request.</returns> /// <exception cref="ArgumentNullException">Thrown when username is null.</exception> internal override AdtsBindRequestPacket CreateSimpleBindRequest( AdtsLdapContext context, string username, string password, string domainNetbiosName) { if (username == null) { throw new ArgumentNullException("username"); } BindRequest_authentication authentication = new BindRequest_authentication(); authentication.SetData(BindRequest_authentication.simple, new Asn1OctetString(password ?? string.Empty)); string fullname = (domainNetbiosName != null) ? (domainNetbiosName + "\\" + username) : username; BindRequest bindRequest = new BindRequest( new Asn1Integer((long)version), new LDAPDN(fullname), authentication); return(CreateBindRequestPacket(context, bindRequest)); }
public override void Bind(Google.ProtocolBuffers.IRpcController controller, BindRequest request, Action<BindResponse> done) { throw new NotImplementedException(); }
public override void Bind(IRpcController controller, BindRequest request, Action<BindResponse> done) { ProtoOutputBuffer.Write(request.GetType(), request.ToString()); }