我尝试使用Adobe Digital Publishing Suite Web Viewer.
我正确设置了我的Web Viewer - 它正在我的网站中运行。但是,它不会验证每个用户是否可以访问Web Viewer正在访问的作品集。关于如何做到这一点,Adobe有一种documentation,但他们的文档似乎缺乏。似乎Adobe要求我吸引用户' Adobe的用户名和密码 - 但这不是正确的。我怀疑Adobe会邀请网络钓鱼。但这并不是我失去的唯一一点。
我目前的脚本如下:
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
});
答案 0 :(得分:1)
Adobe不需要您的用户名和密码,他们需要身份验证令牌。 为了使它成功,你需要:
之后你需要创建一个验证器:
auth = adobeDPS.authenticationService.createAuthenticator(strAccountID, strIntegratorID);
并传递给authToken
auth.login(token, successCalck, errorCallback)