/// <summary> /// Initialises profile connection. /// </summary> /// <param name="cookie">Dna Cookie to login with</param> /// <param name="signInComponent">Initialised ProfileAPI</param> private bool InitialiseProfileAPI(DnaCookie cookie, ref IDnaIdentityWebServiceProxy signInComponent) { InputContext.Diagnostics.WriteTimedEventToLog("SSO", "Start"); DateTime timer = DateTime.Now; // Set the current user. If this returns false, it means the user was not signed in correctly string decodedCookie = cookie.Value; // Get a profile connection if (signInComponent.SignInSystemType == SignInSystem.Identity) { signInComponent.SetService(InputContext.CurrentSite.IdentityPolicy); } else { signInComponent.SetService(InputContext.CurrentSite.SSOService); } InputContext.Diagnostics.WriteTimedEventToLog("SSO","End"); // Check to see if the service was set ok before calling any user functions if (!signInComponent.IsServiceSet) { InputContext.Diagnostics.WriteToLog("---** SignIn **---", "Service not set!!!"); return false; } string secureCookie = ""; if (InputContext.GetCookie("IDENTITY-HTTPS") != null) { secureCookie = InputContext.GetCookie("IDENTITY-HTTPS").Value; } bool userSet = signInComponent.TrySecureSetUserViaCookies(decodedCookie, secureCookie) || signInComponent.IsUserSignedIn; InputContext.IsSecureRequest = signInComponent.IsSecureRequest; InputContext.Diagnostics.WriteToLog("---** InputContext.IsSecureRequest **---", InputContext.IsSecureRequest.ToString()); if (!userSet) { InputContext.Diagnostics.WriteToLog("---** SignIn **---", "Set user with cookie failed!!! - " + decodedCookie); if (secureCookie.Length > 0) { InputContext.Diagnostics.WriteToLog("---** SignIn **---", "Set user with secure cookie failed!!! - " + secureCookie); } InputContext.Diagnostics.WriteToLog("---** SignIn **---", "Timing Info: "+signInComponent.GetLastTimingInfo()); return false; } Statistics.AddIdentityCallDuration(TimeSpan.FromTicks(DateTime.Now.Ticks - timer.Ticks).Milliseconds); return true; }
/// <summary> /// This is the place where all the actual work is done /// Please add all new code here, and not in the main Page_Load method /// </summary> private void DoPageLoad() { Stopwatch requesttimer = new Stopwatch(); requesttimer.Start(); InitialiseRequest(); // Check to see which sign in method we need to create if (_debugUserID.Length > 0) { SetupDebugUserSignin(); } else if (CurrentSite.UseIdentitySignInSystem) { // Create a new Identity web service object string identityWebServiceConnetionDetails = GetConnectionDetails["IdentityURL"].ConnectionString; Diagnostics.WriteTimedEventToLog("IDENTITY", "Started with " + identityWebServiceConnetionDetails); string clientIPAddress = GetParamStringOrEmpty("__ip__", "Client IP Address"); _signInComponent = new DnaIdentityWebServiceProxy.IdentityRestSignIn(identityWebServiceConnetionDetails, clientIPAddress); _signInComponent.SetService(CurrentSite.IdentityPolicy); Diagnostics.WriteTimedEventToLog("IDENTITY", "Finished"); } else { // Create a new profileAPI signin object throw new NotSupportedException("The ProfileAPI is nolonger supported. Please set the site to use Identity as the Signin System."); } // If we have cached output available for this request, don't do any more work if (IsCachedOutputAvailable()) { return; } CheckForForbiddenUserAgents(UserAgent, BannedUserAgents); int curRequests = Interlocked.Increment(ref _currentRequestCount); try { if (curRequests > MaximumRequestCount && _dnapage.PageType.Equals("SERVERTOOBUSY") == false ) { AddServerBusy(); Server.Transfer("ServerTooBusyPage.aspx"); //_viewingUser = new User(this); //_page = new WholePage(this); //_page.InitialisePage("SERVERTOOBUSY"); //_page.AddTextTag(_page.RootElement.FirstChild, "REQUESTTYPE", PageType); //_skinSelector.Initialise(this, this); } InitialisePage(); // Intialise the page Statistics.AddRawRequest(); if (!IsDnaUserAllowed() && !_useDotNetRendering ) {//not logged in if (!_skinSelector.IsPureXml(this)) { _skinSelector.SkinName = "admin"; _skinSelector.SkinSet = "vanilla"; } _page = new WholePage(this); _page.InitialisePage("ERROR"); _page.AddErrorXml("Authorization", "You are not authorised to view this page.", _page.RootElement.FirstChild); } else if (!IsSecureAccessAllowed()) {//logged in but not secure if (!_skinSelector.IsPureXml(this)) { _skinSelector.SkinName = "admin"; _skinSelector.SkinSet = "vanilla"; } _page = new WholePage(this); _page.InitialisePage("ERROR"); _page.AddErrorXml("NotSecure", "You must access this page be secure methods.", _page.RootElement.FirstChild); } else { // Now call the add components _dnapage.OnPageLoad(); AddComponent(new SkinParams(this)); _page.ProcessRequest(); // Update any data source controls on the page _dnapage.UpdateDataSourceControls(); // Allow the page to do any post process request actions. _dnapage.OnPostProcessRequest(); } //Finish off other related BasePage stuff FinalisePage(); Statistics.AddRequestDuration((int)requesttimer.ElapsedMilliseconds); _page.AddTimeForPage(Diagnostics.ElapsedMilliseconds); _page.AddInside(_tracker, "H2G2"); } finally { Interlocked.Decrement(ref _currentRequestCount); } }