2013-12-13 98 views
2

我正在研究需要从需要身份验证的http存储库下载必备软件的burn bootstrapper。 那么,我该如何处理这个要求呢?Wix Bootstrapper - 从安全的http存储库下载软件包

谢谢!

+0

你想提示输入相应的凭据用户或者是你正在寻找一种方式来(安全)嵌入的凭据? (第二个是不太可能的,但是知道你想要去哪个路径很好) –

+0

不,用户不会被提示输入凭证;我正在寻找方式来指定凭据。 Engine.SetDownloadSource()方法已经支持,但我不知道如何使用它。参考:http://stackoverflow.com/questions/13346168/wix-managedbootstrapper-setdownloadsource-confusion – slimbyte

回答

1

Got it!这可以在OnResolveSource实现()事件:

// variable used for authentication 
static const LPCWSTR WIXSTDBA_VARIABLE_HTTP_DOWNLOAD_USER = L"HTTPDownloadUserName"; 
static const LPCWSTR WIXSTDBA_VARIABLE_HTTP_DOWNLOAD_PASS = L"HTTPDownloadPassword"; 

virtual STDMETHODIMP_(int) OnResolveSource(
    __in_z LPCWSTR wzPackageOrContainerId, 
    __in_z_opt LPCWSTR wzPayloadId, 
    __in_z LPCWSTR wzLocalSource, 
    __in_z_opt LPCWSTR wzDownloadSource 
    ) 
{ 
    int nResult = IDERROR; // assume we won't resolve source and that is unexpected. 

    LPWSTR sczHTTPDwnUserName = NULL; 
    LPWSTR sczHTTPDwnPassword = NULL; 
    BOOL bUseHTTPAuth = FALSE; 

    if (BalStringVariableExists(WIXSTDBA_VARIABLE_HTTP_DOWNLOAD_USER)) 
    { 
     HRESULT hrUsr = BalGetStringVariable(WIXSTDBA_VARIABLE_HTTP_DOWNLOAD_USER, &sczHTTPDwnUserName); 
     HRESULT hrPwd = BalGetStringVariable(WIXSTDBA_VARIABLE_HTTP_DOWNLOAD_PASS, &sczHTTPDwnPassword); 
     if (SUCCEEDED(hrUsr) && SUCCEEDED(hrPwd)) bUseHTTPAuth = TRUE; 
    } 

    if (BOOTSTRAPPER_DISPLAY_FULL == m_command.display) 
    { 
     if (wzDownloadSource) 
     { 
      if (bUseHTTPAuth) 
      { 
       HRESULT hr = m_pEngine->SetDownloadSource(wzPackageOrContainerId, wzPayloadId, wzDownloadSource, sczHTTPDwnUserName, sczHTTPDwnPassword); 
       nResult = SUCCEEDED(hr) ? IDDOWNLOAD : IDERROR; 
      } 
      else 
       nResult = IDDOWNLOAD; 
     } 
     else // prompt to change the source location. 
     { 
      // related stuff 
     } 
    } 
    else if (wzDownloadSource) 
    { 
     // If doing a non-interactive install and download source is available, let's try downloading the package silently 
     if (bUseHTTPAuth) 
     { 
      HRESULT hr = m_pEngine->SetDownloadSource(wzPackageOrContainerId, wzPayloadId, wzDownloadSource, sczHTTPDwnUserName, sczHTTPDwnPassword); 
      nResult = SUCCEEDED(hr) ? IDRETRY : IDERROR; 
     } 
     else 
      nResult = IDDOWNLOAD; 
    } 
    // else there's nothing more we can do in non-interactive mode 

    return CheckCanceled() ? IDCANCEL : nResult; 
} 
+0

你究竟在这里做什么? OnResolveSource是如何利用的? –

相关问题