2

我正在尝试使用 Adob​​eDigital Publishing Suite Web Viewer. 我已经正确设置了我的 Web 查看器 - 它在我的网站中运行。但是,并不是验证每个用户都有权访问 Web 查看器正在访问的作品集。Adobe 有一些关于如何做到这一点的文档,但他们的文档似乎缺乏似乎 Adob​​e 要求我获取 Adob​​e 的用户名和密码 - 但这是不对的。我怀疑 Adob​​e 会邀请网络钓鱼。但这不是我迷失的唯一一点。

我当前的脚本如下:

    var wvQueryParamGroups = location.search.match(/[?&^#]wv=(s[\/%\-.\w]+)/),
    wvQueryParam = wvQueryParamGroups && wvQueryParamGroups.length === 2 ? decodeURIComponent(wvQueryParamGroups[1]) : null;

    function loadXMLDoc(url, successCallback, failCallback) {
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                var parser = new DOMParser();
                var xmlDoc = parser.parseFromString(xmlhttp.responseText, "application/xml");
                successCallback(xmlDoc);
            } else if (xmlhttp.readyState == 4 && xmlhttp.status == 0) {
                alert("unsuccessful cross-domain data access attempt?");
                failCallback(xmlhttp.status);
            } else if (xmlhttp.readyState == 4) {
                failCallback(xmlhttp.status);
            } else {
                console.log('readystate=' + xmlhttp.readyState + ', status=' + xmlhttp.status);
            }
        }
        xmlhttp.open("GET", url, true);
        xmlhttp.send();
    }

    function directEntitlementSignIn(directEntitlementURL, emailAddress, password, appID, authTokenSuccess, authTokenFail) {
        var response;
        if (!authTokenSuccess || !authTokenFail) {
            throw new Error('Callbacks are required: ');
        }
        loadXMLDoc(directEntitlementURL + '?emailAddress=' + emailAddress + '&password=' + password + '&appId=' + appID,
        handleToken = function (data) {
            token = data.documentElement.childNodes[0].innerHTML;
            authTokenSuccess(token);
        }
        );
    }

    function onAuthTokenSuccess(token) {
        alert(token);
        // pass the token into the Authenticator class's login method
    }

    function onAuthTokenFail(status) {
        alert("fail: " + status);
        // prompt the user to try logging in again
    }

    function signIn(emailAddress, password) {
        var deAPIURL = 'http://127.0.0.1/hostDemos r27/authHard/test.php';
        var emailAddress; // user's login ID.....get from form
        var password; // user's password ... get from form
        var appID = 'com.publisher.magazine';

        directEntitlementSignIn(deAPIURL, emailAddress, password, appID, onAuthTokenSuccess, onAuthTokenFail);
    }

    function eventCallback(ev) {
        if (ev.eventType == "paywall") {
            return false;
        }
        if (ev.eventType == "metadata") {
            return true;
        }
        console.log(ev);
        return true;
    }

    function errorCallback (message) {
        console.log(message);
        return true;
    }

    function redirectCallbackHandler (message) {
        console.log(message);
    }

    var wv_appName = "Professional Roofing";
    var wv_accountID = Account_ID_Is_Here; //Hiding account ID purposely
    var wv_folio = "August 2014 Issue";
    var wv_article = "Cover";
    var wv_url = '/s/' + wv_appName + '/' + wv_accountID + '/' + wv_folio + '/' + wv_article + '.html';
    console.log(wv_url);

    var bridge = adobeDPS.frameService.createFrame({
        boolIsFullScreen : true,
        parentDiv : 'mainContainer',
        wrapperClasses : 'uniqueFrame',
        iframeID : 'demoFrame',
        accountIDs : wv_accountID,
        wvParam : wvQueryParam ? wvQueryParam : wv_url,
        curtainClasses : 'mask hidden',
        eventCallback : eventCallback,
        errorCallback : errorCallback,
        redirectCallback : redirectCallbackHandler
    });
4

1 回答 1

1

Adobe 不需要您的用户名和密码,它们需要身份验证令牌。要使其工作,您需要:

  • 实施直接权利 API
  • 请您在 Adob​​e 中的客户代表创建一个集成商 ID

之后,您需要创建一个身份验证器:

  auth = adobeDPS.authenticationService.createAuthenticator(strAccountID, strIntegratorID);

并将 authToken 传递给它

 auth.login(token, successCalck, errorCallback)
于 2014-08-18T17:31:17.303 回答