public static void CreateIssuedToken(Guid transactionId, string coordinationContextId, ProtocolVersion protocolVersion, out RequestSecurityTokenResponse issuedToken, out string sctId) { sctId = CoordinationContext.CreateNativeIdentifier(Guid.NewGuid()); byte[] key = DeriveIssuedTokenKey(transactionId, sctId); DateTime utcNow = DateTime.UtcNow; SecurityContextSecurityToken token = new SecurityContextSecurityToken(new UniqueId(sctId), key, utcNow, utcNow + TimeSpan.FromDays(36500.0)); BinarySecretSecurityToken token2 = new BinarySecretSecurityToken(key); SecurityStandardsManager standardsManager = CreateStandardsManager(protocolVersion); RequestSecurityTokenResponse response = new RequestSecurityTokenResponse(standardsManager) { TokenType = standardsManager.SecureConversationDriver.TokenTypeUri, RequestedUnattachedReference = SecurityContextSecurityTokenParameters.CreateKeyIdentifierClause(token, SecurityTokenReferenceStyle.External), RequestedAttachedReference = SecurityContextSecurityTokenParameters.CreateKeyIdentifierClause(token, SecurityTokenReferenceStyle.Internal), RequestedSecurityToken = token, RequestedProofToken = token2 }; DataContractSerializer serializer = IdentifierElementSerializer(protocolVersion); ProtocolVersionHelper.AssertProtocolVersion(protocolVersion, typeof(CoordinationServiceSecurity), "CreateIssuedToken"); switch (protocolVersion) { case ProtocolVersion.Version10: response.SetAppliesTo<IdentifierElement10>(new IdentifierElement10(coordinationContextId), serializer); break; case ProtocolVersion.Version11: response.SetAppliesTo<IdentifierElement11>(new IdentifierElement11(coordinationContextId), serializer); break; } response.MakeReadOnly(); if (DebugTrace.Verbose) { DebugTrace.Trace(TraceLevel.Verbose, "Created issued token with id {0} for transaction {1}", sctId, transactionId); } issuedToken = response; }
public NpgsqlPasswordPacket(String password, ProtocolVersion protocolVersion) { NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME); this.password = password; this.protocolVersion = protocolVersion; }
public static void AssertProtocolVersion(ProtocolVersion protocolVersion, Type type, string method) { if (!Enum.IsDefined(typeof(ProtocolVersion), protocolVersion)) { DiagnosticUtility.FailFast(string.Concat(new object[] { "An invalid protocol version value was used in ", type, '.', method })); } }
// The demand is not added now (in 4.5), to avoid a breaking change. To be considered in the next version. /* // We demand full trust because we call into CoordinationStrings.Version(..), which is defined in a non-APTCA assembly and does an Environment.FailFast // if the argument is invalid. It's recommended to not let partially trusted callers to bring down the process. // WSATs are not supported in partial trust, so customers should not be broken by this demand. [PermissionSet(SecurityAction.Demand, Unrestricted = true)] */ public WsatTransactionHeader(CoordinationContext context, ProtocolVersion protocolVersion) { this.context = context; CoordinationStrings coordinationStrings = CoordinationStrings.Version(protocolVersion); this.wsatHeaderElement = coordinationStrings.CoordinationContext; this.wsatNamespace = coordinationStrings.Namespace; }
public override bool VerifyData(ProtocolVersion version, byte[] data, HashAlgorithm hashAlgorithm, CertificatePublicKey key, byte[] signature) { if (signature.Length == 0) { return true; } return false; }
public NpgsqlStartupPacket(Int32 packet_size, ProtocolVersion protocol_version, String database_name, String user_name, String arguments, String unused, String optional_tty) { NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME); // Just copy the values. // [FIXME] Validate params? We are the only clients, so, hopefully, we // know what to send. this.packet_size = packet_size; this.protocol_version = protocol_version; this.database_name = database_name; this.user_name = user_name; this.arguments = arguments; this.unused = unused; this.optional_tty = optional_tty; }
public InfoSource(GuidPrefix guidPrefix) : base(SubMessageKind.INFO_SRC) { this.protocolVersion = ProtocolVersion.PROTOCOLVERSION_2_1; this.vendorId = VendorId.VENDORID_UNKNOWN; this.guidPrefix = guidPrefix; }
/// <summary> /// Creates a new <see cref="ConnectionParameters"/>. /// </summary> public ConnectionParameters() { m_protocolVersion = ProtocolVersion.M; m_configurationFileName = null; m_refreshConfigurationFileOnChange = false; m_deviceLabel = null; }
public NpgsqlAsciiRow(NpgsqlRowDescription rowDesc, ProtocolVersion protocolVersion, byte[] inputBuffer, char[] chars) : base(rowDesc, protocolVersion) { NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME); _inputBuffer = inputBuffer; _chars = chars; }
public static IFrameBuilder GetBuilderFor(ProtocolVersion protocolVersion) { if(protocolVersion == ProtocolVersion.Hybi10) return new Hybi10ControlFrameBuilder(); return null; }
public static CoordinationContext GetCoordinationContext(Message message, ProtocolVersion protocolVersion) { int num; CoordinationContext context; CoordinationStrings strings = CoordinationStrings.Version(protocolVersion); string coordinationContext = strings.CoordinationContext; string ns = strings.Namespace; try { num = message.Headers.FindHeader(coordinationContext, ns); } catch (MessageHeaderException exception) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning); return null; } if (num < 0) { return null; } XmlDictionaryReader readerAtHeader = message.Headers.GetReaderAtHeader(num); using (readerAtHeader) { context = GetCoordinationContext(readerAtHeader, protocolVersion); } MessageHeaderInfo headerInfo = message.Headers[num]; if (!message.Headers.UnderstoodHeaders.Contains(headerInfo)) { message.Headers.UnderstoodHeaders.Add(headerInfo); } return context; }
void parameterizedProgrammaticOPIdentifierTest(Identifier opIdentifier, ProtocolVersion version, Identifier claimedUrl, AuthenticationRequestMode requestMode, AuthenticationStatus expectedResult, bool provideStore) { var rp = TestSupport.CreateRelyingParty(provideStore ? TestSupport.RelyingPartyStore : null, null, null); var returnTo = TestSupport.GetFullUrl(TestSupport.ConsumerPage); var realm = new Realm(TestSupport.GetFullUrl(TestSupport.ConsumerPage).AbsoluteUri); var request = rp.CreateRequest(opIdentifier, realm, returnTo); request.Mode = requestMode; var rpResponse = TestSupport.CreateRelyingPartyResponseThroughProvider(request, opReq => { opReq.IsAuthenticated = expectedResult == AuthenticationStatus.Authenticated; if (opReq.IsAuthenticated.Value) { opReq.ClaimedIdentifier = claimedUrl; } }); Assert.AreEqual(expectedResult, rpResponse.Status); if (rpResponse.Status == AuthenticationStatus.Authenticated) { Assert.AreEqual(claimedUrl, rpResponse.ClaimedIdentifier); } else if (rpResponse.Status == AuthenticationStatus.SetupRequired) { Assert.IsNull(rpResponse.ClaimedIdentifier); Assert.IsNull(rpResponse.FriendlyIdentifierForDisplay); Assert.IsNull(rpResponse.Exception); Assert.IsInstanceOfType(typeof(ISetupRequiredAuthenticationResponse), rpResponse); Assert.AreEqual(opIdentifier.ToString(), ((ISetupRequiredAuthenticationResponse)rpResponse).ClaimedOrProviderIdentifier.ToString()); } }
public override byte[] GetClientKeys(ProtocolVersion version, ProtocolVersion clientVersion, CertificatePublicKey publicKey) { if (!(publicKey.Algorithm is RSACryptoServiceProvider)) { throw new CryptographicException("RSA key exchange requires RSA public key"); } return GetClientKeys(version, clientVersion, (RSACryptoServiceProvider)publicKey.Algorithm); }
public InteropRegistrationBinding(Uri clientBaseAddress, bool acceptSupportingTokens, ProtocolVersion protocolVersion) : base(clientBaseAddress, protocolVersion) { if (acceptSupportingTokens) { this.supportingTokenBE = new Microsoft.Transactions.Wsat.Messaging.SupportingTokenBindingElement(protocolVersion); } }
public static void AssertProtocolVersion11(ProtocolVersion protocolVersion, Type type, string method) { if (protocolVersion != ProtocolVersion.Version11) { DiagnosticUtility.FailFast(string.Concat(new object[] { "Must use the protocol version 1.1 to execute ", type, '.', method })); } }
public static NpgsqlStartupPacket BuildStartupPacket(ProtocolVersion protocol_version, String database_name, String user_name, NpgsqlConnectionStringBuilder settings) { NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "BuildStartupPacket"); if (protocol_version == ProtocolVersion.Version2) { return new NpgsqlStartupPacketV2(database_name,user_name, "", "", ""); } else { Dictionary<String, String> parameters = new Dictionary<String, String>(); parameters.Add("DateStyle", "ISO"); parameters.Add("client_encoding", "UTF8"); parameters.Add("extra_float_digits", "2"); parameters.Add("lc_monetary", "C"); if (!string.IsNullOrEmpty(settings.ApplicationName)) { parameters.Add("application_name", settings.ApplicationName); } if (!string.IsNullOrEmpty(settings.SearchPath)) { parameters.Add("search_path", settings.SearchPath); } return new NpgsqlStartupPacketV3(database_name,user_name,parameters); } }
// The demand is not added now (in 4.5), to avoid a breaking change. To be considered in the next version. /* // We demand full trust because we call into CoordinationContext and CoordinationStrings, which are defined in a non-APTCA assembly. Also, CoordinationStrings.Version(..) // does an Environment.FailFast if the argument is invalid. It's recommended to not let partially trusted callers to bring down the process. // WSATs are not supported in partial trust, so customers should not be broken by this demand. [PermissionSet(SecurityAction.Demand, Unrestricted = true)] */ public static CoordinationContext GetCoordinationContext(Message message, ProtocolVersion protocolVersion) { CoordinationStrings coordinationStrings = CoordinationStrings.Version(protocolVersion); string locWsatHeaderElement = coordinationStrings.CoordinationContext; string locWsatNamespace = coordinationStrings.Namespace; int index; try { index = message.Headers.FindHeader(locWsatHeaderElement, locWsatNamespace); } catch (MessageHeaderException e) { DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning); return null; } if (index < 0) return null; CoordinationContext context; XmlDictionaryReader reader = message.Headers.GetReaderAtHeader(index); using (reader) { context = GetCoordinationContext(reader, protocolVersion); } MessageHeaderInfo header = message.Headers[index]; if (!message.Headers.UnderstoodHeaders.Contains(header)) { message.Headers.UnderstoodHeaders.Add(header); } return context; }
public override bool SupportsProtocolVersion(ProtocolVersion version) { if (version.IsUsingDatagrams) { return false; } return true; }
public Receiver(Header header) : this() { sourceGuidPrefix = header.GuidPrefix; sourceVersion = header.Version; throw new KeyNotFoundException("See page 35, unicast and multicast initialization"); }
private static void AddVersionTests(IList testSuite, ProtocolVersion version) { string prefix = version.ToString() .Replace(" ", "") .Replace("\\", "") .Replace(".", "") + "_"; /* * NOTE: Temporarily disabled automatic test runs because of problems getting a clean exit * of the DTLS server after a fatal alert. As of writing, manual runs show the correct * alerts being raised */ //{ // TlsTestConfig c = CreateDtlsTestConfig(version); // c.clientAuth = C.CLIENT_AUTH_INVALID_VERIFY; // c.ExpectServerFatalAlert(AlertDescription.decrypt_error); // testSuite.Add(new TestCaseData(c).SetName(prefix + "BadCertificateVerify")); //} //{ // TlsTestConfig c = CreateDtlsTestConfig(version); // c.clientAuth = C.CLIENT_AUTH_INVALID_CERT; // c.ExpectServerFatalAlert(AlertDescription.bad_certificate); // testSuite.Add(new TestCaseData(c).SetName(prefix + "BadClientCertificate")); //} //{ // TlsTestConfig c = CreateDtlsTestConfig(version); // c.clientAuth = C.CLIENT_AUTH_NONE; // c.serverCertReq = C.SERVER_CERT_REQ_MANDATORY; // c.ExpectServerFatalAlert(AlertDescription.handshake_failure); // testSuite.Add(new TestCaseData(c).SetName(prefix + "BadMandatoryCertReqDeclined")); //} { TlsTestConfig c = CreateDtlsTestConfig(version); testSuite.Add(new TestCaseData(c).SetName(prefix + "GoodDefault")); } { TlsTestConfig c = CreateDtlsTestConfig(version); c.serverCertReq = C.SERVER_CERT_REQ_NONE; testSuite.Add(new TestCaseData(c).SetName(prefix + "GoodNoCertReq")); } { TlsTestConfig c = CreateDtlsTestConfig(version); c.clientAuth = C.CLIENT_AUTH_NONE; testSuite.Add(new TestCaseData(c).SetName(prefix + "GoodOptionalCertReqDeclined")); } }
public Receiver() { sourceVersion = ProtocolVersion.PROTOCOLVERSION; vendorId = VendorId.VENDORID_UNKNOWN; sourceGuidPrefix = GuidPrefix.GUIDPREFIX_UNKNOWN; haveTimestamp = false; timestamp = Time.TIME_INVALID; }
Uri getPositiveAssertion(ProtocolVersion version) { OpenIdRelyingParty rp = TestSupport.CreateRelyingParty(null); Identifier id = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, version); var request = rp.CreateRequest(id, realm, returnTo); var provider = TestSupport.CreateProviderForRequest(request); var opRequest = provider.Request as DotNetOpenId.Provider.IAuthenticationRequest; opRequest.IsAuthenticated = true; return opRequest.Response.ExtractUrl(); }
void replayAttackPrevention(ProtocolVersion version) { ServiceEndpoint ep = getServiceEndpoint(TestSupport.Scenarios.AutoApproval, version); Token token = new Token(ep); INonceStore store = new ApplicationMemoryStore(); string serializedToken = token.Serialize(store); Token.Deserialize(serializedToken, store); Token.Deserialize(serializedToken, store); }
public Finished(ProtocolVersion ver, byte[] verifyData) : base(HandshakeType.Finished) { if (ver == ProtocolVersion.SSL30 && verifyData.Length != 36) throw new ArgumentException (); if (ver != ProtocolVersion.SSL30 && verifyData.Length != 12) throw new ArgumentException (); _verifyData = verifyData; }
/// <summary> /// init /// </summary> public RequestPackage(int msgId, string sessionId, int actionId, int userId, ProtocolVersion ptcl = ProtocolVersion.Default) { MsgId = msgId; SessionId = sessionId; ProxySid = Guid.Empty; ActionId = actionId; UserId = userId; Ptcl = ptcl; }
public Finished(ProtocolVersion ver, byte[] buffer, int offset, uint length) : base(HandshakeType.Finished) { if (ver == ProtocolVersion.SSL30) _verifyData = new byte[36]; else _verifyData = new byte[12]; Buffer.BlockCopy (buffer, offset, _verifyData, 0, _verifyData.Length); }
public ServiceProviderDescription(OAuthEndPoint requestTokenEndPoint, OAuthEndPoint authorizationEndPoint, OAuthEndPoint accessTokenEndPoint, ProtocolVersion protocolVersion = ProtocolVersion.V10) { this.RequestTokenEndPoint = requestTokenEndPoint; this.AuthorizationEndPoint = authorizationEndPoint; this.AccessTokenEndPoint = accessTokenEndPoint; this.ProtocolVersion = protocolVersion; }
public ServerHello(ProtocolVersion ver, byte[] random, byte[] sessionID, CipherSuite suite, CompressionMethod compression, Extension[] extensions) : base(HandshakeType.ServerHello) { _version = ver; _random = random; _sessionID = sessionID; _cipherSuite = suite; _compression = compression; _extensions = extensions; }
public HandshakeRequest(string handshakeRequest) { var lines = handshakeRequest.Split(Environment.NewLine.ToCharArray()); foreach (var line in lines.Where(l=>string.IsNullOrEmpty(l) == false)) { if(line.StartsWith("GET")) { Path = line.Replace("GET /", "").Replace("HTTP/1.1", "").Trim(); continue; } if (line.StartsWith("Sec-WebSocket-Version:")) { Version = int.Parse(line.Split(':')[1]) <= 7 ? ProtocolVersion.Hixie76 : ProtocolVersion.Hybi10; continue; } if (line.StartsWith("Sec-WebSocket-Key:")) { Key = line.Split(':')[1].Trim(); continue; } if (line.StartsWith("Host:")) { Host = line.Split(':')[1].Trim(); continue; } if (line.StartsWith("Upgrade:")) { Upgrade = line.Split(':')[1].Trim(); continue; } if (line.StartsWith("Connection:")) { Connection = line.Split(':')[1].Trim(); continue; } if (line.StartsWith("Sec-WebSocket-Origin:")) { Origin = line.Replace("Sec-WebSocket-Origin:", "").Trim(); continue; } if (line.StartsWith("Sec-WebSocket-Extensions:")) { Extensions = line.Split(':')[1].Trim(); continue; } } }
static ServiceEndpoint getServiceEndpoint(TestSupport.Scenarios scenario, ProtocolVersion version) { Protocol protocol = Protocol.Lookup(version); ServiceEndpoint ep = ServiceEndpoint.CreateForClaimedIdentifier( TestSupport.GetIdentityUrl(scenario, version), TestSupport.GetDelegateUrl(scenario), TestSupport.GetFullUrl(TestSupport.ProviderPage), new[] { protocol.ClaimedIdentifierServiceTypeURI }, 10, 10 ); return ep; }
/// <summary> /// Determines if the protocol version is supported by this driver. /// </summary> public static bool IsSupported(this ProtocolVersion version) { return(version >= ProtocolVersion.V1 && version <= ProtocolVersion.V4); }
/// <inheritdoc/> public NetworkPeer CreateConnectedNetworkPeer(Network network, string endpoint, ProtocolVersion myVersion = ProtocolVersion.PROTOCOL_VERSION, bool isRelay = true, CancellationToken cancellation = default(CancellationToken)) { IPEndPoint ipEndPoint = Utils.ParseIpEndpoint(endpoint, network.DefaultPort); var parameters = new NetworkPeerConnectionParameters() { ConnectCancellation = cancellation, IsRelay = isRelay, Version = myVersion, Services = NetworkPeerServices.Nothing, }; return(this.CreateConnectedNetworkPeer(network, ipEndPoint, parameters)); }
public override void NotifyServerVersion(ProtocolVersion serverVersion) { base.NotifyServerVersion(serverVersion); Console.WriteLine("Negotiated " + serverVersion); }
/// <summary> /// Determines whether the protocol supports unset parameters. /// </summary> /// <param name="version"></param> /// <returns></returns> public static bool SupportsUnset(this ProtocolVersion version) { return(version >= ProtocolVersion.V4); }
public static void ReadWrite(this IBitcoinSerializable serializable, Stream stream, bool serializing, ProtocolVersion protocolVersion = ProtocolVersion.PROTOCOL_VERSION) { serializable.ReadWrite(new BitcoinStream(stream, serializing) { ProtocolVersion = protocolVersion }); }
/// <summary> /// Determines whether the collection length is encoded using 32 bits. /// </summary> public static bool Uses4BytesCollectionLength(this ProtocolVersion version) { return(version >= ProtocolVersion.V3); }
public override IEnumerable <MacroOpBase> ToMacroOps(ProtocolVersion version) { if (Mask.HasFlag(MaskFlags.SizeX)) { yield return new DVEAndFlyKeyXSizeMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, SizeX = SizeX } } ; if (Mask.HasFlag(MaskFlags.SizeY)) { yield return new DVEAndFlyKeyYSizeMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, SizeY = SizeY } } ; if (Mask.HasFlag(MaskFlags.PositionX)) { yield return new DVEAndFlyKeyXPositionMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, PositionX = PositionX } } ; if (Mask.HasFlag(MaskFlags.PositionY)) { yield return new DVEAndFlyKeyYPositionMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, PositionY = PositionY } } ; if (Mask.HasFlag(MaskFlags.Rotation)) { yield return new DVEAndFlyKeyRotationMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, Rotation = Rotation } } ; if (Mask.HasFlag(MaskFlags.BorderEnabled)) { yield return new DVEKeyBorderEnableMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, Enable = BorderEnabled } } ; if (Mask.HasFlag(MaskFlags.BorderShadowEnabled)) { yield return new DVEKeyShadowEnableMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, Enable = BorderShadowEnabled } } ; if (Mask.HasFlag(MaskFlags.BorderBevel)) { yield return new DVEKeyBorderBevelMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, Bevel = BorderBevel } } ; if (Mask.HasFlag(MaskFlags.BorderOuterWidth)) { yield return new DVEKeyBorderOuterWidthMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, OuterWidth = BorderOuterWidth } } ; if (Mask.HasFlag(MaskFlags.BorderInnerWidth)) { yield return new DVEKeyBorderInnerWidthMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, InnerWidth = BorderInnerWidth } } ; if (Mask.HasFlag(MaskFlags.BorderOuterSoftness)) { yield return new DVEKeyBorderOuterSoftnessMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, OuterSoftness = BorderOuterSoftness } } ; if (Mask.HasFlag(MaskFlags.BorderInnerSoftness)) { yield return new DVEKeyBorderInnerSoftnessMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, InnerSoftness = BorderInnerSoftness } } ; if (Mask.HasFlag(MaskFlags.BorderBevelSoftness)) { yield return new DVEKeyBorderBevelSoftnessMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, BevelSoftness = BorderBevelSoftness } } ; if (Mask.HasFlag(MaskFlags.BorderBevelPosition)) { yield return new DVEKeyBorderBevelPositionMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, BevelPosition = BorderBevelPosition } } ; if (Mask.HasFlag(MaskFlags.BorderOpacity)) { yield return new DVEKeyBorderOpacityMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, Opacity = BorderOpacity } } ; if (Mask.HasFlag(MaskFlags.BorderHue)) { yield return new DVEKeyBorderHueMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, Hue = BorderHue } } ; if (Mask.HasFlag(MaskFlags.BorderSaturation)) { yield return new DVEKeyBorderSaturationMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, Saturation = BorderSaturation } } ; if (Mask.HasFlag(MaskFlags.BorderLuma)) { yield return new DVEKeyBorderLuminescenceMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, Luma = BorderLuma } } ; if (Mask.HasFlag(MaskFlags.LightSourceDirection)) { yield return new DVEKeyShadowDirectionMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, Direction = LightSourceDirection } } ; if (Mask.HasFlag(MaskFlags.LightSourceAltitude)) { yield return new DVEKeyShadowAltitudeMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, Altitude = LightSourceAltitude } } ; if (Mask.HasFlag(MaskFlags.MaskEnabled)) { yield return new DVEKeyMaskEnableMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, Enable = MaskEnabled } } ; if (Mask.HasFlag(MaskFlags.MaskTop)) { yield return new DVEKeyMaskTopMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, Top = MaskTop } } ; if (Mask.HasFlag(MaskFlags.MaskBottom)) { yield return new DVEKeyMaskBottomMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, Bottom = MaskBottom } } ; if (Mask.HasFlag(MaskFlags.MaskLeft)) { yield return new DVEKeyMaskLeftMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, Left = MaskLeft } } ; if (Mask.HasFlag(MaskFlags.MaskRight)) { yield return new DVEKeyMaskRightMacroOp() { Index = MixEffectIndex, KeyIndex = KeyerIndex, Right = MaskRight } } ; if (Mask.HasFlag(MaskFlags.Rate)) { yield return new DVEAndFlyKeyRateMacroOp { Index = MixEffectIndex, KeyIndex = KeyerIndex, Rate = Rate } } ; } } }
public static VolatileEnlistmentInDoubtRecordSchema Instance(Guid enlistmentId, EndpointAddress replyTo, ProtocolVersion protocolVersion) { ProtocolVersionHelper.AssertProtocolVersion(protocolVersion, typeof(VolatileEnlistmentInDoubtRecordSchema), "Instance"); switch (protocolVersion) { case ProtocolVersion.Version10: return(new VolatileEnlistmentInDoubtRecordSchema10(enlistmentId, replyTo)); case ProtocolVersion.Version11: return(new VolatileEnlistmentInDoubtRecordSchema11(enlistmentId, replyTo)); } return(null); }
protected WsatTransactionFormatter(ProtocolVersion protocolVersion) { this.protocolVersion = protocolVersion; }
public static int GetSerializedSize(this IBitcoinSerializable serializable, ProtocolVersion version = ProtocolVersion.PROTOCOL_VERSION) { return(GetSerializedSize(serializable, version, SerializationType.Disk)); }
public static void FromBytes(this IBitcoinSerializable serializable, byte[] bytes, ProtocolVersion version = ProtocolVersion.PROTOCOL_VERSION) { using (var ms = new MemoryStream(bytes)) { var bitcoinStream = new BitcoinStream(ms, false) { ProtocolVersion = version }; serializable.ReadWrite(bitcoinStream); } }
public static void ReadWrite(this IBitcoinSerializable serializable, byte[] bytes, ConsensusFactory consensusFactory, ProtocolVersion version = ProtocolVersion.PROTOCOL_VERSION) { using (var ms = new MemoryStream(bytes)) { ReadWrite(serializable, ms, false, consensusFactory, version); } }
public static void ReadWrite(this IBitcoinSerializable serializable, Stream stream, bool serializing, ConsensusFactory consensusFactory, ProtocolVersion protocolVersion = ProtocolVersion.PROTOCOL_VERSION) { if (consensusFactory == null) { throw new ArgumentException("{0} cannot be null", nameof(consensusFactory)); } serializable.ReadWrite(new BitcoinStream(stream, serializing) { ProtocolVersion = protocolVersion, ConsensusFactory = consensusFactory }); }
public static byte[] ToBytes(this IBitcoinSerializable serializable, ConsensusFactory consensusFactory, ProtocolVersion version = ProtocolVersion.PROTOCOL_VERSION) { if (consensusFactory == null) { throw new ArgumentException("{0} cannot be null", nameof(consensusFactory)); } using (var ms = new MemoryStream()) { var bms = new BitcoinStream(ms, true) { ProtocolVersion = version, ConsensusFactory = consensusFactory }; serializable.ReadWrite(bms); return(ToArrayEfficient(ms)); } }
/// <summary> /// Startup responses using protocol v4+ can be a SERVER_ERROR wrapping a ProtocolException, /// this method returns true when is possible to receive such error. /// </summary> public static bool CanStartupResponseErrorBeWrapped(this ProtocolVersion version) { return(version >= ProtocolVersion.V4); }
public override bool SupportsProtocolVersion(ProtocolVersion version) { return(true); }
/// <summary> /// Determines whether the QUERY, EXECUTE and BATCH flags are encoded using 32 bits. /// </summary> public static bool Uses4BytesQueryFlags(this ProtocolVersion version) { return(version >= ProtocolVersion.V5); }
/// <summary> /// Determines whether the protocol supports up to 4 strings (ie: change_type, target, keyspace and table) in /// the schema change responses. /// </summary> public static bool SupportsSchemaChangeFullMetadata(this ProtocolVersion version) { return(version >= ProtocolVersion.V3); }
/// <summary> /// Determines if streamIds are serialized used 2 bytes /// </summary> public static bool Uses2BytesStreamIds(this ProtocolVersion version) { return(version >= ProtocolVersion.V3); }
/// <summary> /// Parse a Handshake ClientHello payload from wire format /// </summary> /// <returns>True if we successfully decode the ClientHello message. Otherwise false</returns> public static bool Parse(out ClientHello result, ByteSpan span) { result = new ClientHello(); if (span.Length < MinSize) { return(false); } ProtocolVersion clientVersion = (ProtocolVersion)span.ReadBigEndian16(); if (clientVersion != ProtocolVersion.DTLS1_2) { return(false); } span = span.Slice(2); result.Random = span.Slice(0, Dtls.Random.Size); span = span.Slice(Dtls.Random.Size); ///NOTE(mendsley): We ignore session id byte sessionIdSize = span[0]; if (span.Length < 1 + sessionIdSize) { return(false); } span = span.Slice(1 + sessionIdSize); byte cookieSize = span[0]; if (span.Length < 1 + cookieSize) { return(false); } result.Cookie = span.Slice(1, cookieSize); span = span.Slice(1 + cookieSize); ushort cipherSuiteSize = span.ReadBigEndian16(); if (span.Length < 2 + cipherSuiteSize) { return(false); } else if (cipherSuiteSize % 2 != 0) { return(false); } result.CipherSuites = span.Slice(2, cipherSuiteSize); span = span.Slice(2 + cipherSuiteSize); int compressionMethodsSize = span[0]; bool foundNullCompressionMethod = false; for (int ii = 0; ii != compressionMethodsSize; ++ii) { if (span[1 + ii] == (byte)CompressionMethod.Null) { foundNullCompressionMethod = true; break; } } span = span.Slice(1 + compressionMethodsSize); if (!foundNullCompressionMethod) { return(false); } // Parse extensions if (span.Length > 0) { ushort extensionsSize = span.ReadBigEndian16(); span = span.Slice(2); if (span.Length != extensionsSize) { return(false); } while (span.Length > 0) { // Parse extension header if (span.Length < 4) { return(false); } ExtensionType extensionType = (ExtensionType)span.ReadBigEndian16(0); ushort extensionLength = span.ReadBigEndian16(2); ByteSpan extensionData = span.Slice(4, extensionLength); if (extensionData.Length < extensionLength) { return(false); } span = span.Slice(4 + extensionLength); result.ParseExtension(extensionType, extensionData); } } return(true); }
/// <summary> /// Determines whether the protocol supports BATCH requests. /// </summary> public static bool SupportsBatch(this ProtocolVersion version) { return(version >= ProtocolVersion.V2); }
public PluggableProtocol(Guid protocolId, string name, ProtocolVersion protocolVersion) { this.protocolId = protocolId; this.name = name; this.protocolVersion = protocolVersion; }
/// <summary> /// Determines whether the protocol supports timestamps parameters in BATCH, QUERY and EXECUTE requests. /// </summary> public static bool SupportsTimestamp(this ProtocolVersion version) { return(version >= ProtocolVersion.V3); }
public GlobalAclOperationRequirement(List <string> windowsIdentities, List <string> x509Thumbprints, ProtocolVersion protocolVersion) { this.BuildSidDictionary((windowsIdentities != null) ? windowsIdentities : new List <string>()); this.BuildThumbprintDictionary((x509Thumbprints != null) ? x509Thumbprints : new List <string>()); this.protocolVersion = protocolVersion; }
// see interface ConnectionReuseStrategy public virtual bool KeepAlive(HttpResponse response, HttpContext context) { Args.NotNull(response, "HTTP response"); Args.NotNull(context, "HTTP context"); // Check for a self-terminating entity. If the end of the entity will // be indicated by closing the connection, there is no keep-alive. ProtocolVersion ver = response.GetStatusLine().GetProtocolVersion(); Header teh = response.GetFirstHeader(HTTP.TransferEncoding); if (teh != null) { if (!Sharpen.Runtime.EqualsIgnoreCase(HTTP.ChunkCoding, teh.GetValue())) { return(false); } } else { if (CanResponseHaveBody(response)) { Header[] clhs = response.GetHeaders(HTTP.ContentLen); // Do not reuse if not properly content-length delimited if (clhs.Length == 1) { Header clh = clhs[0]; try { int contentLen = System.Convert.ToInt32(clh.GetValue()); if (contentLen < 0) { return(false); } } catch (FormatException) { return(false); } } else { return(false); } } } // Check for the "Connection" header. If that is absent, check for // the "Proxy-Connection" header. The latter is an unspecified and // broken but unfortunately common extension of HTTP. HeaderIterator hit = response.HeaderIterator(HTTP.ConnDirective); if (!hit.HasNext()) { hit = response.HeaderIterator("Proxy-Connection"); } // Experimental usage of the "Connection" header in HTTP/1.0 is // documented in RFC 2068, section 19.7.1. A token "keep-alive" is // used to indicate that the connection should be persistent. // Note that the final specification of HTTP/1.1 in RFC 2616 does not // include this information. Neither is the "Connection" header // mentioned in RFC 1945, which informally describes HTTP/1.0. // // RFC 2616 specifies "close" as the only connection token with a // specific meaning: it disables persistent connections. // // The "Proxy-Connection" header is not formally specified anywhere, // but is commonly used to carry one token, "close" or "keep-alive". // The "Connection" header, on the other hand, is defined as a // sequence of tokens, where each token is a header name, and the // token "close" has the above-mentioned additional meaning. // // To get through this mess, we treat the "Proxy-Connection" header // in exactly the same way as the "Connection" header, but only if // the latter is missing. We scan the sequence of tokens for both // "close" and "keep-alive". As "close" is specified by RFC 2068, // it takes precedence and indicates a non-persistent connection. // If there is no "close" but a "keep-alive", we take the hint. if (hit.HasNext()) { try { TokenIterator ti = CreateTokenIterator(hit); bool keepalive = false; while (ti.HasNext()) { string token = ti.NextToken(); if (Sharpen.Runtime.EqualsIgnoreCase(HTTP.ConnClose, token)) { return(false); } else { if (Sharpen.Runtime.EqualsIgnoreCase(HTTP.ConnKeepAlive, token)) { // continue the loop, there may be a "close" afterwards keepalive = true; } } } if (keepalive) { return(true); } } catch (ParseException) { // neither "close" nor "keep-alive", use default policy // invalid connection header means no persistent connection // we don't have logging in HttpCore, so the exception is lost return(false); } } // default since HTTP/1.1 is persistent, before it was non-persistent return(!ver.LessEquals(HttpVersion.Http10)); }
/// <summary> /// Initializes a new instance of the object having a chain of block headers and a list of available nodes. /// </summary> /// <param name="chain">Chain of block headers.</param> /// <param name="nodes">Network peers of the node.</param> /// <param name="protocolVersion">Version of the protocol that the node supports.</param> /// <param name="loggerFactory">Factory to be used to create logger for the puller.</param> protected BlockPuller(ConcurrentChain chain, IReadOnlyNetworkPeerCollection nodes, ProtocolVersion protocolVersion, ILoggerFactory loggerFactory) { this.Chain = chain; this.Nodes = nodes; this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.downloadedBlocks = new Dictionary <uint256, DownloadedBlock>(); this.pendingInventoryVectors = new Queue <uint256>(); this.assignedBlockTasks = new Dictionary <uint256, BlockPullerBehavior>(); this.peerQuality = new QualityScore(QualityScoreHistoryLength, loggerFactory); // Set the default requirements. this.requirements = new NetworkPeerRequirement { MinVersion = protocolVersion, RequiredServices = NetworkPeerServices.Network }; }
private Connection CreateConnection(ProtocolVersion protocolVersion, Configuration config) { Trace.TraceInformation("Creating test connection using protocol v{0}", protocolVersion); return(new Connection(new Serializer(protocolVersion), new IPEndPoint(new IPAddress(new byte[] { 127, 0, 0, 1 }), 9042), config)); }
/// <inheritdoc/> public NetworkPeerServer CreateNetworkPeerServer(Network network, ProtocolVersion version = ProtocolVersion.PROTOCOL_VERSION, int internalPort = -1) { return(new NetworkPeerServer(network, version, internalPort, this.dateTimeProvider, this.loggerFactory, this)); }
public static void FromBytes(this IBitcoinSerializable serializable, byte[] bytes, ConsensusFactory consensusFactory, ProtocolVersion version = ProtocolVersion.PROTOCOL_VERSION) { if (consensusFactory == null) { throw new ArgumentException("{0} cannot be null", nameof(consensusFactory)); } using (var ms = new MemoryStream(bytes)) { var bitcoinStream = new BitcoinStream(ms, false) { ProtocolVersion = version, ConsensusFactory = consensusFactory }; serializable.ReadWrite(bitcoinStream); } }
public override IEnumerable <MacroOpBase> ToMacroOps(ProtocolVersion version) { yield return(new DownConvertModeMacroOp { DownConvertMode = DownConvertMode }); }