/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { this.Visible = false; } else { // Check renamed DLL library if (CMSOpenIDHelper.CheckOpenIdDLL()) { // Check if OpenID module is enabled if (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSEnableOpenID")) { ltlScript.Text = ScriptHelper.GetIncludeScript(PROVIDERS_LOCATION + "OpenIDSelector.js"); lblError.Text = GetString("openid.invalidid"); SetProviders(); DisplayButtons(); openIDhelper = new CMSOpenIDHelper(); CheckStatus(); } else { // Error label is displayed in Design mode when OpenID is disabled if (CMSContext.ViewMode == ViewModeEnum.Design) { StringBuilder parameter = new StringBuilder(); parameter.Append(GetString("header.sitemanager") + " -> "); parameter.Append(GetString("settingscategory.cmssettings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmsopenid")); if (CMSContext.CurrentUser.UserSiteManagerAdmin) { // Make it link for SiteManager Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl("~/CMSSiteManager/default.aspx?section=settings") + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.openid.disabled"), parameter.ToString()); lblError.Visible = true; txtInput.Visible = false; } else { this.Visible = false; } } } // Error label is displayed in Design mode when OpenID library is not enabled else { lblError.Text = ResHelper.GetString("mem.openid.library"); lblError.Visible = true; txtInput.Visible = false; } } }
/// <summary> /// Sign In clicked event handler. /// </summary> protected void btnSignIn_Click(object sender, EventArgs e) { openIDhelper = new CMSOpenIDHelper(); string openidURL = DisplayTextbox ? txtInput.Text.Trim() : hdnValue.Value; // Check if validation was successful if (CMSOpenIDHelper.IsValid(openidURL)) { // Store ProviderURL for later use SessionHelper.SetValue(SESSION_NAME_URL, openidURL); // Send request string response = openIDhelper.SendRequest(openidURL, BirthDateRequest, CountryRequest, EmailRequest, FullNameRequest, GenderRequest, LanguageRequest, NicknameRequest, PostalCodeRequest, TimeZoneRequest); if (!String.IsNullOrEmpty(response)) { lblError.Visible = true; lblError.Text = response; } } else { if (DisplayTextbox) { lblError.Text = GetString("mem.openid.enterproviderurl"); } else { lblError.Text = GetString("mem.openid.selectprovider"); } lblError.Visible = true; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { Visible = false; } else { if (SystemContext.IsFullTrustLevel) { // Check if OpenID module is enabled if (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSEnableOpenID")) { ltlScript.Text = ScriptHelper.GetIncludeScript(PROVIDERS_LOCATION + "OpenIDSelector.js"); lblError.Text = GetString("openid.invalidid"); SetProviders(); DisplayButtons(); openIDhelper = new CMSOpenIDHelper(); CheckStatus(); } else { // Error label is displayed in Design mode when OpenID is disabled if (PortalContext.IsDesignMode(PortalContext.ViewMode)) { StringBuilder parameter = new StringBuilder(); parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmsopenid")); if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin)) { // Make it link for Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(UIContextHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.openid.disabled"), parameter.ToString()); lblError.Visible = true; txtInput.Visible = false; } else { Visible = false; } } } // Error label is displayed in Design mode when OpenID library is not enabled else { lblError.Text = ResHelper.GetString("socialnetworking.fulltrustrequired"); lblError.Visible = true; txtInput.Visible = false; } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!this.StopProcessing) { // Check renamed DLL library if (CMSOpenIDHelper.CheckOpenIdDLL()) { // Check if LinkedIn module is enabled if (LinkedInHelper.LinkedInIsAvailable(CMSContext.CurrentSiteName)) { DisplayButtons(); linkedInHelper = new LinkedInHelper(); CheckStatus(); } else { // Error label is displayed in Design mode when LinkedIn is disabled if (CMSContext.ViewMode == ViewModeEnum.Design) { StringBuilder parameter = new StringBuilder(); parameter.Append(GetString("header.sitemanager") + " -> "); parameter.Append(GetString("settingscategory.cmssettings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmslinkedin")); if (CMSContext.CurrentUser.UserSiteManagerAdmin) { // Make it link for SiteManager Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl("~/CMSSiteManager/default.aspx?section=settings") + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.linkedin.disabled"), parameter.ToString()); lblError.Visible = true; } else { this.Visible = false; } } } // Error label is displayed in Design mode when LinkedIn library is not loaded else { lblError.ResourceString = "mem.openid.library"; lblError.Visible = true; } } else { this.Visible = false; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { this.Visible = false; } else { // Check renamed DLL library if (CMSOpenIDHelper.CheckOpenIdDLL()) { // Check if OpenID module is enabled if (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSEnableOpenID")) { ltlScript.Text = ScriptHelper.GetIncludeScript(PROVIDERS_LOCATION + "OpenIDSelector.js"); lblError.Text = GetString("openid.invalidid"); SetProviders(); DisplayButtons(); openIDhelper = new CMSOpenIDHelper(); CheckStatus(); } else { // Error label is displayed in Design mode when OpenID is disabled if (CMSContext.ViewMode == ViewModeEnum.Design) { StringBuilder parameter = new StringBuilder(); parameter.Append(GetString("header.sitemanager") + " -> "); parameter.Append(GetString("settingscategory.cmssettings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmsopenid")); if (CMSContext.CurrentUser.UserSiteManagerAdmin) { // Make it link for SiteManager Admin parameter.Insert(0,"<a href=\"" + URLHelper.GetAbsoluteUrl("~/CMSSiteManager/default.aspx?section=settings") + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.openid.disabled"), parameter.ToString()); lblError.Visible = true; txtInput.Visible = false; } else { this.Visible = false; } } } // Error label is displayed in Design mode when OpenID library is not enabled else { lblError.Text = ResHelper.GetString("mem.openid.library"); lblError.Visible = true; txtInput.Visible = false; } } }
/// <summary> /// Sign In clicked event handler. /// </summary> protected void btnSignIn_Click(object sender, EventArgs e) { openIDhelper = new CMSOpenIDHelper(); string openidURL = null; if (this.DisplayTextbox) { openidURL = txtInput.Text.Trim(); } else { openidURL = hdnValue.Value; } // Check if validation was successful if (CMSOpenIDHelper.IsValid(openidURL)) { // Store ProviderURL for later use SessionHelper.SetValue(SESSION_NAME_URL, openidURL); // Send request string response = openIDhelper.SendRequest(openidURL, BirthDateRequest, CountryRequest, EmailRequest, FullNameRequest, GenderRequest, LanguageRequest, NicknameRequest, PostalCodeRequest, TimeZoneRequest); if (!String.IsNullOrEmpty(response)) { lblError.Visible = true; lblError.Text = response; } } else { if (this.DisplayTextbox) { lblError.Text = GetString("mem.openid.enterproviderurl"); } else { lblError.Text = GetString("mem.openid.selectprovider"); } lblError.Visible = true; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!StopProcessing) { plcError.Visible = false; // Check renamed DLL library if (!CMSOpenIDHelper.CheckOpenIdDLL()) { // Error label is displayed when OpenID library is not enabled lblError.Text = ResHelper.GetString("mem.openid.library"); plcError.Visible = true; plcContent.Visible = false; } // Check if OpenID module is enabled if (!SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSEnableOpenID") && !plcError.Visible) { // Error label is displayed only in Design mode if (CMSContext.ViewMode == ViewModeEnum.Design) { StringBuilder parameter = new StringBuilder(); parameter.Append(GetString("header.sitemanager") + " -> "); parameter.Append(GetString("settingscategory.cmssettings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmsopenid")); if (CMSContext.CurrentUser.UserSiteManagerAdmin) { // Make it link for SiteManager Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl("~/CMSSiteManager/default.aspx?section=settings") + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.openid.disabled"), parameter.ToString()); plcError.Visible = true; plcContent.Visible = false; } // In other modes is webpart hidden else { Visible = false; } } // Display webpart when no error occured if (!plcError.Visible && Visible) { if (!CMSContext.CurrentUser.IsAuthenticated()) { plcPasswordNew.Visible = AllowFormsAuthentication; pnlExistingUser.Visible = AllowExistingUser; // Initialize OpenID session response = (Dictionary <string, object>)SessionHelper.GetValue(SESSION_NAME_USERDATA); userProviderUrl = ValidationHelper.GetString(SessionHelper.GetValue(SESSION_NAME_URL), null); // Check that OpenID is not already registered if (response != null) { UserInfo ui = OpenIDUserInfoProvider.GetUserInfoByOpenID((string)response["ClaimedIdentifier"]); // OpenID is already registered to some user if (ui != null) { plcContent.Visible = false; plcError.Visible = true; lblError.Text = GetString("mem.openid.openidregistered"); } } // There is no OpenID response object stored in session - hide all if ((response == null) && HideForNoOpenID) { Visible = false; } else if (!RequestHelper.IsPostBack()) { LoadData(); } } // Hide webpart for authenticated users else { Visible = false; } } } // Hide control when StopProcessing = TRUE else { Visible = false; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!StopProcessing) { plcError.Visible = false; // Check renamed DLL library if (!CMSOpenIDHelper.CheckOpenIdDLL()) { // Error label is displayed when OpenID library is not enabled lblError.ResourceString = "mem.openid.library"; plcError.Visible = true; plcContent.Visible = false; } string currentSiteName = CMSContext.CurrentSiteName; // Check if LinkedIn module is enabled if (!LinkedInHelper.LinkedInIsAvailable(CMSContext.CurrentSiteName) && !plcError.Visible) { // Error label is displayed only in Design mode if (CMSContext.ViewMode == ViewModeEnum.Design) { StringBuilder parameter = new StringBuilder(); parameter.Append(GetString("header.sitemanager") + " -> "); parameter.Append(GetString("settingscategory.cmssettings") + " -> "); parameter.Append(GetString("settingscategory.socialnetworks") + " -> "); parameter.Append(GetString("settingscategory.cmslinkedin")); if (CMSContext.CurrentUser.UserSiteManagerAdmin) { // Make it link for SiteManager Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl("~/CMSSiteManager/default.aspx?section=settings") + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.linkedin.disabled"), parameter.ToString()); plcError.Visible = true; plcContent.Visible = false; } // In other modes is webpart hidden else { Visible = false; } } // Display webpart when no error occured if (!plcError.Visible && Visible) { // Hide webpart if user is authenticated if (CMSContext.CurrentUser.IsAuthenticated()) { Visible = false; return; } plcPasswordNew.Visible = AllowFormsAuthentication; pnlExistingUser.Visible = AllowExistingUser; linkedInHelper = new LinkedInHelper(); linkedInHelper.Initialize(SessionHelper.GetValue(SESSION_NAME_USERDATA) as XmlDocument); // There is no LinkedIn user ID stored in session - hide all if (string.IsNullOrEmpty(linkedInHelper.MemberId) && HideForNoLinkedInUserID) { Visible = false; } else if (!RequestHelper.IsPostBack()) { LoadData(); } } } else { Visible = false; } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!this.StopProcessing) { plcError.Visible = false; // Check renamed DLL library if (!CMSOpenIDHelper.CheckOpenIdDLL()) { // Error label is displayed when OpenID library is not enabled lblError.Text = ResHelper.GetString("mem.openid.library"); plcError.Visible = true; plcContent.Visible = false; } // Check if OpenID module is enabled if (!SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSEnableOpenID") && !this.plcError.Visible) { // Error label is displayed only in Design mode if (CMSContext.ViewMode == ViewModeEnum.Design) { StringBuilder parameter = new StringBuilder(); parameter.Append(GetString("header.sitemanager") + " -> "); parameter.Append(GetString("settingscategory.cmssettings") + " -> "); parameter.Append(GetString("settingscategory.cmsmembership") + " -> "); parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> "); parameter.Append(GetString("settingscategory.cmsopenid")); if (CMSContext.CurrentUser.UserSiteManagerAdmin) { // Make it link for SiteManager Admin parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl("~/CMSSiteManager/default.aspx?section=settings") + "\" target=\"_top\">"); parameter.Append("</a>"); } lblError.Text = String.Format(GetString("mem.openid.disabled"), parameter.ToString()); plcError.Visible = true; plcContent.Visible = false; } // In other modes is webpart hidden else { this.Visible = false; } } // Display webpart when no error occured if (!plcError.Visible && this.Visible) { if (!CMSContext.CurrentUser.IsAuthenticated()) { plcPasswordNew.Visible = this.AllowFormsAuthentication; pnlExistingUser.Visible = this.AllowExistingUser; // Initialize OpenID session openIDhelper = new CMSOpenIDHelper(); openIDhelper.Initialize(SessionHelper.GetValue(SESSION_NAME_USERDATA)); userProviderUrl = ValidationHelper.GetString(SessionHelper.GetValue(SESSION_NAME_URL), null); // Check that OpenID is not already registered if (openIDhelper.GetResponseObject() != null) { UserInfo ui = OpenIDUserInfoProvider.GetUserInfoByOpenID(openIDhelper.ClaimedIdentifier); // OpenID is already registered to some user if (ui != null) { plcContent.Visible = false; plcError.Visible = true; lblError.Text = GetString("mem.openid.openidregistered"); } } // There is no OpenID response object stored in session - hide all if (openIDhelper.GetResponseObject() == null && HideForNoOpenID) { this.Visible = false; } else if (!RequestHelper.IsPostBack()) { LoadData(); } } // Hide webpart for authenticated users else { this.Visible = false; } } } // Hide control when StopProcessing = TRUE else { this.Visible = false; } }