void Container4() { //ReceiveActivity.ServiceOperationInfo //<snippet4> ReceiveActivity receiveQuoteFromShipper1 = new ReceiveActivity(); CodeActivity shipper1ShippingQuote = new CodeActivity(); ContextToken contextToken1 = new ContextToken(); ActivityBind activityBind1 = new ActivityBind(); WorkflowParameterBinding workflowParameterBinding1 = new WorkflowParameterBinding(); TypedOperationInfo typedOperationInfo1 = new TypedOperationInfo(); receiveQuoteFromShipper1.Activities.Add(shipper1ShippingQuote); contextToken1.Name = "Shipper1Context"; contextToken1.OwnerActivityName = "GetShippingQuotes"; receiveQuoteFromShipper1.ContextToken = contextToken1; receiveQuoteFromShipper1.Name = "receiveQuoteFromShipper1"; activityBind1.Name = "SupplierWorkflow"; activityBind1.Path = "quoteShipper1"; workflowParameterBinding1.ParameterName = "quote"; workflowParameterBinding1.SetBinding(WorkflowParameterBinding.ValueProperty, ((ActivityBind)(activityBind1))); receiveQuoteFromShipper1.ParameterBindings.Add(workflowParameterBinding1); typedOperationInfo1.ContractType = typeof(IShippingQuote); typedOperationInfo1.Name = "ShippingQuote"; receiveQuoteFromShipper1.ServiceOperationInfo = typedOperationInfo1; //</snippet4> }
private string GetClientId() { if (_queryParams != null && _queryParams.ContainsKey("clientId") && !string.IsNullOrEmpty(_queryParams?["clientId"])) { return(_queryParams["clientId"]); } else { var contextTokenParts = ContextToken?.Split('.'); if (contextTokenParts != null && contextTokenParts.Length > 1) { var mainPart = contextTokenParts[1]; try { var jwt = TokenHelper.Base64DecodeJwtToken(mainPart); var deserializer = new JavaScriptSerializer(); var tokenProperties = deserializer.Deserialize <Dictionary <string, string> >(jwt); if (tokenProperties.ContainsKey("aud")) { return(tokenProperties["aud"].Split('/')[0]); } } catch { // ignored } } } return(null); }
private static void PostSerialize(ref ObjectContext objectContext, ContextToken contextToken) { // Restore contexts that must be restored if (contextToken.NonIdentifiableItems) { objectContext.SerializerContext.Properties.Remove(CollectionWithIdsSerializerBase.NonIdentifiableCollectionItemsKey); } }
private static Asn1Message ParseApplicationMessage(Asn1Element element) { switch (element.ApplicationTag) { case 0: // SPNEGO InitialContextToken return(ContextToken.Parse(element)); } throw new InvalidDataException(); }
public static object Parse(ReadOnlyMemory <byte> data) { if (ParsedNonGssApiToken(data, out ContextToken token)) { return(token); } var gss = GssApiToken.Decode(data); return(ContextToken.Parse(gss)); }
private static ContextToken PreSerialize(ref ObjectContext objectContext) { var token = new ContextToken(); // Check if we enter a context where collection items are not identifiable anymore (see doc of the related attribute) if (objectContext.Descriptor.Type.GetCustomAttribute<NonIdentifiableCollectionItemsAttribute>(true) != null) { if (!objectContext.SerializerContext.Properties.ContainsKey(CollectionWithIdsSerializerBase.NonIdentifiableCollectionItemsKey)) { token.NonIdentifiableItems = true; objectContext.SerializerContext.Properties.Add(CollectionWithIdsSerializerBase.NonIdentifiableCollectionItemsKey, true); } } return token; }
private static ContextToken PreSerialize(ref ObjectContext objectContext) { var token = new ContextToken(); // Check if we enter a context where collection items are not identifiable anymore (see doc of the related attribute) if (objectContext.Descriptor.Type.GetCustomAttribute <NonIdentifiableCollectionItemsAttribute>(true) != null) { if (!objectContext.SerializerContext.Properties.ContainsKey(CollectionWithIdsSerializerBase.NonIdentifiableCollectionItemsKey)) { token.NonIdentifiableItems = true; objectContext.SerializerContext.Properties.Add(CollectionWithIdsSerializerBase.NonIdentifiableCollectionItemsKey, true); } } return(token); }
private static bool ParsedNonGssApiToken(ReadOnlyMemory <byte> data, out ContextToken token) { // // A caller may try and pass a token that isn't wrapped by GSS-API semantics // We should try and detect what it is and return that instead of treating // it like GSS data // // We'll check if it's NTLM, NegoEx, or Kerberos // Otherwise bail and try letting GssApiToken sort it out // // are we an NTLM token? if (NtlmMessage.CanReadNtlmMessage(data)) { token = new NtlmContextToken(data: data); return(true); } // are we a NegoEx token? if (NegotiateExtension.CanDecode(data)) { token = new NegoExContextToken(data); return(true); } // are we a Kerberos ticket? if (KrbApChoice.CanDecode(data)) { token = new KerberosContextToken(data: data); return(true); } // we don't know what we are. Maybe we're GSS so figure it out later. token = null; return(false); }
public AsteroidServer(NetDefinitions netdefs, Vector2 boundary, int port) { NetDefs = netdefs; Boundary = boundary; Server = new UDPServer(port); Server.Compression = NetworkCompression; MaxPlayers = 8; OutgoingPool = new OutgoingSyncPool(netdefs, 0); Physicals = new List <Physical>(); Projectiles = new List <Projectile>(); CollisionWorld = new VoltWorld(0, 1.0f); Clients = new List <RemoteClient>(); Context = new ContextToken(this); int k = 4; for (int i = 0; i < 30 * k; i++) { AddEntity(NewAsteroid(32)); } for (int i = 0; i < 40 * k; i++) { AddEntity(NewAsteroid(48)); } for (int i = 0; i < 10 * k; i++) { AddEntity(NewAsteroid(56)); } OutgoingPool.AddEntity(serverReport); LastTimestamp = 0; Random = new Random((int)System.DateTime.UtcNow.ToBinary()); }
private Token DeserializeNext( byte tokenCode = Byte.MaxValue ) { var tokenPosition = CodePosition; if( tokenCode == Byte.MaxValue ) { tokenCode = FixToken( Buffer.ReadByte() ); AlignSize( sizeof(byte) ); } Token tokenItem = null; if( tokenCode >= (byte)ExprToken.FirstNative ) { tokenItem = FindNativeTable( tokenCode ); } else if( tokenCode >= (byte)ExprToken.ExtendedNative ) { tokenItem = FindNativeTable( (tokenCode - (byte)ExprToken.ExtendedNative) << 8 | Buffer.ReadByte() ); AlignSize( sizeof(byte) ); } else switch( tokenCode ) { #region Cast case (byte)ExprToken.DynamicCast: tokenItem = new DynamicCastToken(); break; case (byte)ExprToken.MetaCast: tokenItem = new MetaCastToken(); break; case (byte)ExprToken.InterfaceCast: if( Buffer.Version < PrimitveCastVersion ) // UE1 { tokenItem = new IntToStringToken(); } else { tokenItem = new InterfaceCastToken(); } break; // Redefined, can be RotatorToVector!(UE1) case (byte)ExprToken.PrimitiveCast: if( Buffer.Version < PrimitveCastVersion ) // UE1 { tokenItem = new RotatorToVectorToken(); } else // UE2+ { // Next byte represents the CastToken! tokenCode = Buffer.ReadByte(); AlignSize( sizeof(byte) ); tokenItem = DeserializeCastToken( tokenCode ); //tokenitem = new PrimitiveCastToken(); } break; #endregion #region Context case (byte)ExprToken.ClassContext: tokenItem = new ClassContextToken(); break; case (byte)ExprToken.InterfaceContext: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new ByteToStringToken(); } else { tokenItem = new InterfaceContextToken(); } break; case (byte)ExprToken.Context: tokenItem = new ContextToken(); break; case (byte)ExprToken.StructMember: tokenItem = new StructMemberToken(); break; #endregion #region Assigns case (byte)ExprToken.Let: tokenItem = new LetToken(); break; case (byte)ExprToken.LetBool: tokenItem = new LetBoolToken(); break; case (byte)ExprToken.EndParmValue: tokenItem = new EndParmValueToken(); break; // Redefined, can be FloatToBool!(UE1) case (byte)ExprToken.LetDelegate: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new FloatToBoolToken(); } else { tokenItem = new LetDelegateToken(); } break; // Redefined, can be NameToBool!(UE1) case (byte)ExprToken.Conditional: tokenItem = new ConditionalToken(); break; case (byte)ExprToken.Eval: // case (byte)ExprToken.DynArrayFindStruct: case (byte)ExprToken.Conditional: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new NameToBoolToken(); } else if( Buffer.Version >= 300 ) { tokenItem = new DynamicArrayFindStructToken(); } else { tokenItem = new ConditionalToken(); } break; #endregion #region Jumps case (byte)ExprToken.Return: tokenItem = new ReturnToken(); break; case (byte)ExprToken.ReturnNothing: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new ByteToIntToken(); } // Definitely existed since GoW(490) else if( Buffer.Version > 420 && (DeserializedTokens.Count > 0 && !(DeserializedTokens[DeserializedTokens.Count - 1] is ReturnToken)) ) // Should only be done if the last token wasn't Return { tokenItem = new DynamicArrayInsertToken(); } else { tokenItem = new ReturnNothingToken(); } break; case (byte)ExprToken.GotoLabel: tokenItem = new GoToLabelToken(); break; case (byte)ExprToken.Jump: tokenItem = new JumpToken(); break; case (byte)ExprToken.JumpIfNot: tokenItem = new JumpIfNotToken(); break; case (byte)ExprToken.Switch: tokenItem = new SwitchToken(); break; case (byte)ExprToken.Case: tokenItem = new CaseToken(); break; case (byte)ExprToken.DynArrayIterator: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new RotatorToStringToken(); } else { tokenItem = new ArrayIteratorToken(); } break; case (byte)ExprToken.Iterator: tokenItem = new IteratorToken(); break; case (byte)ExprToken.IteratorNext: tokenItem = new IteratorNextToken(); break; case (byte)ExprToken.IteratorPop: tokenItem = new IteratorPopToken(); break; case (byte)ExprToken.FilterEditorOnly: tokenItem = new FilterEditorOnlyToken(); break; #endregion #region Variables case (byte)ExprToken.NativeParm: tokenItem = new NativeParameterToken(); break; // Referenced variables that are from this function e.g. Local and params case (byte)ExprToken.InstanceVariable: tokenItem = new InstanceVariableToken(); break; case (byte)ExprToken.LocalVariable: tokenItem = new LocalVariableToken(); break; case (byte)ExprToken.StateVariable: tokenItem = new StateVariableToken(); break; // Referenced variables that are default case (byte)ExprToken.UndefinedVariable: #if BORDERLANDS2 if( _Container.Package.Build == UnrealPackage.GameBuild.BuildName.Borderlands2 ) { tokenItem = new DynamicVariableToken(); break; } #endif tokenItem = new UndefinedVariableToken(); break; case (byte)ExprToken.DefaultVariable: tokenItem = new DefaultVariableToken(); break; // UE3+ case (byte)ExprToken.OutVariable: tokenItem = new OutVariableToken(); break; case (byte)ExprToken.BoolVariable: tokenItem = new BoolVariableToken(); break; // Redefined, can be FloatToInt!(UE1) case (byte)ExprToken.DelegateProperty: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new FloatToIntToken(); } else { tokenItem = new DelegatePropertyToken(); } break; case (byte)ExprToken.DefaultParmValue: if( Buffer.Version < PrimitveCastVersion ) // StringToInt { tokenItem = new StringToIntToken(); } else { tokenItem = new DefaultParameterToken(); } break; #endregion #region Misc // Redefined, can be BoolToFloat!(UE1) case (byte)ExprToken.DebugInfo: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new BoolToFloatToken(); } else { tokenItem = new DebugInfoToken(); } break; case (byte)ExprToken.Nothing: tokenItem = new NothingToken(); break; case (byte)ExprToken.EndFunctionParms: tokenItem = new EndFunctionParmsToken(); break; case (byte)ExprToken.IntZero: tokenItem = new IntZeroToken(); break; case (byte)ExprToken.IntOne: tokenItem = new IntOneToken(); break; case (byte)ExprToken.True: tokenItem = new TrueToken(); break; case (byte)ExprToken.False: tokenItem = new FalseToken(); break; case (byte)ExprToken.NoDelegate: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new IntToFloatToken(); } else { tokenItem = new NoDelegateToken(); } break; // No value passed to an optional parameter. case (byte)ExprToken.NoParm: tokenItem = new NoParmToken(); break; case (byte)ExprToken.NoObject: tokenItem = new NoObjectToken(); break; case (byte)ExprToken.Self: tokenItem = new SelfToken(); break; // End of state code. case (byte)ExprToken.Stop: tokenItem = new StopToken(); break; case (byte)ExprToken.Assert: tokenItem = new AssertToken(); break; case (byte)ExprToken.LabelTable: tokenItem = new LabelTableToken(); break; case (byte)ExprToken.EndOfScript: //CastToken.BoolToString: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new BoolToStringToken(); } else { tokenItem = new EndOfScriptToken(); } break; case (byte)ExprToken.Skip: tokenItem = new SkipToken(); break; case (byte)ExprToken.StructCmpEq: tokenItem = new StructCmpEqToken(); break; case (byte)ExprToken.StructCmpNE: tokenItem = new StructCmpNeToken(); break; case (byte)ExprToken.DelegateCmpEq: tokenItem = new DelegateCmpEqToken(); break; case (byte)ExprToken.DelegateFunctionCmpEq: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new IntToBoolToken(); } else { tokenItem = new DelegateFunctionCmpEqToken(); } break; case (byte)ExprToken.DelegateCmpNE: tokenItem = new DelegateCmpNEToken(); break; case (byte)ExprToken.DelegateFunctionCmpNE: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new IntToBoolToken(); } else { tokenItem = new DelegateFunctionCmpNEToken(); } break; case (byte)ExprToken.InstanceDelegate: tokenItem = new InstanceDelegateToken(); break; case (byte)ExprToken.EatString: tokenItem = new EatStringToken(); break; case (byte)ExprToken.New: tokenItem = new NewToken(); break; case (byte)ExprToken.FunctionEnd: // case (byte)ExprToken.DynArrayFind: if( Buffer.Version < 300 ) { tokenItem = new EndOfScriptToken(); } else { tokenItem = new DynamicArrayFindToken(); } break; case (byte)ExprToken.VarInt: case (byte)ExprToken.VarFloat: case (byte)ExprToken.VarByte: case (byte)ExprToken.VarBool: //case (byte)ExprToken.VarObject: // See UndefinedVariable if (_Container.Package.Build == UnrealPackage.GameBuild.BuildName.Mass_Effect) { // Don't know what this op code is for.... just know it takes two bytes. tokenItem = new MassEffectUnknownToken(); } else { tokenItem = new DynamicVariableToken(); } break; #endregion #region Constants case (byte)ExprToken.IntConst: tokenItem = new IntConstToken(); break; case (byte)ExprToken.ByteConst: tokenItem = new ByteConstToken(); break; case (byte)ExprToken.IntConstByte: tokenItem = new IntConstByteToken(); break; case (byte)ExprToken.FloatConst: tokenItem = new FloatConstToken(); break; // ClassConst? case (byte)ExprToken.ObjectConst: tokenItem = new ObjectConstToken(); break; case (byte)ExprToken.NameConst: tokenItem = new NameConstToken(); break; case (byte)ExprToken.StringConst: tokenItem = new StringConstToken(); break; case (byte)ExprToken.UniStringConst: tokenItem = new UniStringConstToken(); break; case (byte)ExprToken.RotatorConst: tokenItem = new RotatorConstToken(); break; case (byte)ExprToken.VectorConst: tokenItem = new VectorConstToken(); break; #endregion #region Functions case (byte)ExprToken.FinalFunction: tokenItem = new FinalFunctionToken(); break; case (byte)ExprToken.VirtualFunction: tokenItem = new VirtualFunctionToken(); break; case (byte)ExprToken.GlobalFunction: tokenItem = new GlobalFunctionToken(); break; // Redefined, can be FloatToByte!(UE1) case (byte)ExprToken.DelegateFunction: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new FloatToByteToken(); } else { tokenItem = new DelegateFunctionToken(); } break; #endregion #region Arrays case (byte)ExprToken.ArrayElement: tokenItem = new ArrayElementToken(); break; case (byte)ExprToken.DynArrayElement: tokenItem = new DynamicArrayElementToken(); break; case (byte)ExprToken.DynArrayLength: tokenItem = new DynamicArrayLengthToken(); break; case (byte)ExprToken.DynArrayInsert: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new BoolToByteToken(); } else { tokenItem = new DynamicArrayInsertToken(); } break; case (byte)ExprToken.DynArrayInsertItem: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new VectorToStringToken(); } else { tokenItem = new DynamicArrayInsertItemToken(); } break; // Redefined, can be BoolToInt!(UE1) case (byte)ExprToken.DynArrayRemove: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new BoolToIntToken(); } else { tokenItem = new DynamicArrayRemoveToken(); } break; case (byte)ExprToken.DynArrayRemoveItem: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new NameToStringToken(); } else { tokenItem = new DynamicArrayRemoveItemToken(); } break; case (byte)ExprToken.DynArrayAdd: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new FloatToStringToken(); } else { tokenItem = new DynamicArrayAddToken(); } break; case (byte)ExprToken.DynArrayAddItem: if( Buffer.Version < PrimitveCastVersion ) { tokenItem = new ObjectToStringToken(); } else { tokenItem = new DynamicArrayAddItemToken(); } break; case (byte)ExprToken.DynArraySort: tokenItem = new DynamicArraySortToken(); break; // See FunctionEnd and Eval /*case (byte)ExprToken.DynArrayFind: break; case (byte)ExprToken.DynArrayFindStruct: break;*/ #endregion default: { #region Casts if( Buffer.Version < PrimitveCastVersion ) { // No other token was matched. Check if it matches any of the CastTokens // We don't just use PrimitiveCast detection due compatible with UE1 games tokenItem = DeserializeCastToken( tokenCode ); } break; #endregion } } if( tokenItem == null ) { tokenItem = new UnknownExprToken(); } Console.Out.WriteLine("Token is: "+ tokenCode.ToString("X") + " type: " + tokenItem.GetType().Name + " pos: " + Buffer.Position); tokenItem.Decompiler = this; tokenItem.RepresentToken = tokenCode; tokenItem.Position = tokenPosition;// + (uint)Owner._ScriptOffset; tokenItem.StoragePosition = (uint)Buffer.Position - (uint)_Container.ScriptOffset - 1; // IMPORTANT:Add before deserialize, due the possibility that the tokenitem might deserialize other tokens as well. DeserializedTokens.Add( tokenItem ); tokenItem.Deserialize( Buffer ); // Includes all sizes of followed tokens as well! e.g. i = i + 1; is summed here but not i = i +1; (not>>)i ++; tokenItem.Size = (ushort)(CodePosition - tokenPosition); tokenItem.StorageSize = (ushort)((uint)Buffer.Position - (uint)_Container.ScriptOffset - tokenItem.StoragePosition); tokenItem.PostDeserialized(); return tokenItem; }
public KerberosRequest(byte[] data) { negotiate = MessageParser.ParseContext(data); }
public static void RegisterDecryptor(EncryptionType type, Func <KrbApReq, DecryptedData> func) { ContextToken.RegisterDecryptor(type, func); }