我的问题是这样的:
推送通知事件来源:
WL.Server.createEventSource({
name : 'PushEventSource',
poll : {
interval : 360,
onPoll : 'sendNotifications'
},
securityTest : 'mobileSecTest'
});
mobileSecTest安全测试:
<mobileSecurityTest name="mobileSecTest">
<testUser realm="LdapAdapterRealm"/>
<testDeviceId provisioningType="none"/>
</mobileSecurityTest>
sendNotifications() 实现:
var notificationServicesResourceName = "PushAdapter";
function sendNotifications(){
WL.Logger.info('Starting to send notifications');
var lockInvocationData = {
adapter : "SQLConnector",
procedure : "isLocked",
parameters : [ notificationServicesResourceName ]
};
var isLockedResult = WL.Server.invokeProcedure(lockInvocationData);
if (!isLockedResult.locked) {
lockInvocationData = {
adapter : "SQLConnector",
procedure : "acquireLock",
parameters : [ notificationServicesResourceName ]
};
WL.Server.invokeProcedure(lockInvocationData);
//Get the list of all notifications, from external database
var dbResponse = getAllUnsentNotifications();
var data = dbResponse.data ;
/////////////////THE REST OF THE LONG LONG CODE ////////////
//Reealse lock
lockInvocationData = {
adapter : "SQLConnector",
procedure : "releaseLock",
parameters : [ notificationServicesResourceName ]
};
WL.Server.invokeProcedure(lockInvocationData);
}
}
适配器 XML 文件:
<wl:adapter name="PushAdapter"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.worklight.com/integration"
xmlns:http="http://www.worklight.com/integration/http">
<displayName>PushAdapter</displayName>
<description>PushAdapter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>${com.ibm.moi.ci.host}</domain>
<port>${com.ibm.moi.ci.port}</port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="300" />
</connectivity>
<!-- Replace this with appropriate procedures -->
<procedure name="sendNotifications"/>
<procedure name="submitNotification"/>
</wl:adapter>
所以我现在就开始运行了。
这是一个安全问题。当您在本地工作站上的 worklight studio 和 liberty profile 上运行应用程序时,某些安全功能会被禁用,但生产环境并非如此。
在开发模式下,所有没有显式 securityTest 的过程默认都有 wl_inprotected 我认为他们这样做是为了能够从 Eclipse 调用过程。在生产环境中,安全性得到增强,wl_unprotected 不被视为默认安全测试。
因此,我所做的就是为执行链中的所有过程添加 securityTest="wl_unprotected",但 sendNotifications 过程除外,该过程应该保留而无需进行秒测试。
就是这样 !
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)