Liferay:[SecurityPortletContainerWrapper:630]拒绝流程操作

时间:2016-11-07 19:29:02

标签: java liferay-6

我正在尝试在Liferay上传文件,我累了,我上传了“大”文件大小(超过2MB)。带日志

  

[SecurityPortletContainerWrapper:630]拒绝流程操作

<%@ include file="/init.jsp"%>
<portlet:actionURL var="intergrateURL" name="intergrate" />
<aui:form method="post" action="<%=intergrateURL.toString() %>" 
enctype="multipart/form-data">
     <aui:input name="messagContent1" />
     <aui:input name="messagContent2" />
     <aui:input name="uploadFileHere" type="file"/>
     <aui:button value="submit" type="submit"/>
</aui:form>

Portlet行动:

public class IntergratePortlet extends MVCPortlet {

public void intergrate(ActionRequest actionRequest,
        ActionResponse actionResponse) {

    UploadPortletRequest uploadPortletRequest = PortalUtil
            .getUploadPortletRequest(actionRequest);

    String messageContent1 = uploadPortletRequest.getFullFileName("uploadFileHere");
    String messageContent2 = ParamUtil.getString(actionRequest,
            "messagContent2");

    InputStream fileInputStream = null;
    byte[] fileByteArray; 

    MessageContentBean messageContentBean = new MessageContentBean();

    messageContentBean.setMessageContent1(messageContent1);
    messageContentBean.setMessageContent2(messageContent2);

    try {
        fileInputStream = uploadPortletRequest.getFileAsStream("uploadFileHere");
        fileByteArray = ReceiveMessage.convertInputStreamToByteArray(fileInputStream);
        messageContentBean.setFileMessage(fileByteArray);
    } catch (IOException e) {
        e.printStackTrace();
    }
    SendJmsMessage sendJmsMessage = new SendJmsMessage();
    sendJmsMessage.doSendMessage("103.74.121.22", messageContentBean);
    // sendJmsMessage.doSendMessage("127.0.0.1", messageContentBean);
}

}

1 个答案:

答案 0 :(得分:1)

有两个选项:

选项1:

在portlet.xml下面添加以禁用liferay的csrf保护:

    <init-param>
        <name>check-auth-token</name>
        <value>false</value>
    </init-param>

选项2:

更改$ {liferay_installed_dir} /portal-ext.properties以添加以下内容:

<强> auth.token.ignore.portlets = $ {形式} _war _ $ {门户}

建议您使用“选项1 ”,有关详细信息,请参阅this post

有关如何针对每个操作禁用CSRF,请使用关键字搜索liferay官方文档/ wiki:

  • “portlet.add.default.resource.check.whitelist”
  • “portlet.add.default.resource.check.whitelist.action”