Wix Bootstrapper - 从安全的http存储库下载软件包包

时间:2013-12-13 13:49:44

标签: wix wix3.7 burn

我正在研究一个需要从需要身份验证的http存储库下载先决条件的刻录引导程序。 那么,我该如何处理这个请求?

谢谢!

1 个答案:

答案 0 :(得分:1)

知道了!这可以在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;
}