From 3c345871de73a9c534a6b6bd597338b3f3a704c7 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 18 Aug 2006 07:37:10 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=10944 --- checkin_notes | 26 ++++++++++++ clientgui/ProjectProcessingPage.cpp | 7 ++-- clientgui/WizardAttachProject.cpp | 26 +++++++++++- clientgui/WizardAttachProject.h | 1 + clientlib/win/AuthenticatorDetection.cpp | 53 ++++++++++++++++++++++++ clientlib/win/AuthenticatorDetection.h | 22 ++++++++++ clientlib/win/stdafx.h | 1 + win_build/boinc_dll.vcproj | 8 ++++ win_build/boinc_dll_2003.vcproj | 8 +++- 9 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 clientlib/win/AuthenticatorDetection.cpp create mode 100644 clientlib/win/AuthenticatorDetection.h diff --git a/checkin_notes b/checkin_notes index 75b42f9af9..3ae1e0791c 100755 --- a/checkin_notes +++ b/checkin_notes @@ -8916,6 +8916,7 @@ Charlie 17 Aug 2006 x_opengl.C client/ hostinfo_unix.C + Milos 17 Aug 2006 - changed the way wxFlatNotebook is initialized when there is no work present. Added routing to intialize notebook to default values.Introduced Freeze() @@ -8949,3 +8950,28 @@ Charlie 17 Aug 2006 mac_build/ boinc.xcodeproj/ project.pbxproj + +Rom 18 Aug 2006 + - boincmgr - Add support for detecting an authenticator via a "Setup" cookie + from the projects master URL. With this, and the project_init.xml file + specified for a customized installer will allow for a handsfree install + scenario. + + project_init.xml just needs to contain the project name and master url, the + website sets a cookie named "Setup" with the desired authenticator and + a reasonable timeout, like 30 minutes, and the attach to project wizard will + automatically attach to the project and get work. + + NOTE: This only works if the participant is using Internet Explorer. + + clientgui/ + ProjectProcessingPage.cpp + WizardAttachProject.cpp, .h + clientlib/win/ + AuthenticatorDetection.cpp, .h + stdafx.h + win_build/ + boinc_dll.vcproj + boinc_dll_2003.vcproj + + \ No newline at end of file diff --git a/clientgui/ProjectProcessingPage.cpp b/clientgui/ProjectProcessingPage.cpp index 2b5d579e10..622514e3c3 100644 --- a/clientgui/ProjectProcessingPage.cpp +++ b/clientgui/ProjectProcessingPage.cpp @@ -377,10 +377,11 @@ void CProjectProcessingPage::OnStateChange( CProjectProcessingPageEvent& WXUNUSE ai->url = (const char*)pWAP->m_ProjectInfoPage->GetProjectURL().mb_str(); - if (!pWAP->m_AccountKeyPage->m_strAccountKey.IsEmpty() || - pWAP->m_bCredentialsCached + if (!pWAP->m_AccountKeyPage->m_strAccountKey.IsEmpty() || + pWAP->m_bCredentialsCached || + pWAP->m_bCredentialsDetected ) { - if (!pWAP->m_bCredentialsCached) { + if (!pWAP->m_bCredentialsCached || pWAP->m_bCredentialsDetected) { ao->authenticator = (const char*)pWAP->m_AccountKeyPage->m_strAccountKey.mb_str(); } SetProjectCommunitcationsSucceeded(true); diff --git a/clientgui/WizardAttachProject.cpp b/clientgui/WizardAttachProject.cpp index b0dcccd3b0..cb2b36a2ce 100644 --- a/clientgui/WizardAttachProject.cpp +++ b/clientgui/WizardAttachProject.cpp @@ -50,6 +50,9 @@ #include "res/attachprojectwizard.xpm" ////@end XPM images +#ifdef __WXMSW__ +EXTERN_C BOOL DetectSetupAuthenticator(LPCSTR szProjectURL, LPSTR szAuthenticator, LPDWORD lpdwSize); +#endif /*! * CWizardAttachProject type definition @@ -130,6 +133,7 @@ bool CWizardAttachProject::Create( wxWindow* parent, wxWindowID id, const wxPoin project_url = wxEmptyString; project_authenticator = wxEmptyString; m_bCredentialsCached = false; + m_bCredentialsDetected = false; wxString strTitle; if (wxGetApp().GetBrand()->IsBranded()) { @@ -266,7 +270,27 @@ bool CWizardAttachProject::Run( wxString& WXUNUSED(strName), wxString& strURL, b m_bCredentialsCached = bCredentialsCached; } - if ( strURL.Length() && bCredentialsCached && m_ProjectProcessingPage) { +#ifdef __WXMSW__ + + // If credentials are not cached, then we should try one last place to look up the + // authenticator. Some projects will set a "Setup" cookie off of their URL with a + // pretty short timeout. Lets take a crack at detecting it. + // + // Only Internet Explorer is supported at this time. + // + if (!bCredentialsCached) { + TCHAR szAuthenticator[512]; + DWORD dwSize = sizeof(szAuthenticator)/sizeof(TCHAR); + + if (DetectSetupAuthenticator(strURL.mbc_str(), szAuthenticator, &dwSize)) { + m_bCredentialsDetected = true; + m_AccountKeyPage->m_strAccountKey = szAuthenticator; + } + } + +#endif + + if ( strURL.Length() && (bCredentialsCached || m_bCredentialsDetected) && m_ProjectProcessingPage) { return RunWizard(m_ProjectProcessingPage); } else if (strURL.Length() && !bCredentialsCached && m_ProjectPropertiesPage) { return RunWizard(m_ProjectPropertiesPage); diff --git a/clientgui/WizardAttachProject.h b/clientgui/WizardAttachProject.h index 88fe4a8c5b..4edb67bdcb 100644 --- a/clientgui/WizardAttachProject.h +++ b/clientgui/WizardAttachProject.h @@ -125,6 +125,7 @@ public: CErrProxyPage* m_ErrProxyPage; ////@end CWizardAttachProject member variables bool m_bCredentialsCached; + bool m_bCredentialsDetected; wxString strProjectName; }; diff --git a/clientlib/win/AuthenticatorDetection.cpp b/clientlib/win/AuthenticatorDetection.cpp new file mode 100644 index 0000000000..ded35b9886 --- /dev/null +++ b/clientlib/win/AuthenticatorDetection.cpp @@ -0,0 +1,53 @@ +// Berkeley Open Infrastructure for Network Computing +// http://boinc.berkeley.edu +// Copyright (C) 2005 University of California +// +// This is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; +// either version 2.1 of the License, or (at your option) any later version. +// +// This software is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// To view the GNU Lesser General Public License visit +// http://www.gnu.org/copyleft/lesser.html +// or write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +#include "stdafx.h" +#include "Identification.h" + + +/** + * Detect what authenticator to use from the current users cookie cache. + * + * A project will assign an authenticator from some web based signup system as part + * of their HTTP cookie, from there we can query Internet Explorer and get the + * authenticator and use it during the attach to project wizard execution. + * + * Internet Explorer is the only browser supported at present. + **/ +EXTERN_C __declspec(dllexport) BOOL DetectSetupAuthenticator(LPCTSTR szProjectURL, LPTSTR szAuthenticator, LPDWORD lpdwSize) +{ + BOOL bReturnValue = FALSE; + TCHAR szCookie[2048]; + DWORD dwSize = sizeof(szCookie)/sizeof(TCHAR); + + bReturnValue = InternetGetCookieEx(szProjectURL, _T("Setup"), szCookie, &dwSize, INTERNET_COOKIE_THIRD_PARTY, NULL); + if (bReturnValue) + { + _tcsncpy(szAuthenticator, _tcsstr(szCookie, TEXT("=")) + 1, *lpdwSize); + *lpdwSize = (DWORD)_tcslen(szAuthenticator); + } + else + { + fprintf(stderr, TEXT("DetectSetupAuthenticator() - InternetGetCookieEx Failed. GetLastError = '%d'"), GetLastError()); + } + + return bReturnValue; +} + diff --git a/clientlib/win/AuthenticatorDetection.h b/clientlib/win/AuthenticatorDetection.h new file mode 100644 index 0000000000..6ba8ebd32b --- /dev/null +++ b/clientlib/win/AuthenticatorDetection.h @@ -0,0 +1,22 @@ +// Berkeley Open Infrastructure for Network Computing +// http://boinc.berkeley.edu +// Copyright (C) 2005 University of California +// +// This is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; +// either version 2.1 of the License, or (at your option) any later version. +// +// This software is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// To view the GNU Lesser General Public License visit +// http://www.gnu.org/copyleft/lesser.html +// or write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#pragma once + +EXTERN_C __declspec(dllexport) BOOL DetectSetupAuthenticator(LPCTSTR szProjectURL, LPTSTR szAuthenticator, LPDWORD lpdwSize); diff --git a/clientlib/win/stdafx.h b/clientlib/win/stdafx.h index 3149a0f793..856416c36c 100755 --- a/clientlib/win/stdafx.h +++ b/clientlib/win/stdafx.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/win_build/boinc_dll.vcproj b/win_build/boinc_dll.vcproj index aaa7fb4d51..7fd123a644 100644 --- a/win_build/boinc_dll.vcproj +++ b/win_build/boinc_dll.vcproj @@ -412,6 +412,10 @@ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + @@ -478,6 +482,10 @@ Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > + + diff --git a/win_build/boinc_dll_2003.vcproj b/win_build/boinc_dll_2003.vcproj index c7a8bd0158..da7a6b7889 100644 --- a/win_build/boinc_dll_2003.vcproj +++ b/win_build/boinc_dll_2003.vcproj @@ -159,7 +159,7 @@ PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG;_USRDLL;_ATL_ATTRIBUTES" MinimalRebuild="TRUE" BasicRuntimeChecks="3" - RuntimeLibrary="3" + RuntimeLibrary="1" UsePrecompiledHeader="3" WarningLevel="4" Detect64BitPortabilityProblems="TRUE" @@ -287,6 +287,9 @@ Name="Source Files" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + + @@ -337,6 +340,9 @@ Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + +