public LeadDetailsPage(IApp app, Platform platform) : base(app, platform, "Opportunity", "OPPORTUNITY") { if (OnAndroid) { ContactTab = x => x.Id("action_bar_container").Descendant().Text("Contact"); EditCompany = x => x.Marked("Company").Sibling(); EditIndustry = x => x.Class("android.widget.EditText").Index(1); EditSize = x => x.Marked("Size").Sibling(); EditStage = x => x.Class("android.widget.EditText").Index(3); Done = x => x.Marked("Save"); Save = x => x.Marked("Save"); ScrollPanel = x => x.Marked("customPanel"); OkButton = x => x.Marked("button1"); } if (OniOS) { ContactTab = x => x.Class("UITabBarButtonLabel").Text("Contact"); EditCompany = x => x.Class("UITextFieldLabel").Index(0); EditIndustry = x => x.Class("UITextFieldLabel").Index(1); EditSize = x => x.Marked("Size").Sibling(); EditStage = x => x.Class("UITextFieldLabel").Index(3); Done = x => x.Marked("DONE"); Save = x => x.Marked("Save"); DismissSelection = x => x.Marked("Done"); } }
public override void ProcessPrimitiveObject(ObjectInformation oi) { if (oi.customProperties.Count == 0) //No custom properties means a regular platform { Platform tempPlatform = new Platform(oi.width, oi.height, oi.position, oi.name); return; } else { switch (oi.customProperties[0].ToUpper()) { case "SLOPE": new Platform(oi.width, oi.height, oi.position, oi.name, true); return; case "INVERSLOPE": new Platform(oi.width, oi.height, oi.position, oi.name, false); return; case "PLAYER": new Player(oi.position, "PlayerOne"); break; } } }
public static string PlatformToString(Platform platformToConvert) { switch (platformToConvert) { case Platform.Steam: { return "Steam"; } case Platform.Pirate: { return "Pirate"; } case Platform.Windows: { return "Windows"; } case Platform.Battlenet: { return "Battle.net"; } default: { return ""; } } }
public InfoService (Platform platform, VLogger logger) { this.platform = platform; this.logger = logger; string homeIdPart = string.Empty; //if (HomeOS.Shared.Globals.HomeId != null) //{ // homeIdPart = "/" + HomeOS.Shared.Globals.HomeId; //} host = new ServiceHost(this, new Uri(HomeOS.Hub.Common.Constants.InfoServiceAddress + homeIdPart)); host.AddServiceEndpoint(typeof(IHomeOSInfo), new WebHttpBinding(), "").Behaviors.Add(new System.ServiceModel.Description.WebHttpBehavior()); var smb = new System.ServiceModel.Description.ServiceMetadataBehavior(); smb.HttpGetEnabled = true; host.Description.Behaviors.Add(smb); try { host.Open(); } catch (Exception e) { logger.Log("Could not open the service host: " + e.Message + @" Possible issues: 1) are you running the command prompt / Visual Studio in administrator mode? 2) is another instance of Platform running? 3) is a local copy of Gatekeeper running? 4) is another process occupying the InfoServicePort (51430)?"); throw e; } }
public ExePackLoader(IServiceProvider services, string filename, byte[] imgRaw) : base(services, filename, imgRaw) { arch = new IntelArchitecture(ProcessorMode.Real); platform = new MsdosPlatform(Services, arch); var exe = new ExeImageLoader(services, filename, imgRaw); this.exeHdrSize = (uint)(exe.e_cparHeader * 0x10U); this.hdrOffset = (uint)(exe.e_cparHeader + exe.e_cs) * 0x10U; ImageReader rdr = new LeImageReader(RawImage, hdrOffset); this.ip = rdr.ReadLeUInt16(); this.cs = rdr.ReadLeUInt16(); rdr.ReadLeUInt16(); this.cbExepackHeader = rdr.ReadLeUInt16(); this.sp = rdr.ReadLeUInt16(); this.ss = rdr.ReadLeUInt16(); this.cpUncompressed = rdr.ReadLeUInt16(); int offset = ExePackHeaderOffset(exe); if (LoadedImage.CompareArrays(imgRaw, offset, signature, signature.Length)) { relocationsOffset = 0x012D; } else if (LoadedImage.CompareArrays(imgRaw, offset, signature2, signature2.Length)) { relocationsOffset = 0x0125; } else throw new ApplicationException("Not a recognized EXEPACK image."); }
public void Setup() { gameId = new Guid("44B0752E-998B-466A-AAAD-3ED535BA3559"); GameSKUId = new Guid("3FE5BFCF-0A01-4EC2-A662-ADA08A2C34D2"); game = new Game { Id = gameId, Name = "A game" }; ps4Platform = new Platform { PlatformCode = "PS4", PlatformName = "Playstation 4" }; veilCompany = new Company() { Id = new Guid("B4FDA176-1EA6-469A-BB02-75125D811ED4"), Name = "Veil" }; physicalGameProduct = new PhysicalGameProduct { Id = new Guid("E7746CD1-106E-4622-BC10-E13CCCCA7AC9"), GameId = game.Id }; downloadGameProduct = new DownloadGameProduct { Id = new Guid("2A1474A0-7ABA-41D6-BBD1-2DF28F43786E"), GameId = game.Id }; }
public Program(LoadedImage image, ImageMap imageMap, IProcessorArchitecture arch, Platform platform) : this() { this.Image = image; this.ImageMap = imageMap; this.Architecture = arch; this.Platform = platform; }
public ActionResult Index() { string initialState = SessionHelper.Get("state").ToString(); string initialRedirectUri = SessionHelper.Get("redirect_uri").ToString(); string code = Request.QueryString["code"]; string state = Request.QueryString["state"]; TokenResponseModel tokenResponseModel = null; if (state.Trim() == initialState.Trim()) { Platform = new SDKModel().GenerateSDK().GetPlatform(); var response = Platform.AuthorizeByAuthCode("authorization_code", code, initialRedirectUri); JToken token = JObject.Parse(response.GetBody()); tokenResponseModel = new TokenResponseModel() { AccessToken = (string)token.SelectToken("access_token"), ExpireIn = (string)token.SelectToken("expires_in"), RefreshToken = (string)token.SelectToken("refresh_token"), RefreshToken_ExpireIn = (string)token.SelectToken("refresh_token_expires_in"), Scope = (string)token.SelectToken("scope"), TokenType = (string)token.SelectToken("token_type"), OwnerId = (string)token.SelectToken("owner_id"), EndpointId = (string)token.SelectToken("endpoint_id") }; } return View(tokenResponseModel != null ? tokenResponseModel : null); }
public SystemService Build(Platform platform) { SystemService svc = new SystemService(); svc.Name = Name; svc.SyscallInfo = new SyscallInfo(); svc.SyscallInfo.Vector = Convert.ToInt32(SyscallInfo.Vector, 16); if (SyscallInfo.RegisterValues != null) { svc.SyscallInfo.RegisterValues = new RegValue[SyscallInfo.RegisterValues.Length]; for (int i = 0; i < SyscallInfo.RegisterValues.Length; ++i) { svc.SyscallInfo.RegisterValues[i] = new RegValue { Register = platform.Architecture.GetRegister(SyscallInfo.RegisterValues[i].Register), Value = Convert.ToInt32(SyscallInfo.RegisterValues[i].Value, 16), }; } } else { svc.SyscallInfo.RegisterValues = new RegValue[0]; } TypeLibraryLoader loader = new TypeLibraryLoader(platform, true); var sser = platform.CreateProcedureSerializer(loader, "stdapi"); svc.Signature = sser.Deserialize(Signature, platform.Architecture.CreateFrame()); svc.Characteristics = Characteristics != null ? Characteristics : DefaultProcedureCharacteristics.Instance; return svc; }
// POST: odata/PlatformsImporter public async Task<IHttpActionResult> Post(Platform platform) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Platforms.Add(platform); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (PlatformExists(platform.PlatformId)) { return Conflict(); } else { throw; } } return Created(platform); }
public static void Main(string[] args) { // setup test data var PlatformSet = new HashSet<Platform>(); Platform Platform0; PlatformSet.Add(Platform0 = new Platform()); var ManSet = new HashSet<Man>(); Man Man0; ManSet.Add(Man0 = new Man()); Man Man1; ManSet.Add(Man1 = new Man()); Man0.ceiling = Platform0; Man1.ceiling = Platform0; Man0.floor = Platform0; Man1.floor = Platform0; var DateSet = new HashSet<Date>(); var PersonSet = new HashSet<Person>(); Eve Eve0; PersonSet.Add(Eve0 = Eve.Instance); var WomanSet = new HashSet<Woman>(); WomanSet.Add(Eve0); var EveSet = new HashSet<Eve>(); EveSet.Add(Eve0); // check test data Contract.Assert(Contract.ForAll(ManSet, m => ManSet.Where(n => FuncClass.Above(m, n)).Count() == 1), "BelowToo"); }
void defineTargetPlatform() { if (platformTargetCombo.Items.Count > 0) TargetPlatform = new Platform(platformTargetCombo.SelectedItem.ToString(), GameVersion.RS2014.ToString()); else TargetPlatform = new Platform(GamePlatform.None, GameVersion.None); }
public LzExeUnpacker(IServiceProvider services, ExeImageLoader exe, string filename, byte [] rawImg) : base(services, filename, rawImg) { this.arch = new IntelArchitecture(ProcessorMode.Real); this.platform = new MsdosPlatform(services, arch); Validate(exe); }
public DataTypeBuilder(TypeFactory factory, ITypeStore store, Platform platform) { this.store = store; this.factory = factory; this.unifier = new DataTypeBuilderUnifier(factory, store); this.platform = platform; }
void defineSourcePlatform() { if (platformSourceCombo.Items.Count > 0) SourcePlatform = new Platform(platformSourceCombo.SelectedItem.ToString(), GameVersion.RS2014.ToString()); else SourcePlatform = new Platform(GamePlatform.None, GameVersion.None); }
public static Platform getInstance() { if (instance == null){ instance = new Platform(); } return instance; }
public ItemCatalog(ItemData[] items_data) { _items = new Dictionary<ulong, Item>(items_data.GetLength(0) * 2); foreach (ItemData itemData in items_data) { Item item; FileStream textureStream = new FileStream(Environment.SpecialFolder.Resources + "\\Custom\\" + itemData.UniversalTexture, FileMode.Open); Texture2D universalTexture = Texture2D.FromStream(Game.GraphicsInstance.GraphicsDevice, textureStream); switch (itemData.ClassType) { case "Teraform.Platform": item = new Platform(new Point(0, 0), universalTexture, Item.ITEM_STATE.IN_INVENTORY); break; case "Teraform.Block": item = new Block(new Point(0,0), universalTexture, Item.ITEM_STATE.IN_INVENTORY); break; default: throw new NotSupportedException(string.Concat("Error, item type ", itemData.ClassType ," not recognized; check the world\'s .xml file")); } item._itemId = itemData.Id; item._itemName = itemData.Name; _items.Add(itemData.Id, item); } }
void CheckForDownfall(Platform platform) { var nextRectangle = new Rectangle(0,0,0,0); Rectangle pr; if (CurrentMoveDirection == MoveDirection.Right) { nextRectangle = new Rectangle(PositionRectangle.X + PositionRectangle.Width, PositionRectangle.Y, PositionRectangle.Width, PositionRectangle.Height); pr = new Rectangle(platform.PositionRectangle.X + platform.PositionRectangle.Width, platform.PositionRectangle.Y, platform.PositionRectangle.Width, platform.PositionRectangle.Height); } else if (CurrentMoveDirection == MoveDirection.Left) { nextRectangle = new Rectangle(PositionRectangle.X - PositionRectangle.Width, PositionRectangle.Y, PositionRectangle.Width, PositionRectangle.Height); } /* var cha = Game.Components.Where(c => c is Platform) .Cast<Platform>() .Where(p => p.PositionRectangle.Intersects(nextRectangle)); if (cha.Count() < 0) { if (CurrentMoveDirection == MoveDirection.Left) { CurrentMoveDirection = MoveDirection.Right; isBanLeft = true; } if (CurrentMoveDirection == MoveDirection.Right) { CurrentMoveDirection = MoveDirection.Left; } }*/ }
/// <summary> /// Constructs the arena. Also constructs several platforms and physics elements /// which need to get added to the EntityManager and PhysicsSimulator. /// </summary> /// <param name="entityManager"></param> /// <param name="physicsSimulator"></param> public SplitBaseArena(EntityManager entityManager, PhysicsSimulator physicsSimulator) { // Create the platforms. float focus = 15.0f; Platform leftGround = new Platform(new Vector3(-focus, 0, 0), 22.0f, 2.0f, 5.0f); Platform rightGround = new Platform(new Vector3(focus, 0, 0), 22.0f, 2.0f, 5.0f); Platforms.Add(leftGround); entityManager.AddEntity(leftGround); physicsSimulator.AddPhysicsEntity(leftGround.GetBox()); Platforms.Add(rightGround); entityManager.AddEntity(rightGround); physicsSimulator.AddPhysicsEntity(rightGround.GetBox()); // Create the Spawn Positions spawnPositions = new List<Vector3>(); spawnPositions.Add(new Vector3(-15, 10, 0)); spawnPositions.Add(new Vector3(-5, 15, 0)); spawnPositions.Add(new Vector3(5, 15, 0)); spawnPositions.Add(new Vector3(15, 10, 0)); // Create the Bounding box. boundingBox = new BoundingBox(new Vector3(-70, -20, -20), new Vector3(70, 60, 20)); }
public Level(Texture2D background, Platform[] platform, Door d, Player p) { Background = background; platforms = platform; door = d; player = p; }
internal Device(Platform platform, IntPtr deviceID) { Platform = platform; DeviceID = deviceID; InitializeExtensionHashSet(); }
public ConfigUpdater(Configuration config, VLogger log, int frequency, Delegate method, Platform platform) { this.config = config; this.logger = log; this.frequency = frequency; this.methodToInvoke = method; this.platform = platform; tcb = ConfigSync; timer = new Timer(tcb, null, 500, frequency); if (System.IO.Directory.Exists(temporaryZipLocation)) // creating temporary directory location for downloading and holding zips Utils.CleanDirectory(logger, temporaryZipLocation); Utils.CreateDirectory(logger, temporaryZipLocation); this.status = new UpdateStatus(this.frequency); ConfigUpdaterWebService webService = new ConfigUpdaterWebService(logger, this); string homeIdPart = ""; if (!string.IsNullOrWhiteSpace(Settings.HomeId)) homeIdPart = "/" + Settings.HomeId; string url = Constants.InfoServiceAddress + homeIdPart + "/config"; serviceHost = ConfigUpdaterWebService.CreateServiceHost(webService, new Uri(url)); serviceHost.Open(); Utils.structuredLog(logger, "I", "ConfigUpdaterWebService initiated at " + url); }
static void ChangeAniso(int newLevel, Platform somePlatform = Platform.Default) { Debug.Log(System.String.Format("{0} Set AnisoLevel '{2}' @ {1} platform", logTitle, somePlatform, newLevel)); TextureImportParams tiParams = new TextureImportParams(Actions.SetAniso, somePlatform); tiParams.anisoLevel = newLevel; SelectedChangeAnyPlatformSettings(tiParams); }
public SceneManager(Platform platform, Engine engine, Scene startScene) { this.platform = platform; this.engine = engine; nextScene = startScene; sceneRenderer = new SceneRenderer(platform); }
// move the inner level into the 'ring' of outer level // NOTE: called when the player enters the inner level public void changeRing() { if(camObject == null) camObject = GameObject.Find("Menu Camera").GetComponent<CameraScript>(); else if(!plyr.rigidbody2D.isKinematic) camObject.jiggle = true; if (outer == null) { // there should be one and only one ring now outer = GameObject.Find("Platform"); Platform plat = outer.GetComponent<Platform>(); plat.ratio = platformRatio; outerPlatform = plat; } else { levelCount++; //if(levelCount%5==0) plyr.IncreaseJumps(levelCount); levelText.setValue (levelCount); Platform plat=outer.GetComponent<Platform>(); plat.die(); outer = inner; inner = null; outerPlatform = outer.GetComponent<Platform>(); } }
public Engine(Platform platform) { this.Assets = new Assets (platform); this.InputEventSystem = new InputEventSystem (platform); this.DebugRenderer = new DebugRenderer (platform); this.PrimitiveRenderer = new PrimitiveRenderer (platform); }
public HeartbeatService(Platform platform, VLogger log) { this.platform = platform; this.logger = log; this.tcb = SendHeartbeat; this.sequenceNumber = 0; try { this.uri = new Uri("https://" + GetHeartbeatServiceHostString() + ":" + Constants.HeartbeatServiceSecurePort + "/" + Constants.HeartbeatServiceWcfListenerEndPointUrlSuffix); this.heartbeatIntervalMins = Settings.HeartbeatIntervalMins; if (this.heartbeatIntervalMins < Constants.MinHeartbeatIntervalInMins) this.heartbeatIntervalMins = Constants.MinHeartbeatIntervalInMins; if (this.heartbeatIntervalMins > Constants.MaxHeartbeatIntervalInMins) this.heartbeatIntervalMins = Constants.MaxHeartbeatIntervalInMins; this.perfCountPercentProcTime = new PerformanceCounter("Process", "% Processor Time", Process.GetCurrentProcess().ProcessName, true); this.perfCountWorkingSet = new PerformanceCounter("Process", "Working Set", Process.GetCurrentProcess().ProcessName, true); } catch (Exception e) { logger.Log("Platform failed failed to construct heartbeat service , Exception={0}", e.Message); } }
public void SetUp() { var appKey = ""; var appSecret = ""; var password = ""; if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APP_KEY"))) { appKey = Environment.GetEnvironmentVariable("APP_KEY"); } if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APP_SECRET"))) { appSecret = Environment.GetEnvironmentVariable("APP_SECRET"); } if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("USER_NAME"))) { UserName = Environment.GetEnvironmentVariable("USER_NAME"); ToPhone = UserName; } if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("PASSWORD"))) { password = Environment.GetEnvironmentVariable("PASSWORD"); } RingCentralClient = new RingCentral.SDK.SDK(appKey, appSecret, ApiEndPoint,"C Sharp Test Suite", "1.0.0"); Platform = RingCentralClient.GetPlatform(); Platform._client = new HttpClient(MockResponseHandler) { BaseAddress = new Uri(ApiEndPoint) }; AuthResult = Platform.Authorize(UserName, Extension, password, true); }
public Mandelbrot( Platform platform, int width, int height ) { openCLPlatform = platform; openCLDevices = openCLPlatform.QueryDevices(DeviceType.ALL); openCLContext = openCLPlatform.CreateDefaultContext(); openCLCQ = openCLContext.CreateCommandQueue(openCLDevices[0], CommandQueueProperties.PROFILING_ENABLE); mandelBrotProgram = openCLContext.CreateProgramWithSource(File.ReadAllText("Mandelbrot.cl")); try { mandelBrotProgram.Build(); } catch (OpenCLException) { string buildLog = mandelBrotProgram.GetBuildLog(openCLDevices[0]); MessageBox.Show(buildLog,"Build error(64 bit debug sessions in vs2008 always fail like this - debug in 32 bit or use vs2010)"); Application.Exit(); } mandelbrotKernel = mandelBrotProgram.CreateKernel("Mandelbrot"); Left = -2.0f; Top = 2.0f; Right = 2.0f; Bottom = -2.0f; BitmapWidth = width; BitmapHeight = height; mandelbrotMemBuffer = openCLContext.CreateBuffer((MemFlags)((long)MemFlags.WRITE_ONLY), width*height*4, IntPtr.Zero); }
public static IApp StartApp(Platform platform) { // TODO: If the iOS or Android app being tested is included in the solution // then open the Unit Tests window, right click Test Apps, select Add App Project // and select the app projects that should be tested. // // The iOS project should have the Xamarin.TestCloud.Agent NuGet package // installed. To start the Test Cloud Agent the following code should be // added to the FinishedLaunching method of the AppDelegate: // // #if ENABLE_TEST_CLOUD // Xamarin.Calabash.Start(); // #endif if(platform == Platform.Android) { return ConfigureApp .Android // TODO: Update this path to point to your Android app and uncomment the // code if the app is not included in the solution. //.ApkFile ("../../../Droid/bin/Debug/xamarinforms.apk") .StartApp(); } return ConfigureApp .iOS // TODO: Update this path to point to your iOS app and uncomment the // code if the app is not included in the solution. //.AppBundle ("../../../iOS/bin/iPhoneSimulator/Debug/XamarinForms.iOS.app") //.DeviceIdentifier("F2CA162A-15A5-4023-B97A-427A2A9B59B7") //.CodesignIdentity("iPhone Developer: Rob DeRosa (VH66B6QF79)") .StartApp(); }
public static Platform ToMacArch(this Platform platform) { return(platform & Platform.Mac_Arch); }
public static bool IsIos(this Platform platform) { return(ToIosVersion(platform) != Platform.None); }
public static bool IsMac(this Platform platform) { return(ToMacVersion(platform) != Platform.None); }
public static int CompareIosVersion(this Platform a, Platform b) { return(((uint)ToIosVersion(a)).CompareTo((uint)ToIosVersion(b))); }
public static int CompareMacVersion(this Platform a, Platform b) { return(((ulong)ToMacVersion(a)).CompareTo((ulong)ToMacVersion(b))); }
public static int CompareIos(this Platform a, Platform b) { return(CompareIosVersion(a, b)); }
public static Platform ToIosArch(this Platform platform) { return(platform & Platform.iOS_Arch); }
public static Platform ToIosVersion(this Platform platform) { return(platform & Platform.iOS_Version); }
public static Platform ToVersion(this Platform platform) { return(platform & ~(Platform.Mac_Arch | Platform.iOS_Arch)); }
public static Platform ToArch(this Platform platform) { return(platform & (Platform.Mac_Arch | Platform.iOS_Arch)); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="platform">The target platform.</param> public ColorfulConsoleWriter(Platform platform) : this(platform, ColorfulConsoleWriter.GetDefaultColorSchemeConfig(MonitorColorScheme.AutoDetect)) { }
public static Platform ToMacVersion(this Platform platform) { return(platform & Platform.Mac_Version); }
private void UnArchiveSpecials(World world) { var thinkers = world.Thinkers; var sa = world.SectorAction; // Read in saved thinkers. while (true) { var tclass = (SpecialClass)this.reader.ReadByte(); switch (tclass) { case SpecialClass.EndSpecials: // End of list. return; case SpecialClass.Ceiling: this.PadPointer(); var ceiling = new CeilingMove(world); this.reader.BaseStream.Position += 8; ceiling.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); ceiling.Type = (CeilingMoveType)this.reader.ReadInt32(); ceiling.Sector = world.Map.Sectors[this.reader.ReadInt32()]; ceiling.Sector.SpecialData = ceiling; ceiling.BottomHeight = new Fixed(this.reader.ReadInt32()); ceiling.TopHeight = new Fixed(this.reader.ReadInt32()); ceiling.Speed = new Fixed(this.reader.ReadInt32()); ceiling.Crush = this.reader.ReadInt32() != 0; ceiling.Direction = this.reader.ReadInt32(); ceiling.Tag = this.reader.ReadInt32(); ceiling.OldDirection = this.reader.ReadInt32(); thinkers.Add(ceiling); sa.AddActiveCeiling(ceiling); break; case SpecialClass.Door: this.PadPointer(); var door = new VerticalDoor(world); this.reader.BaseStream.Position += 8; door.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); door.Type = (VerticalDoorType)this.reader.ReadInt32(); door.Sector = world.Map.Sectors[this.reader.ReadInt32()]; door.Sector.SpecialData = door; door.TopHeight = new Fixed(this.reader.ReadInt32()); door.Speed = new Fixed(this.reader.ReadInt32()); door.Direction = this.reader.ReadInt32(); door.TopWait = this.reader.ReadInt32(); door.TopCountDown = this.reader.ReadInt32(); thinkers.Add(door); break; case SpecialClass.Floor: this.PadPointer(); var floor = new FloorMove(world); this.reader.BaseStream.Position += 8; floor.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); floor.Type = (FloorMoveType)this.reader.ReadInt32(); floor.Crush = this.reader.ReadInt32() != 0; floor.Sector = world.Map.Sectors[this.reader.ReadInt32()]; floor.Sector.SpecialData = floor; floor.Direction = this.reader.ReadInt32(); floor.NewSpecial = (SectorSpecial)this.reader.ReadInt32(); floor.Texture = this.reader.ReadInt32(); floor.FloorDestHeight = new Fixed(this.reader.ReadInt32()); floor.Speed = new Fixed(this.reader.ReadInt32()); thinkers.Add(floor); break; case SpecialClass.Plat: this.PadPointer(); var plat = new Platform(world); this.reader.BaseStream.Position += 8; plat.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); plat.Sector = world.Map.Sectors[this.reader.ReadInt32()]; plat.Sector.SpecialData = plat; plat.Speed = new Fixed(this.reader.ReadInt32()); plat.Low = new Fixed(this.reader.ReadInt32()); plat.High = new Fixed(this.reader.ReadInt32()); plat.Wait = this.reader.ReadInt32(); plat.Count = this.reader.ReadInt32(); plat.Status = (PlatformState)this.reader.ReadInt32(); plat.OldStatus = (PlatformState)this.reader.ReadInt32(); plat.Crush = this.reader.ReadInt32() != 0; plat.Tag = this.reader.ReadInt32(); plat.Type = (PlatformType)this.reader.ReadInt32(); thinkers.Add(plat); sa.AddActivePlatform(plat); break; case SpecialClass.Flash: this.PadPointer(); var flash = new LightFlash(world); this.reader.BaseStream.Position += 8; flash.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); flash.Sector = world.Map.Sectors[this.reader.ReadInt32()]; flash.Count = this.reader.ReadInt32(); flash.MaxLight = this.reader.ReadInt32(); flash.MinLight = this.reader.ReadInt32(); flash.MaxTime = this.reader.ReadInt32(); flash.MinTime = this.reader.ReadInt32(); thinkers.Add(flash); break; case SpecialClass.Strobe: this.PadPointer(); var strobe = new StrobeFlash(world); this.reader.BaseStream.Position += 8; strobe.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); strobe.Sector = world.Map.Sectors[this.reader.ReadInt32()]; strobe.Count = this.reader.ReadInt32(); strobe.MinLight = this.reader.ReadInt32(); strobe.MaxLight = this.reader.ReadInt32(); strobe.DarkTime = this.reader.ReadInt32(); strobe.BrightTime = this.reader.ReadInt32(); thinkers.Add(strobe); break; case SpecialClass.Glow: this.PadPointer(); var glow = new GlowingLight(world); this.reader.BaseStream.Position += 8; glow.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32()); glow.Sector = world.Map.Sectors[this.reader.ReadInt32()]; glow.MinLight = this.reader.ReadInt32(); glow.MaxLight = this.reader.ReadInt32(); glow.Direction = this.reader.ReadInt32(); thinkers.Add(glow); break; default: throw new Exception("Unknown special in savegame!"); } } }
public static bool IsValid(this Platform platform) { #pragma warning disable 0618 switch (ToMacVersion(platform)) { case Platform.None: #if !XAMCORE_2_0 case Platform.Mac: #endif case Platform.Mac_Version: case Platform.Mac_10_0: case Platform.Mac_10_1: case Platform.Mac_10_2: case Platform.Mac_10_3: case Platform.Mac_10_4: case Platform.Mac_10_5: case Platform.Mac_10_6: case Platform.Mac_10_7: case Platform.Mac_10_8: case Platform.Mac_10_9: case Platform.Mac_10_10: case Platform.Mac_10_10_3: case Platform.Mac_10_11: case Platform.Mac_10_12: break; default: return(false); } switch (ToIosVersion(platform)) { case Platform.None: #if !XAMCORE_2_0 case Platform.iOS: #endif case Platform.iOS_Version: case Platform.iOS_2_0: case Platform.iOS_2_2: case Platform.iOS_3_0: case Platform.iOS_3_1: case Platform.iOS_3_2: case Platform.iOS_4_0: case Platform.iOS_4_1: case Platform.iOS_4_2: case Platform.iOS_4_3: case Platform.iOS_5_0: case Platform.iOS_5_1: case Platform.iOS_6_0: case Platform.iOS_6_1: case Platform.iOS_7_0: case Platform.iOS_7_1: case Platform.iOS_8_0: case Platform.iOS_8_1: case Platform.iOS_8_2: case Platform.iOS_8_3: case Platform.iOS_8_4: case Platform.iOS_9_0: case Platform.iOS_9_1: case Platform.iOS_9_2: break; default: return(false); } return(true); #pragma warning restore 0618 }
public override void Close() { Platform.Dispose(stream); base.Close(); }
protected internal Asn1Set( int capacity) { _set = Platform.CreateArrayList(capacity); }
void ShowDownloadDialog() { getStatusText = () => "Fetching list of mirrors..."; progressBar.Indeterminate = true; var retryButton = panel.Get <ButtonWidget>("RETRY_BUTTON"); retryButton.IsVisible = () => false; var cancelButton = panel.Get <ButtonWidget>("CANCEL_BUTTON"); var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); Action deleteTempFile = () => { Log.Write("install", "Deleting temporary file " + file); File.Delete(file); }; Action <DownloadProgressChangedEventArgs> onDownloadProgress = i => { var dataReceived = 0.0f; var dataTotal = 0.0f; var mag = 0; var dataSuffix = ""; if (i.TotalBytesToReceive < 0) { dataTotal = float.NaN; dataReceived = i.BytesReceived; dataSuffix = SizeSuffixes[0]; } else { mag = (int)Math.Log(i.TotalBytesToReceive, 1024); dataTotal = i.TotalBytesToReceive / (float)(1L << (mag * 10)); dataReceived = i.BytesReceived / (float)(1L << (mag * 10)); dataSuffix = SizeSuffixes[mag]; } progressBar.Indeterminate = false; progressBar.Percentage = i.ProgressPercentage; getStatusText = () => "Downloading from {4} {1:0.00}/{2:0.00} {3} ({0}%)".F(i.ProgressPercentage, dataReceived, dataTotal, dataSuffix, downloadHost ?? "unknown host"); }; Action <string> onExtractProgress = s => Game.RunAfterTick(() => getStatusText = () => s); Action <string> onError = s => Game.RunAfterTick(() => { Log.Write("install", "Download failed: " + s); progressBar.Indeterminate = false; progressBar.Percentage = 100; getStatusText = () => "Error: " + s; retryButton.IsVisible = () => true; cancelButton.OnClick = Ui.CloseWindow; }); Action <AsyncCompletedEventArgs> onDownloadComplete = i => { if (i.Cancelled) { deleteTempFile(); Game.RunAfterTick(Ui.CloseWindow); return; } if (i.Error != null) { deleteTempFile(); onError(Download.FormatErrorMessage(i.Error)); return; } // Automatically extract getStatusText = () => "Extracting..."; progressBar.Indeterminate = true; var extracted = new List <string>(); try { using (var stream = File.OpenRead(file)) using (var z = new ZipFile(stream)) { foreach (var kv in download.Extract) { var entry = z.GetEntry(kv.Value); if (entry == null || !entry.IsFile) { continue; } onExtractProgress("Extracting " + entry.Name); Log.Write("install", "Extracting " + entry.Name); var targetPath = Platform.ResolvePath(kv.Key); Directory.CreateDirectory(Path.GetDirectoryName(targetPath)); extracted.Add(targetPath); using (var zz = z.GetInputStream(entry)) using (var f = File.Create(targetPath)) zz.CopyTo(f); } z.Close(); } Game.RunAfterTick(() => { Ui.CloseWindow(); onSuccess(); }); } catch (Exception e) { Log.Write("install", "Archive extraction failed: " + e.ToString()); foreach (var f in extracted) { Log.Write("install", "Deleting " + f); File.Delete(f); } onError("Archive extraction failed"); } finally { deleteTempFile(); } }; Action <string> downloadUrl = url => { Log.Write("install", "Downloading " + url); downloadHost = new Uri(url).Host; var dl = new Download(url, file, onDownloadProgress, onDownloadComplete); cancelButton.OnClick = dl.CancelAsync; retryButton.OnClick = ShowDownloadDialog; }; if (download.MirrorList != null) { Log.Write("install", "Fetching mirrors from " + download.MirrorList); Action <DownloadDataCompletedEventArgs> onFetchMirrorsComplete = i => { progressBar.Indeterminate = true; if (i.Cancelled) { Game.RunAfterTick(Ui.CloseWindow); return; } if (i.Error != null) { onError(Download.FormatErrorMessage(i.Error)); return; } try { var data = Encoding.UTF8.GetString(i.Result); var mirrorList = data.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); downloadUrl(mirrorList.Random(new MersenneTwister())); } catch (Exception e) { Log.Write("install", "Mirror selection failed with error:"); Log.Write("install", e.ToString()); onError("Online mirror is not available. Please install from an original disc."); } }; var updateMirrors = new Download(download.MirrorList, onDownloadProgress, onFetchMirrorsComplete); cancelButton.OnClick = updateMirrors.CancelAsync; retryButton.OnClick = ShowDownloadDialog; } else { downloadUrl(download.URL); } }
/// <summary> /// Gets a list of running processes on the system. /// </summary> /// <returns>List of ProcessResults.</returns> public static CoreSploitResultList <ProcessResult> GetProcessList() { Platform processorArchitecture = Platform.Unknown; if (System.Environment.Is64BitOperatingSystem) { processorArchitecture = Platform.x64; } else { processorArchitecture = Platform.x86; } Process[] processes = Process.GetProcesses().OrderBy(P => P.Id).ToArray(); CoreSploitResultList <ProcessResult> results = new CoreSploitResultList <ProcessResult>(); foreach (Process process in processes) { int processId = process.Id; int parentProcessId = 0; string processName = process.ProcessName; string processPath = string.Empty; int sessionId = process.SessionId; //string processOwner = GetProcessOwner(process); Platform processArch = Platform.Unknown; if (parentProcessId != 0) { try { processPath = process.MainModule.FileName; } catch (System.ComponentModel.Win32Exception) { } } /** * if (processorArchitecture == Platform.x64) * { * processArch = IsWow64(process) ? Win32.Kernel32.Platform.x86 : Win32.Kernel32.Platform.x64; * } * else if (processorArchitecture == Win32.Kernel32.Platform.x86) * { * processArch = Win32.Kernel32.Platform.x86; * } * else if (processorArchitecture == Win32.Kernel32.Platform.IA64) * { * processArch = "x86"; * } **/ results.Add(new ProcessResult { Pid = processId, Ppid = parentProcessId, Name = processName, Path = processPath, SessionID = sessionId, //Owner = processOwner, //Architecture = processArch }); } return(results); }
/** * Initialise to use all defaults */ public DefaultAuthenticatedAttributeTableGenerator() { table = Platform.CreateHashtable(); }
public PicturePageTests(Platform platform) : base(platform) { }
public MockDataTests(Platform platform) : base(platform) { }
public Tests(Platform platform) { this.platform = platform; }
public static void ClassInit(TestContext context) { mBF = new BusinessFlow(); mBF.Name = "BF Test Fire Fox"; mBF.Active = true; Activity activity = new Activity(); mBF.AddActivity(activity); ActDummy action1 = new ActDummy(); ActDummy action2 = new ActDummy(); mBF.Activities[0].Acts.Add(action1); mBF.Activities[0].Acts.Add(action2); Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "SCM" }); VariableString v1 = new VariableString() { Name = "v1", InitialStringValue = "1" }; mBF.AddVariable(v1); mGR = new GingerRunner(); mGR.Name = "Test Runner"; mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); environment = new ProjEnvironment(); environment.Name = "Default"; mBF.Environment = environment.Name; Agent a = new Agent(); //a.DriverType = Agent.eDriverType.SeleniumFireFox;//have known firefox issues with selenium 3 a.DriverType = Agent.eDriverType.SeleniumChrome; mGR.SolutionAgents = new ObservableList <Agent>(); mGR.SolutionAgents.Add(a); // p2.Agent = a; mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "SCM", Agent = a }); mGR.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.SolutionApplications.Add(new ApplicationPlatform() { AppName = "SCM", Platform = ePlatformType.Web, Description = "New application" }); mGR.BusinessFlows.Add(mBF); mGR.SpecificEnvironmentName = environment.Name; mGR.UseSpecificEnvironment = false; string path = Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions" + Path.DirectorySeparatorChar + "BasicSimple")); string solutionFile = System.IO.Path.Combine(path, @"Ginger.Solution.xml"); solution = Solution.LoadSolution(solutionFile); SR = GingerSolutionRepository.CreateGingerSolutionRepository(); SR.Open(path); WorkSpace.Instance.Solution = solution; WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder = WorkSpace.Instance.Solution.LoggerConfigurations.ExecutionLoggerConfigurationExecResultsFolder; }
private DABImportDocuments.Response DABImportDocumentsHandler(DABImportDocuments command) { var response = new DABImportDocuments.Response(); var processes = Platform.ProjectionQuery <Process>().Where(p => p.FinalMaterialId != null).ToDictionary(p => p.Id, p => p.FinalMaterialId.Value); var finalMaterialIds = processes.Select(p => p.Value).Distinct().ToList(); var finalMaterials = Platform.ProjectionQuery <MaterialDefinition>().Where(m => finalMaterialIds.Contains(m.Id)).ToList(); WindchillDocConnector docConnector = new WindchillDocConnector(); var matDocDictionary = new Dictionary <int, List <Guid> >(); foreach (var finalMat in finalMaterials) { Platform.Tracer.Write("Siemens-SimaticIT-Trace-UADMRuntime", $"Retrieving documents for FinalMaterial {finalMat.NId} {finalMat.Revision}"); string revision = finalMat.Revision == "n/a" ? string.Empty : finalMat.Revision; var docInfoList = docConnector.GetDocumentList(finalMat.NId, revision); if (!docInfoList.Any()) { continue; } matDocDictionary.Add(finalMat.Id, new List <Guid>()); foreach (var docInfo in docInfoList) { string docNId = $"{docInfo.Revision}_{docInfo.Number}"; if (Platform.ProjectionQuery <Document>().Any(doc => doc.FileName == docInfo.Number && doc.Type == docInfo.DocType && doc.NId == doc.NId)) { continue; } Platform.Tracer.Write("Siemens-SimaticIT-Trace-UADMRuntime", $"Importing document {docNId} for FinalMaterial {finalMat.NId} {finalMat.Revision}"); var docFile = docConnector.DownloadDoc(docInfo); if (docFile == null) { continue; } var createDocInput = new CreateDocument() { Document = new DocumentParameterType { File = docFile.Content, FileName = docFile.Name, NId = docNId, Type = docFile.DocType, MIMEType = GetMimeType(docFile.Name) } }; var createDocResponse = Platform.CallCommand <CreateDocument, CreateDocument.Response>(createDocInput); if (!createDocResponse.Succeeded) { response.SetError(createDocResponse.Error.ErrorCode, createDocResponse.Error.ErrorMessage); return(response); } matDocDictionary[finalMat.Id].Add(createDocResponse.Id.Value); } foreach (var mat in matDocDictionary.Keys) { var processIds = processes.Where(kvp => kvp.Value.Equals(mat)).Select(kvp => kvp.Key); foreach (var procId in processIds) { var opIds = Platform.ProjectionQuery <Process>().Include(p => p.Operations).Where(p => p.Id.Equals(procId)).SelectMany(p => p.Operations).Select(o => o.Id); foreach (var opId in opIds) { if (!Platform.ProjectionQuery <OperationDependency>().Any(od => od.ContextProcess_Id.Equals(procId) && od.ToOperation_Id.Equals(opId))) { var createDocAssoc = Platform.CallCommand <LinkDocumentListToOperation, LinkDocumentListToOperation.Response>(new LinkDocumentListToOperation { ListOfDocumentId = matDocDictionary[mat], OperationId = opId }); if (!createDocAssoc.Succeeded) { response.SetError(createDocAssoc.Error.ErrorCode, createDocAssoc.Error.ErrorMessage); return(response); } break; } } } } } return(response); }
/// <summary> /// Permissions handler. /// </summary> /// <param name="requestCode">Request code.</param> /// <param name="permissions">Permissions.</param> /// <param name="grantResults">Grant results.</param> public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults) { Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults); base.OnRequestPermissionsResult(requestCode, permissions, grantResults); }
public StackPanel(Platform platform) : base(platform) { }
private void ProcessHandshakeMessage(HandshakeType type, byte[] buf) { MemoryStream inStr = new MemoryStream(buf, false); /* * Check the type. */ switch (type) { case HandshakeType.certificate: { switch (connection_state) { case CS_SERVER_HELLO_RECEIVED: { // Parse the Certificate message and send to cipher suite Certificate serverCertificate = Certificate.Parse(inStr); AssertEmpty(inStr); this.keyExchange.ProcessServerCertificate(serverCertificate); this.authentication = tlsClient.GetAuthentication(); this.authentication.NotifyServerCertificate(serverCertificate); break; } default: this.FailWithError(AlertLevel.fatal, AlertDescription.unexpected_message); break; } connection_state = CS_SERVER_CERTIFICATE_RECEIVED; break; } case HandshakeType.finished: switch (connection_state) { case CS_SERVER_CHANGE_CIPHER_SPEC_RECEIVED: /* * Read the checksum from the finished message, it has always 12 bytes. */ byte[] serverVerifyData = new byte[12]; TlsUtilities.ReadFully(serverVerifyData, inStr); AssertEmpty(inStr); /* * Calculate our own checksum. */ byte[] expectedServerVerifyData = TlsUtilities.PRF( securityParameters.masterSecret, "server finished", rs.GetCurrentHash(), 12); /* * Compare both checksums. */ if (!Arrays.ConstantTimeAreEqual(expectedServerVerifyData, serverVerifyData)) { /* * Wrong checksum in the finished message. */ this.FailWithError(AlertLevel.fatal, AlertDescription.handshake_failure); } connection_state = CS_DONE; /* * We are now ready to receive application data. */ this.appDataReady = true; break; default: this.FailWithError(AlertLevel.fatal, AlertDescription.unexpected_message); break; } break; case HandshakeType.server_hello: switch (connection_state) { case CS_CLIENT_HELLO_SEND: /* * Read the server hello message */ TlsUtilities.CheckVersion(inStr, this); /* * Read the server random */ securityParameters.serverRandom = new byte[32]; TlsUtilities.ReadFully(securityParameters.serverRandom, inStr); byte[] sessionID = TlsUtilities.ReadOpaque8(inStr); if (sessionID.Length > 32) { this.FailWithError(AlertLevel.fatal, AlertDescription.illegal_parameter); } this.tlsClient.NotifySessionID(sessionID); /* * Find out which CipherSuite the server has chosen and check that * it was one of the offered ones. */ CipherSuite selectedCipherSuite = (CipherSuite)TlsUtilities.ReadUint16(inStr); if (!ArrayContains(offeredCipherSuites, selectedCipherSuite) || selectedCipherSuite == CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV) { this.FailWithError(AlertLevel.fatal, AlertDescription.illegal_parameter); } this.tlsClient.NotifySelectedCipherSuite(selectedCipherSuite); /* * Find out which CompressionMethod the server has chosen and check that * it was one of the offered ones. */ CompressionMethod selectedCompressionMethod = (CompressionMethod)TlsUtilities.ReadUint8(inStr); if (!ArrayContains(offeredCompressionMethods, selectedCompressionMethod)) { this.FailWithError(AlertLevel.fatal, AlertDescription.illegal_parameter); } this.tlsClient.NotifySelectedCompressionMethod(selectedCompressionMethod); /* * RFC3546 2.2 The extended server hello message format MAY be * sent in place of the server hello message when the client has * requested extended functionality via the extended client hello * message specified in Section 2.1. * ... * Note that the extended server hello message is only sent in response * to an extended client hello message. This prevents the possibility * that the extended server hello message could "break" existing TLS 1.0 * clients. */ /* * TODO RFC 3546 2.3 * If [...] the older session is resumed, then the server MUST ignore * extensions appearing in the client hello, and send a server hello * containing no extensions. */ // ExtensionType -> byte[] IDictionary serverExtensions = Platform.CreateHashtable(); if (inStr.Position < inStr.Length) { // Process extensions from extended server hello byte[] extBytes = TlsUtilities.ReadOpaque16(inStr); MemoryStream ext = new MemoryStream(extBytes, false); while (ext.Position < ext.Length) { ExtensionType extType = (ExtensionType)TlsUtilities.ReadUint16(ext); byte[] extValue = TlsUtilities.ReadOpaque16(ext); // Note: RFC 5746 makes a special case for EXT_RenegotiationInfo if (extType != ExtensionType.renegotiation_info && !clientExtensions.Contains(extType)) { /* * RFC 3546 2.3 * Note that for all extension types (including those defined in * future), the extension type MUST NOT appear in the extended server * hello unless the same extension type appeared in the corresponding * client hello. Thus clients MUST abort the handshake if they receive * an extension type in the extended server hello that they did not * request in the associated (extended) client hello. */ this.FailWithError(AlertLevel.fatal, AlertDescription.unsupported_extension); } if (serverExtensions.Contains(extType)) { /* * RFC 3546 2.3 * Also note that when multiple extensions of different types are * present in the extended client hello or the extended server hello, * the extensions may appear in any order. There MUST NOT be more than * one extension of the same type. */ this.FailWithError(AlertLevel.fatal, AlertDescription.illegal_parameter); } serverExtensions.Add(extType, extValue); } } AssertEmpty(inStr); /* * RFC 5746 3.4. When a ServerHello is received, the client MUST check if it * includes the "renegotiation_info" extension: */ { bool secure_negotiation = serverExtensions.Contains(ExtensionType.renegotiation_info); /* * If the extension is present, set the secure_renegotiation flag * to TRUE. The client MUST then verify that the length of the * "renegotiated_connection" field is zero, and if it is not, MUST * abort the handshake (by sending a fatal handshake_failure * alert). */ if (secure_negotiation) { byte[] renegExtValue = (byte[])serverExtensions[ExtensionType.renegotiation_info]; if (!Arrays.ConstantTimeAreEqual(renegExtValue, CreateRenegotiationInfo(emptybuf))) { this.FailWithError(AlertLevel.fatal, AlertDescription.handshake_failure); } } tlsClient.NotifySecureRenegotiation(secure_negotiation); } if (clientExtensions != null) { tlsClient.ProcessServerExtensions(serverExtensions); } this.keyExchange = tlsClient.GetKeyExchange(); connection_state = CS_SERVER_HELLO_RECEIVED; break; default: this.FailWithError(AlertLevel.fatal, AlertDescription.unexpected_message); break; } break; case HandshakeType.server_hello_done: switch (connection_state) { case CS_SERVER_CERTIFICATE_RECEIVED: case CS_SERVER_KEY_EXCHANGE_RECEIVED: case CS_CERTIFICATE_REQUEST_RECEIVED: // NB: Original code used case label fall-through if (connection_state == CS_SERVER_CERTIFICATE_RECEIVED) { // There was no server key exchange message; check it's OK this.keyExchange.SkipServerKeyExchange(); } AssertEmpty(inStr); connection_state = CS_SERVER_HELLO_DONE_RECEIVED; TlsCredentials clientCreds = null; if (certificateRequest == null) { this.keyExchange.SkipClientCredentials(); } else { clientCreds = this.authentication.GetClientCredentials(certificateRequest); Certificate clientCert; if (clientCreds == null) { this.keyExchange.SkipClientCredentials(); clientCert = Certificate.EmptyChain; } else { this.keyExchange.ProcessClientCredentials(clientCreds); clientCert = clientCreds.Certificate; } SendClientCertificate(clientCert); } /* * Send the client key exchange message, depending on the key * exchange we are using in our CipherSuite. */ SendClientKeyExchange(); connection_state = CS_CLIENT_KEY_EXCHANGE_SEND; if (clientCreds != null && clientCreds is TlsSignerCredentials) { TlsSignerCredentials signerCreds = (TlsSignerCredentials)clientCreds; byte[] md5andsha1 = rs.GetCurrentHash(); byte[] clientCertificateSignature = signerCreds.GenerateCertificateSignature( md5andsha1); SendCertificateVerify(clientCertificateSignature); connection_state = CS_CERTIFICATE_VERIFY_SEND; } /* * Now, we send change cipher state */ byte[] cmessage = new byte[1]; cmessage[0] = 1; rs.WriteMessage(ContentType.change_cipher_spec, cmessage, 0, cmessage.Length); connection_state = CS_CLIENT_CHANGE_CIPHER_SPEC_SEND; /* * Calculate the master_secret */ byte[] pms = this.keyExchange.GeneratePremasterSecret(); securityParameters.masterSecret = TlsUtilities.PRF(pms, "master secret", TlsUtilities.Concat(securityParameters.clientRandom, securityParameters.serverRandom), 48); // TODO Is there a way to ensure the data is really overwritten? /* * RFC 2246 8.1. The pre_master_secret should be deleted from * memory once the master_secret has been computed. */ Array.Clear(pms, 0, pms.Length); /* * Initialize our cipher suite */ rs.ClientCipherSpecDecided(tlsClient.GetCompression(), tlsClient.GetCipher()); /* * Send our finished message. */ byte[] clientVerifyData = TlsUtilities.PRF(securityParameters.masterSecret, "client finished", rs.GetCurrentHash(), 12); MemoryStream bos = new MemoryStream(); TlsUtilities.WriteUint8((byte)HandshakeType.finished, bos); TlsUtilities.WriteOpaque24(clientVerifyData, bos); byte[] message = bos.ToArray(); rs.WriteMessage(ContentType.handshake, message, 0, message.Length); this.connection_state = CS_CLIENT_FINISHED_SEND; break; default: this.FailWithError(AlertLevel.fatal, AlertDescription.handshake_failure); break; } break; case HandshakeType.server_key_exchange: { switch (connection_state) { case CS_SERVER_HELLO_RECEIVED: case CS_SERVER_CERTIFICATE_RECEIVED: { // NB: Original code used case label fall-through if (connection_state == CS_SERVER_HELLO_RECEIVED) { // There was no server certificate message; check it's OK this.keyExchange.SkipServerCertificate(); this.authentication = null; } this.keyExchange.ProcessServerKeyExchange(inStr); AssertEmpty(inStr); break; } default: this.FailWithError(AlertLevel.fatal, AlertDescription.unexpected_message); break; } this.connection_state = CS_SERVER_KEY_EXCHANGE_RECEIVED; break; } case HandshakeType.certificate_request: switch (connection_state) { case CS_SERVER_CERTIFICATE_RECEIVED: case CS_SERVER_KEY_EXCHANGE_RECEIVED: { // NB: Original code used case label fall-through if (connection_state == CS_SERVER_CERTIFICATE_RECEIVED) { // There was no server key exchange message; check it's OK this.keyExchange.SkipServerKeyExchange(); } if (this.authentication == null) { /* * RFC 2246 7.4.4. It is a fatal handshake_failure alert * for an anonymous server to request client identification. */ this.FailWithError(AlertLevel.fatal, AlertDescription.handshake_failure); } int numTypes = TlsUtilities.ReadUint8(inStr); ClientCertificateType[] certificateTypes = new ClientCertificateType[numTypes]; for (int i = 0; i < numTypes; ++i) { certificateTypes[i] = (ClientCertificateType)TlsUtilities.ReadUint8(inStr); } byte[] authorities = TlsUtilities.ReadOpaque16(inStr); AssertEmpty(inStr); IList authorityDNs = Platform.CreateArrayList(); MemoryStream bis = new MemoryStream(authorities, false); while (bis.Position < bis.Length) { byte[] dnBytes = TlsUtilities.ReadOpaque16(bis); // TODO Switch to X500Name when available authorityDNs.Add(X509Name.GetInstance(Asn1Object.FromByteArray(dnBytes))); } this.certificateRequest = new CertificateRequest(certificateTypes, authorityDNs); this.keyExchange.ValidateCertificateRequest(this.certificateRequest); break; } default: this.FailWithError(AlertLevel.fatal, AlertDescription.unexpected_message); break; } this.connection_state = CS_CERTIFICATE_REQUEST_RECEIVED; break; case HandshakeType.hello_request: /* * RFC 2246 7.4.1.1 Hello request * This message will be ignored by the client if the client is currently * negotiating a session. This message may be ignored by the client if it * does not wish to renegotiate a session, or the client may, if it wishes, * respond with a no_renegotiation alert. */ if (connection_state == CS_DONE) { // Renegotiation not supported yet SendAlert(AlertLevel.warning, AlertDescription.no_renegotiation); } break; case HandshakeType.client_key_exchange: case HandshakeType.certificate_verify: case HandshakeType.client_hello: default: // We do not support this! this.FailWithError(AlertLevel.fatal, AlertDescription.unexpected_message); break; } }
public OnboardingTests(Platform platform, UserType userType) : base(platform, userType) { }
/// <summary> /// 推送消息 /// </summary> /// <param name="alert">弹窗</param> /// <param name="content">消息内容</param> /// <param name="extras">参数</param> /// <param name="targets">目标(istag=true:角色表FID istag=false:用户表FNumber)</param> /// <param name="type">推送目标</param> public void Push(string alert, PushParam content, string[] targets, PushType type = PushType.Alias) { try { JPushClient client = new JPushClient(app_key, master_secret); PushPayload payload = new PushPayload(); payload.platform = Platform.android_ios(); payload.options.apns_production = true; if (type == PushType.Tag) { payload.audience = Audience.s_tag(targets); } else if (type == PushType.Alias) { payload.audience = Audience.s_alias(targets); } else if (type == PushType.All) { payload.audience = Audience.all(); } var message = Message.content(content.Text); if (!string.IsNullOrEmpty(alert)) { var notification = new Notification().setAlert(alert); notification.IosNotification = new IosNotification(); notification.IosNotification.incrBadge(1); notification.IosNotification.setContentAvailable(true); notification.IosNotification.setSound("happy"); notification.AndroidNotification = new AndroidNotification(); var extras = content.ToDictionary(); if (extras != null) { foreach (var i in extras) { message.AddExtras(i.Key, i.Value); notification.AndroidNotification.AddExtra(i.Key, i.Value); notification.IosNotification.AddExtra(i.Key, i.Value); } } payload.notification = notification.Check(); } payload.message = message.Check(); var result = client.SendPush(payload); } catch (APIRequestException e) { StringBuilder builder = new StringBuilder(); builder.Append("Error response from JPush server. Should review and fix it. "); builder.Append("HTTP Status: " + e.Status); builder.Append("Error Code: " + e.ErrorCode); builder.Append("Error Message: " + e.ErrorCode); //throw new Exception(builder.ToString()); } catch (APIConnectionException e) { StringBuilder builder = new StringBuilder(); builder.Append("Error response from JPush server. Should review and fix it. "); builder.Append("Message: " + e.Message); builder.Append("StackTrace: " + e.StackTrace); //throw new Exception(builder.ToString()); } catch (Exception e) { } }
public OrderTests(Platform platform) : base(platform) { }