public void Validate(ContractDescription contractDescription, ServiceEndpoint endpoint) { Fx.Assert(endpoint is WorkflowHostingEndpoint, "Must be hosting endpoint!"); }
internal DebugInfo(ActivityInstance activityInstance) { Fx.Assert(activityInstance != null, "activityInstance cannot be null"); this.activityInstance = activityInstance; }
public FeatureAttribute(Type type) { Fx.Assert(type != null, "type should not be null"); this.type = type; }
public int ReleaseReference() { Fx.Assert(referenceCount > 0, "Reference count gone to negative"); //Called from higher locks taken return(--this.referenceCount); }
void OnRead(Task <int> antecedant, object state) { Fx.Assert(readResult != null, "StreamConnection: OnRead called twice."); readResult = antecedant; readCallback(state); }
internal override void ReadField(ByteBuffer buffer, int index, byte formatCode) { switch (index) { case 0: this.linkName = Encoder.ReadString(buffer, formatCode); break; case 1: this.handle = Encoder.ReadUInt(buffer, formatCode); break; case 2: this.role = Encoder.ReadBoolean(buffer, formatCode); break; case 3: this.sndSettleMode = (SenderSettleMode)Encoder.ReadUByte(buffer, formatCode); break; case 4: this.rcvSettleMode = (ReceiverSettleMode)Encoder.ReadUByte(buffer, formatCode); break; case 5: this.source = Encoder.ReadObject(buffer, formatCode); break; case 6: this.target = Encoder.ReadObject(buffer, formatCode); break; case 7: this.unsettled = Encoder.ReadMap(buffer, formatCode); break; case 8: this.incompleteUnsettled = Encoder.ReadBoolean(buffer, formatCode); break; case 9: this.initialDeliveryCount = Encoder.ReadUInt(buffer, formatCode); break; case 10: this.maxMessageSize = Encoder.ReadULong(buffer, formatCode); break; case 11: this.offeredCapabilities = Encoder.ReadObject(buffer, formatCode); break; case 12: this.desiredCapabilities = Encoder.ReadObject(buffer, formatCode); break; case 13: this.properties = Encoder.ReadFields(buffer, formatCode); break; default: Fx.Assert(false, "Invalid field index"); break; } }
// This is called if we found an existing lock. This handle doesn't own the lock, but it could claim it, if it can prove // that no other live handle owns it. If this returns non-null, the outcome will be available later on the // InstanceHandleReference once the AsyncWaitHandle completes. (Null indicates a conflict with another handle.) // // The instanceVersion reported here was read under the transaction, but not changed. Either it was already committed, or it was written under // this transaction in a prior command on a different handle. Due to the latter case, we treat it as dirty - we do not publish it or take // any visible action (such as dooming handles) based on its value. internal AsyncWaitHandle InitiateLockResolution(long instanceVersion, ref InstanceHandleReference reference, ref List <InstanceHandleReference> handlesPendingResolution) { Fx.Assert(reference != null, "Bind wasn't registered - RegisterStartBind must be called."); Fx.Assert(reference.InstanceHandle != null, "Cannot cancel and complete a bind."); Fx.Assert(reference.InstanceHandle.Id != Guid.Empty, "Must be bound to an instance already."); Fx.AssertAndThrow(!(reference is LockResolutionMarker), "InitiateLockResolution already called."); lock (HandlesLock) { InstanceHandleReference cancelReference = reference; LockResolutionMarker markerReference = null; try { InstanceHandle existingHandle; if (BoundHandles.TryGetValue(reference.InstanceHandle.Id, out existingHandle)) { Fx.AssertAndFailFast(!object.ReferenceEquals(existingHandle, reference.InstanceHandle), "InstanceStore lock state is not correct in InitiateLockResolution."); if (existingHandle.Version <= 0 || instanceVersion <= 0) { if (existingHandle.Version != 0 || instanceVersion != 0) { throw Fx.Exception.AsError(new InvalidOperationException(SRCore.InvalidLockToken)); } reference.InstanceHandle.ConflictingHandle = existingHandle; return(null); } if (existingHandle.Version >= instanceVersion) { reference.InstanceHandle.ConflictingHandle = existingHandle; return(null); } } // Put a marker in the InProgressHandles. If it makes it through, and there's still no conflicting handle, // then the lock can be claimed at this version. Only currently in-progress bindings have a chance of // staking a stronger claim to the lock version (if the store actually acquired the lock for the handle). markerReference = new LockResolutionMarker(reference.InstanceHandle, instanceVersion); EnqueueReference(markerReference); reference = markerReference; Fx.Assert(markerReference.MarkerWaitHandle != null, "Null MarkerWaitHandle?"); return(markerReference.MarkerWaitHandle); } finally { if (!object.ReferenceEquals(markerReference, reference)) { CancelReference(ref reference, ref handlesPendingResolution); if (markerReference != null) { cancelReference = markerReference; CancelReference(ref cancelReference, ref handlesPendingResolution); } } else { CancelReference(ref cancelReference, ref handlesPendingResolution); } } } }
internal protected UnrecognizedAssertionsBindingElement(XmlQualifiedName wsdlBinding, ICollection <XmlElement> bindingAsserions) { Fx.Assert(wsdlBinding != null, ""); _wsdlBinding = wsdlBinding; _bindingAsserions = bindingAsserions; }
public TokenProviderAdapter(AmqpEventHubClient eventHubClient) { Fx.Assert(eventHubClient != null, "tokenProvider cannot be null"); this.eventHubClient = eventHubClient; }
internal BookmarkScope(long temporaryId) { Fx.Assert(temporaryId != default(long), "Should never call this constructor with the default value."); this.temporaryId = temporaryId; }
// Similar to DispatchAndReleasePump on Desktop internal async Task DispatchAsyncCore(RequestContext request, bool cleanThread, OperationContext currentOperationContext) { ServiceChannel channel = _requestInfo.Channel; EndpointDispatcher endpoint = _requestInfo.Endpoint; try { DispatchRuntime dispatchBehavior = _requestInfo.DispatchRuntime; if (channel == null || dispatchBehavior == null) { Fx.Assert("System.ServiceModel.Dispatcher.ChannelHandler.Dispatch(): (channel == null || dispatchBehavior == null)"); } Message message = request.RequestMessage; DispatchOperationRuntime operation = dispatchBehavior.GetOperation(ref message); if (operation == null) { Fx.Assert("ChannelHandler.Dispatch (operation == null)"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException("No DispatchOperationRuntime found to process message.")); } if (_shouldRejectMessageWithOnOpenActionHeader && message.Headers.Action == OperationDescription.SessionOpenedAction) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxNoEndpointMatchingAddressForConnectionOpeningMessage, message.Headers.Action, "Open"))); } if (operation.IsTerminating && _hasSession) { _isChannelTerminated = true; } bool hasOperationContextBeenSet; if (currentOperationContext != null) { hasOperationContextBeenSet = true; currentOperationContext.ReInit(request, message, channel); } else { hasOperationContextBeenSet = false; currentOperationContext = new OperationContext(request, message, channel, null); } if (currentOperationContext.EndpointDispatcher == null && _serviceDispatcher != null) { currentOperationContext.EndpointDispatcher = endpoint; } MessageRpc rpc = new MessageRpc(request, message, operation, channel, /*host*/ null, this, cleanThread, currentOperationContext, _requestInfo.ExistingInstanceContext); // passing responsibility for call throttle to MessageRpc // (MessageRpc implicitly owns this throttle once it's created) _requestInfo.ChannelHandlerOwnsCallThrottle = false; // explicitly passing responsibility for instance throttle to MessageRpc rpc.MessageRpcOwnsInstanceContextThrottle = _requestInfo.ChannelHandlerOwnsInstanceContextThrottle; _requestInfo.ChannelHandlerOwnsInstanceContextThrottle = false; // These need to happen before Dispatch but after accessing any ChannelHandler // state, because we go multi-threaded after this until we reacquire pump mutex. await operation.Parent.DispatchAsync(rpc, hasOperationContextBeenSet); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } await HandleErrorAsync(e, request, channel); } }
public Task DispatchAsync(RequestContext context) { Fx.Assert(_next != null, "SetNextDispatcher wasn't called"); return(_next.DispatchAsync(context)); }
/// <summary> /// Used for Dynamic Update: after the instance is updated, if the statemachine is already transitioning, the index of the to-be-scheduled state /// would need to be updated. /// </summary> /// <param name="updateContext">Dynamic Update context</param> /// <param name="eventManager">Internal StateMachineEventManager</param> /// <returns>True, 1. if update is successful and the instanced is updated with the new indexes, and 2 all the trigger ID in the queue are updated; /// false otherwise and the update should fail.</returns> private bool UpdateEventManager( NativeActivityUpdateContext updateContext, StateMachineEventManager eventManager) { Fx.Assert(null != eventManager.CurrentBeingProcessedEvent, "The eventManager must have some info that needs to be updated during transition."); int updatedEventsInQueue = 0; int originalTriggerId = int.MinValue; int originalConditionIndex = int.MinValue; bool updateCurrentEventSucceed = null == eventManager.CurrentBeingProcessedEvent ? true : false; foreach (InternalTransition transition in this.internalTransitions) { object savedTriggerIndex = updateContext.GetSavedOriginalValue(transition.Trigger); if (savedTriggerIndex != null) { Fx.Assert(!updateContext.IsNewlyAdded(transition.Trigger), "the trigger in transition already exist."); if (null != eventManager.CurrentBeingProcessedEvent && eventManager.CurrentBeingProcessedEvent.TriggedId == (int)savedTriggerIndex) { // found a match of the running trigger update the current processed event // Don't match the trigger ID, match only when the Condition is also matched. if (eventManager.CurrentConditionIndex == -1) { if (transition.IsUnconditional) { // executing transition before persist is unconditional originalTriggerId = eventManager.CurrentBeingProcessedEvent.TriggedId; originalConditionIndex = 0; eventManager.CurrentBeingProcessedEvent.TriggedId = transition.InternalTransitionIndex; if (updateContext.GetValue(this.isExiting)) { Fx.Assert(eventManager.OnTransition, "The state is transitioning."); updateContext.SetValue(this.Result, GetTo(transition.InternalTransitionIndex)); } updateCurrentEventSucceed = true; } else { updateContext.DisallowUpdate(SR.ChangeTransitionTypeDuringTransitioningBlockDU); return(false); } } else if (eventManager.CurrentConditionIndex >= 0) { Fx.Assert(!transition.IsUnconditional, "Cannot update a running conditional transition with a unconditional one."); if (!transition.IsUnconditional) { // executing transition before and after are conditional for (int updatedIndex = 0; updatedIndex < transition.TransitionDataList.Count; updatedIndex++) { Activity condition = transition.TransitionDataList[updatedIndex].Condition; Fx.Assert(null != condition, "Conditional transition must have Condition activity."); int?savedCondIndex = updateContext.GetSavedOriginalValue(condition) as int?; if (eventManager.CurrentConditionIndex == savedCondIndex) { originalTriggerId = eventManager.CurrentBeingProcessedEvent.TriggedId; originalConditionIndex = eventManager.CurrentConditionIndex; eventManager.CurrentBeingProcessedEvent.TriggedId = transition.InternalTransitionIndex; eventManager.CurrentConditionIndex = updatedIndex; if (updateContext.GetValue(this.isExiting)) { Fx.Assert(eventManager.OnTransition, "The state is transitioning."); updateContext.SetValue(this.Result, this.GetTo(transition.InternalTransitionIndex, (int)updatedIndex)); } updateCurrentEventSucceed = true; break; } } } } } foreach (TriggerCompletedEvent completedEvent in eventManager.Queue) { if ((int)savedTriggerIndex == completedEvent.TriggedId) { completedEvent.TriggedId = transition.InternalTransitionIndex; updatedEventsInQueue++; } } } } return(eventManager.Queue.Count() == updatedEventsInQueue ? updateCurrentEventSucceed : false); }
private static bool ValidateDUInConditionTransition(NativeActivityUpdateMapMetadata metadata, InternalTransition updatedTransition, InternalTransition originalTransition, out string errorMessage) { Fx.Assert(!originalTransition.IsUnconditional, "Transition should be conditional in the original definition."); errorMessage = string.Empty; foreach (TransitionData updatedTData in updatedTransition.TransitionDataList) { if (metadata.IsReferenceToImportedChild(updatedTData.Condition)) { // if the trigger is referenced, it might have another save values already. errorMessage = SR.TriggerOrConditionIsReferenced; return(false); } Fx.Assert(null != updatedTData.Condition, "Must be a condition transition."); Activity conditionMatch = metadata.GetMatch(updatedTData.Condition); if (null == conditionMatch && null != metadata.GetMatch(updatedTData.Action)) { // new Transition.Condition with an Transition.Action moved from within the InternalState. errorMessage = SR.MovingActivitiesInStateBlockDU; return(false); } else if (null != conditionMatch) { bool foundMatchingOriginalCondition = false; for (int transitionIndex = 0; transitionIndex < originalTransition.TransitionDataList.Count; transitionIndex++) { if (object.ReferenceEquals(originalTransition.TransitionDataList[transitionIndex].Condition, conditionMatch)) { foundMatchingOriginalCondition = true; // found the original matching condition in updated transition definition. TransitionData originalTData = originalTransition.TransitionDataList[transitionIndex]; Activity originalAction = originalTData.Action; // NOTE: Transition.Action is allowed to be removed, because it doesn't change the execution semantics of SM // if this removed activity was executing, WF runtime would disallow the update. Activity actionMatch = metadata.GetMatch(updatedTData.Action); if (null != actionMatch && !object.ReferenceEquals(originalAction, actionMatch)) { // Transition.Action is an activity moved from elsewhere within the InternalState errorMessage = SR.MovingActivitiesInStateBlockDU; return(false); } metadata.SaveOriginalValue(updatedTransition.Trigger, originalTransition.InternalTransitionIndex); metadata.SaveOriginalValue(updatedTData.Condition, transitionIndex); } } if (!foundMatchingOriginalCondition) { // another child activity is move to the Transition.Condition. errorMessage = SR.DUDisallowIfCannotFindingMatchingCondition; return(false); } } } return(true); }
public void Bake(string typeName, string typeNamePrefix, Dictionary <string, byte[]> checksumCache) { // In partial trust, validate the typeName and typeNamePrefix. if (!PartialTrustHelpers.AppDomainFullyTrusted) { typeName = State.ValidateIdentifierString(typeName); typeNamePrefix = State.ValidateIdentifierString(typeNamePrefix); if (checksumCache != null) { bool nullifyChecksumCache = false; foreach (KeyValuePair <string, byte[]> kvpair in checksumCache) { // We use an MD5 hash for the checksum, so the byte array should be 16 elements long. if (!SymbolHelper.ValidateChecksum(kvpair.Value)) { nullifyChecksumCache = true; Trace.WriteLine(SR.DebugSymbolChecksumValueInvalid); break; } } // If we found an invalid checksum, just don't use the cache. if (nullifyChecksumCache) { checksumCache = null; } } } lock (this) { if (this.indexLastBaked < this.states.Count) // there are newly created states. { // Ensure typename is unique. Append a number if needed. int suffix = 1; while (this.dynamicModule.GetType(typeName) != null) { typeName = typeNamePrefix + "_" + suffix.ToString(CultureInfo.InvariantCulture); ++suffix; } TypeBuilder typeBuilder = this.dynamicModule.DefineType(typeName, TypeAttributes.Public | TypeAttributes.Class); for (int i = indexLastBaked; i < this.states.Count; i++) { // Only create the island if debugging is enabled for the state. if (this.states[i].DebuggingEnabled) { MethodBuilder methodBuilder = this.CreateIsland(typeBuilder, this.states[i], false, checksumCache); Fx.Assert(methodBuilder != null, "CreateIsland call should have succeeded"); // Always generate method with priming, for the following scenario: // 1. Start debugging a workflow inside VS, workflow debug session 1 starts (debugStartedAtRoot = true, instrumentation is done) // 2. Workflow persisted, workflow debug session 1 ends // 3. Workflow continued, workflow debug session 2 starts (debugStartedAtRoot = false, instrumentation is skipped because the static dynamicModuleManager is being reused and the instrumentation is done) // 4. PrimeCallStack is called to rebuild the call stack // 5. NullReferenceException will be thrown if MethodInfo with prime is not available MethodBuilder methodBuilderWithPriming = this.CreateIsland(typeBuilder, this.states[i], true, checksumCache); Fx.Assert(methodBuilderWithPriming != null, "CreateIsland call should have succeeded"); // Save information needed to call Type.GetMethod() later. this.states[i].CacheMethodInfo(typeBuilder, methodBuilder.Name); } } // Actual baking. typeBuilder.CreateType(); // Calling Type.GetMethod() is slow (10,000 calls can take ~1 minute). // So defer that to later. this.indexLastBaked = this.states.Count; } } }
//TODO: Move back to internal protected virtual bool IsMatch(BindingElement b) { Fx.Assert(true, "Should not be called unless this binding element is used in one of the standard bindings. In which case, please re-implement the IsMatch() method."); return(false); }
internal override void WriteField(ByteBuffer buffer, int index) { switch (index) { case 0: Encoder.WriteString(buffer, this.linkName, true); break; case 1: Encoder.WriteUInt(buffer, this.handle, true); break; case 2: Encoder.WriteBoolean(buffer, this.role, true); break; case 3: Encoder.WriteUByte(buffer, (byte)this.sndSettleMode); break; case 4: Encoder.WriteUByte(buffer, (byte)this.rcvSettleMode); break; case 5: Encoder.WriteObject(buffer, this.source); break; case 6: Encoder.WriteObject(buffer, this.target); break; case 7: Encoder.WriteMap(buffer, this.unsettled, true); break; case 8: Encoder.WriteBoolean(buffer, this.incompleteUnsettled, true); break; case 9: Encoder.WriteUInt(buffer, this.initialDeliveryCount, true); break; case 10: Encoder.WriteULong(buffer, this.maxMessageSize, true); break; case 11: Encoder.WriteObject(buffer, this.offeredCapabilities); break; case 12: Encoder.WriteObject(buffer, this.desiredCapabilities); break; case 13: Encoder.WriteMap(buffer, this.properties, true); break; default: Fx.Assert(false, "Invalid field index"); break; } }
public AuthenticationSchemesBindingParameter(AuthenticationSchemes authenticationSchemes) { Fx.Assert(authenticationSchemes != AuthenticationSchemes.None, "AuthenticationSchemesBindingParameter should not be added for AuthenticationSchemes.None."); AuthenticationSchemes = authenticationSchemes; }
// This happens only when the transaction under which the handle was bound is committed. internal bool TryCompleteBind(ref InstanceHandleReference reference, ref List <InstanceHandleReference> handlesPendingResolution, out InstanceHandle handleToFree) { Fx.Assert(reference != null, "Bind wasn't registered - RegisterStartBind must be called."); Fx.Assert(reference.InstanceHandle != null, "Cannot cancel and complete a bind."); Fx.Assert(reference.InstanceHandle.Version != -1, "Handle state must be set first."); Fx.Assert(object.ReferenceEquals(this, reference.InstanceHandle.Owner), "TryCompleteBind called on the wrong owner for a handle."); Fx.Assert(!(reference is LockResolutionMarker) || ((LockResolutionMarker)reference).NonConflicting, "How did a Version get set if we're still resolving."); handleToFree = null; lock (HandlesLock) { try { InstanceHandle existingHandle; if (BoundHandles.TryGetValue(reference.InstanceHandle.Id, out existingHandle)) { Fx.AssertAndFailFast(!object.ReferenceEquals(existingHandle, reference.InstanceHandle), "InstanceStore lock state is not correct."); if (existingHandle.Version <= 0 || reference.InstanceHandle.Version <= 0) { if (existingHandle.Version != 0 || reference.InstanceHandle.Version != 0) { throw Fx.Exception.AsError(new InvalidOperationException(SRCore.InvalidLockToken)); } reference.InstanceHandle.ConflictingHandle = existingHandle; return(false); } if (existingHandle.Version > reference.InstanceHandle.Version) { reference.InstanceHandle.ConflictingHandle = existingHandle; return(false); } if (existingHandle.Version < reference.InstanceHandle.Version) { existingHandle.ConflictingHandle = reference.InstanceHandle; handleToFree = existingHandle; BoundHandles[reference.InstanceHandle.Id] = reference.InstanceHandle; return(true); } if (existingHandle.Version == reference.InstanceHandle.Version) { // This could be a case of amnesia (backup / restore). throw Fx.Exception.AsError(new InvalidOperationException(SRCore.InstanceStoreBoundSameVersionTwice)); } throw Fx.AssertAndThrow("All cases covered above."); } else { BoundHandles.Add(reference.InstanceHandle.Id, reference.InstanceHandle); return(true); } } finally { CancelReference(ref reference, ref handlesPendingResolution); } } }
public void EndComplete(IAsyncResult result) { Fx.Assert(this.contextOwnedTransaction != null, "We must have a contextOwnedTransaction if we are calling End"); this.contextOwnedTransaction.EndCommit(result); }
internal void NotifyMarkerComplete(bool success) { Fx.Assert(InstanceHandle != null, "NotifyNonConflicting called on a cancelled LockResolutionMarker."); NonConflicting = success; IsComplete = true; }
internal void SetProperty(string name, object val) { Fx.Assert(null != this.wbemObject, name + " may not be available to WMI"); if (null != val) { WbemNative.CIMTYPE type = 0; if (val is DateTime) { val = ((DateTime)val).ToString("yyyyMMddhhmmss.ffffff", CultureInfo.InvariantCulture) + "+000"; } else if (val is TimeSpan) { TimeSpan ts = (TimeSpan)val; long microSeconds = (ts.Ticks % 1000) / 10; val = string.Format(CultureInfo.InvariantCulture, "{0:00000000}{1:00}{2:00}{3:00}.{4:000}{5:000}:000", new object[] { ts.Days, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds, microSeconds }); } else if (val is InstanceContext) { InstanceContext inst = (InstanceContext)val; val = inst.WbemObject; } else if (val is Array) { Array objs = (Array)val; if (objs.GetLength(0) > 0 && objs.GetValue(0) is InstanceContext) { WbemNative.IWbemClassObject[] insts = new WbemNative.IWbemClassObject[objs.GetLength(0)]; for (int i = 0; i < insts.Length; ++i) { insts[i] = ((InstanceContext)objs.GetValue(i)).WbemObject; } val = insts; } } else if (val is Int64) { val = ((Int64)val).ToString(CultureInfo.InvariantCulture); type = WbemNative.CIMTYPE.CIM_SINT64; } int hResult = this.wbemObject.Put(name, 0, ref val, (int)type); if ((int)WbemNative.WbemStatus.WBEM_E_TYPE_MISMATCH == hResult || (int)WbemNative.WbemStatus.WBEM_E_NOT_FOUND == hResult) { //This would be most likely a product System.Runtime.Diagnostics.EventLogEventId eventId; if ((int)WbemNative.WbemStatus.WBEM_E_TYPE_MISMATCH == hResult) { eventId = System.Runtime.Diagnostics.EventLogEventId.WmiAdminTypeMismatch; } else { eventId = System.Runtime.Diagnostics.EventLogEventId.WmiPropertyMissing; } DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)eventId, this.className, name, val.GetType().ToString()); } else { WbemException.ThrowIfFail(hResult); } } }
private void OnWrite(Task antecedant, object state) { Fx.Assert(writeResult != null, "StreamConnection: OnWrite called twice."); writeResult = antecedant; writeCallback(state); }
internal ClientRuntime(string contractName, string contractNamespace) : this(contractName, contractNamespace, new SharedRuntimeState(false)) { Fx.Assert(!shared.IsOnServer, "Client constructor called on server?"); }
public SecurityBindingElement CreateSecurityBindingElement(bool isSecureTransportMode, bool isReliableSession, MessageSecurityVersion version) { if (isReliableSession && !IsSecureConversationEnabled()) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SecureConversationRequiredByReliableSession))); } SecurityBindingElement result; bool isKerberosSelected = false; SecurityBindingElement oneShotSecurity; if (isSecureTransportMode) { switch (_clientCredentialType) { case MessageCredentialType.None: throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.ClientCredentialTypeMustBeSpecifiedForMixedMode))); case MessageCredentialType.UserName: oneShotSecurity = SecurityBindingElement.CreateUserNameOverTransportBindingElement(); break; case MessageCredentialType.Certificate: oneShotSecurity = SecurityBindingElement.CreateCertificateOverTransportBindingElement(); break; case MessageCredentialType.Windows: oneShotSecurity = SecurityBindingElement.CreateSspiNegotiationOverTransportBindingElement(true); break; //case MessageCredentialType.IssuedToken: // oneShotSecurity = SecurityBindingElement.CreateIssuedTokenOverTransportBindingElement(IssuedSecurityTokenParameters.CreateInfoCardParameters(new SecurityStandardsManager(new WSSecurityTokenSerializer(emitBspAttributes: true)), this.algorithmSuite)); // break; default: Fx.Assert("unknown ClientCredentialType"); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); } if (IsSecureConversationEnabled()) { result = SecurityBindingElement.CreateSecureConversationBindingElement(oneShotSecurity, true); } else { result = oneShotSecurity; } } else { throw new PlatformNotSupportedException(); //TODO //if (negotiateServiceCredential) //{ // switch (this.clientCredentialType) // { // case MessageCredentialType.None: // oneShotSecurity = SecurityBindingElement.CreateSslNegotiationBindingElement(false, true); // break; // case MessageCredentialType.UserName: // oneShotSecurity = SecurityBindingElement.CreateUserNameForSslBindingElement(true); // break; // case MessageCredentialType.Certificate: // oneShotSecurity = SecurityBindingElement.CreateSslNegotiationBindingElement(true, true); // break; // case MessageCredentialType.Windows: // oneShotSecurity = SecurityBindingElement.CreateSspiNegotiationBindingElement(true); // break; // case MessageCredentialType.IssuedToken: // oneShotSecurity = SecurityBindingElement.CreateIssuedTokenForSslBindingElement(IssuedSecurityTokenParameters.CreateInfoCardParameters(new SecurityStandardsManager(new WSSecurityTokenSerializer(emitBspAttributes: true)), this.algorithmSuite), true); // break; // default: // Fx.Assert("unknown ClientCredentialType"); // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); // } //} //else //{ // switch (this.clientCredentialType) // { // case MessageCredentialType.None: // oneShotSecurity = SecurityBindingElement.CreateAnonymousForCertificateBindingElement(); // break; // case MessageCredentialType.UserName: // oneShotSecurity = SecurityBindingElement.CreateUserNameForCertificateBindingElement(); // break; // case MessageCredentialType.Certificate: // oneShotSecurity = SecurityBindingElement.CreateMutualCertificateBindingElement(); // break; // case MessageCredentialType.Windows: // oneShotSecurity = SecurityBindingElement.CreateKerberosBindingElement(); // isKerberosSelected = true; // break; // case MessageCredentialType.IssuedToken: // oneShotSecurity = SecurityBindingElement.CreateIssuedTokenForCertificateBindingElement(IssuedSecurityTokenParameters.CreateInfoCardParameters(new SecurityStandardsManager(new WSSecurityTokenSerializer(emitBspAttributes: true)), this.algorithmSuite)); // break; // default: // Fx.Assert("unknown ClientCredentialType"); // throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); // } //} //if (IsSecureConversationEnabled()) //{ // result = SecurityBindingElement.CreateSecureConversationBindingElement(oneShotSecurity, true); //} //else //{ // result = oneShotSecurity; //} } // set the algorithm suite and issued token params if required if (WasAlgorithmSuiteSet || (!isKerberosSelected)) { result.DefaultAlgorithmSuite = oneShotSecurity.DefaultAlgorithmSuite = AlgorithmSuite; } else if (isKerberosSelected) { result.DefaultAlgorithmSuite = oneShotSecurity.DefaultAlgorithmSuite = SecurityAlgorithmSuite.KerberosDefault; } result.IncludeTimestamp = true; oneShotSecurity.MessageSecurityVersion = version; result.MessageSecurityVersion = version; if (!isReliableSession) { result.LocalServiceSettings.ReconnectTransportOnFailure = false; } else { result.LocalServiceSettings.ReconnectTransportOnFailure = true; } if (IsSecureConversationEnabled()) { oneShotSecurity.LocalServiceSettings.IssuedCookieLifetime = s_defaultServerIssuedTransitionTokenLifetime; //TODO SpNego when port, remove above and enable below. // issue the transition SCT for a short duration only // oneShotSecurity.LocalServiceSettings.IssuedCookieLifetime = SpnegoTokenAuthenticator.defaultServerIssuedTransitionTokenLifetime; } return(result); }
// Enter a state and push it onto the 'virtual callstack'. // Stackframe describing state to enter, along with the // locals in that state. internal void EnterState(int threadIndex, VirtualStackFrame stackFrame) { Fx.Assert(threadIndex < this.threads.Count, "Index out of range for thread"); Fx.Assert(this.threads[threadIndex] != null, "LogicalThread is null"); this.threads[threadIndex].EnterState(stackFrame); }
internal MessageRpc(RequestContext requestContext, Message request, DispatchOperationRuntime operation, ServiceChannel channel, ChannelHandler channelHandler, bool cleanThread, OperationContext operationContext, InstanceContext instanceContext, EventTraceActivity eventTraceActivity) { Fx.Assert((operationContext != null), "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), operationContext == null"); Fx.Assert(channelHandler != null, "System.ServiceModel.Dispatcher.MessageRpc.MessageRpc(), channelHandler == null"); Activity = null; EventTraceActivity = eventTraceActivity; AsyncResult = null; CanSendReply = true; Channel = channel; this.channelHandler = channelHandler; Correlation = EmptyArray<object>.Allocate(operation.Parent.CorrelationCount); DidDeserializeRequestBody = false; Error = null; ErrorProcessor = null; FaultInfo = new ErrorHandlerFaultInfo(request.Version.Addressing.DefaultFaultAction); HasSecurityContext = false; Instance = null; MessageRpcOwnsInstanceContextThrottle = false; NextProcessor = null; NotUnderstoodHeaders = null; Operation = operation; OperationContext = operationContext; IsPaused = false; ParametersDisposed = false; Request = request; RequestContext = requestContext; RequestContextThrewOnReply = false; SuccessfullySendReply = false; RequestVersion = request.Version; Reply = null; ReplyTimeoutHelper = new TimeoutHelper(); SecurityContext = null; InstanceContext = instanceContext; SuccessfullyBoundInstance = false; SuccessfullyIncrementedActivity = false; SuccessfullyLockedInstance = false; SwitchedThreads = !cleanThread; InputParameters = null; OutputParameters = null; ReturnParameter = null; _isInstanceContextSingleton = false; _invokeContinueGate = null; if (!operation.IsOneWay && !operation.Parent.ManualAddressing) { RequestID = request.Headers.MessageId; ReplyToInfo = new RequestReplyCorrelator.ReplyToInfo(request); } else { RequestID = null; ReplyToInfo = new RequestReplyCorrelator.ReplyToInfo(); } if (DiagnosticUtility.ShouldUseActivity) { Activity = TraceUtility.ExtractActivity(Request); } if (DiagnosticUtility.ShouldUseActivity || TraceUtility.ShouldPropagateActivity) { ResponseActivityId = ActivityIdHeader.ExtractActivityId(Request); } else { ResponseActivityId = Guid.Empty; } InvokeNotification = new MessageRpcInvokeNotification(Activity, this.channelHandler); if (EventTraceActivity == null && FxTrace.Trace.IsEnd2EndActivityTracingEnabled) { if (Request != null) { EventTraceActivity = EventTraceActivityHelper.TryExtractActivity(Request, true); } } }
// Pop the state most recently pushed by EnterState. internal void LeaveState(int threadIndex, State state) { Fx.Assert(threadIndex < this.threads.Count, "Index out of range for thread"); Fx.Assert(this.threads[threadIndex] != null, "LogicalThread is null"); this.threads[threadIndex].LeaveState(state); }
protected override Location <TResult> Execute(CodeActivityContext context) { Fx.Assert(_fieldInfo != null, "fieldInfo must not be null."); return(new FieldLocation(_fieldInfo, this.Operand.Get(context))); }
public void SetValue(PrefixHandleType type) { Fx.Assert(type != PrefixHandleType.Buffer, ""); this.type = type; }