如何模拟Worklight适配器基本身份验证

时间:2013-11-07 10:09:21

标签: authentication ibm-mobilefirst basic-authentication worklight-adapters

我正在尝试在Worklight项目中实现基本身份验证。

我在适配器xml中设置了以下代码。

    <authentication>
        <basic/>
        <serverIdentity>
        <username>admin</username>
        <password>admin</password>
        </serverIdentity>
    </authentication>

我的所有程序都必须具有此基本身份验证,因此我设置了以下程序:

    <procedure connectAs="server" name="getClass">
    <displayName>getClass</displayName>
    <description>Retrieves classdetails by id</description>
</procedure>

执行此操作时出现以下错误:

    FWLSE0101E: Caused by:  [project Klappr]java.io.IOException: Unexpected character '<' on line 1, column 1 
                                                                                                           com.worklight.common.log.filters.ErrorFilter

当我没有实现它时,我收到401错误,因为没有给出身份验证对象。

    [11:26:43.403] "Transfer failed, errors = Runtime: Failed to parse JSON string
    Error 401: An Authentication object was not found in the SecurityContext"

如何将此模拟为用户名“admin”,密码为“admin”而不是之前实现整个Worklight安全性?

有关基本身份验证的信息:

    http://pic.dhe.ibm.com/infocenter/wrklight/v5r0m5/index.jsp?topic=/com.ibm.worklight.help.doc/devref/r_the__authentication__element_o.html

1 个答案:

答案 0 :(得分:0)

适配器用于连接后端。在WL适配器中使用身份验证意味着您的后端需要基本身份验证。

您收到错误消息是因为您已经指定了returnsContentType:&#34; json&#34;并且您的后端返回XML / HTML。将returnedContentType设置为&#34; plain&#34;为了看到你的后端响应。

相关问题