<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dear Marc</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Sorry that I tried to reproduce the issue in my local test environment however I can't get body content anymore without ticking the stateful payload introspection option.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style=" background-color: rgb(255, 255, 255); display: inline !important">Besides I just enable 1 policy in order to simplify the test.</span><br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style=" background-color: rgb(255, 255, 255); display: inline !important">If you need more information, please let me know.</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style=" background-color: rgb(255, 255, 255); display: inline !important">Thanks for your help.</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>寄件者:</b> Marc Savy <marc.savy@redhat.com><br>
<b>寄件日期:</b> 2018年6月12日 下午 10:28<br>
<b>收件者:</b> 林 柏廷<br>
<b>副本:</b> Eric Wittmann; apiman-user@lists.jboss.org<br>
<b>主旨:</b> Re: [Apiman-user] Is it possible blocking request after request body parsing?</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">I haven't been able to reproduce this. Could you please provide a bit<br>
more information so I can debug this.<br>
<br>
1. What is your policy chain<br>
2. Can you provide a skeleton policy that reproduces the issue where<br>
you say you are able to get a parsed entity without ticking the<br>
appropriate box in the UI?<br>
<br>
<br>
On 30 April 2018 at 02:16, 林 柏廷 <btlin1025@hotmail.com> wrote:<br>
> Thanks for your information.<br>
> I'll enable this option for parsing request body.<br>
><br>
> ________________________________<br>
> 寄件者: Marc Savy <marc.savy@redhat.com><br>
> 寄件日期: 2018年4月26日 下午 07:36<br>
> 收件者: Eric Wittmann<br>
> 副本: 林 柏廷; apiman-user@lists.jboss.org<br>
><br>
> 主旨: Re: [Apiman-user] Is it possible blocking request after request body<br>
> parsing?<br>
><br>
> Thanks. I'll check it out and report back.<br>
><br>
> On 26 April 2018 at 12:26, Eric Wittmann <eric.wittmann@redhat.com> wrote:<br>
>> Yes that is the UI option I was referring to.<br>
>><br>
>> If the request payload is being parsed without that option being set, then<br>
>> there is a bug in the Apiman gateway. I will write up a bug report for<br>
>> that<br>
>> so that @marcsavy can have a look. :)<br>
>><br>
>> -Eric<br>
>><br>
>><br>
>> On Thu, Apr 26, 2018 at 4:36 AM, 林 柏廷 <btlin1025@hotmail.com> wrote:<br>
>>><br>
>>> Dear Eric<br>
>>><br>
>>> Thanks for your helpful information.<br>
>>> I can get request body with IPolicyContext object.<br>
>>> Besides, you also mentioned enable this on a per-API basis in the apiman<br>
>>> UI.<br>
>>> Is It "Enable stateful request payload insepction" in API implementation<br>
>>> tab?<br>
>>> I'm wondering because I didn't enable this option but can still get the<br>
>>> request body in doApply() with IPolicyContext.<br>
>>> What is the difference if I enable this option?<br>
>>> Thanks<br>
>>><br>
>>> Regards<br>
>>><br>
>>> ________________________________<br>
>>> 寄件者: Eric Wittmann <eric.wittmann@redhat.com><br>
>>> 寄件日期: 2018年4月25日 下午 08:15<br>
>>> 收件者: 林 柏廷<br>
>>> 副本: apiman-user@lists.jboss.org<br>
>>> 主旨: Re: [Apiman-user] Is it possible blocking request after request body<br>
>>> parsing?<br>
>>><br>
>>> Yes there is a feature where apiman will parse the request BEFORE<br>
>>> applying<br>
>>> the policies. This will make the HTTP request body available to all<br>
>>> policies in the chain, should they need them.<br>
>>><br>
>>> You can enable this on a per-API basis in the apiman UI.<br>
>>><br>
>>> When this feature is enabled, your custom policy can access the request<br>
>>> body as an object found in the IPolicyContext object. For example:<br>
>>><br>
>>> Object payload = context.getAttribute("apiman.request-payload");<br>
>>><br>
>>> The type of thing that you get depends on the API's endpoint type. The<br>
>>> endpoint type might be JSON, XML, or SOAP. I think it might be possible<br>
>>> to<br>
>>> have some other kind of endpoint type, but those three are handled by the<br>
>>> request body parser feature.<br>
>>><br>
>>> Here is what you'll get as that payload object, depending on endpoint<br>
>>> type:<br>
>>><br>
>>> JSON - Java Map object as a result of parsing the JSON data using Jackson<br>
>>> XML - org.w3c.dom.Document<br>
>>> Soap - javax.xml.soap.SOAPEnvelope<br>
>>> Anything Else - byte[]<br>
>>><br>
>>> So for example, if your endpoint type is XML, then you could do this in<br>
>>> your policy implementation (in the doApply() method):<br>
>>><br>
>>> org.w3c.dom.Document requestBody = (org.w3c.dom.Document)<br>
>>> context.gettAttribute("apiman.request-payload");<br>
>>><br>
>>> And then you could make some decision using the request data and e.g.<br>
>>> call<br>
>>> doFailure().<br>
>>><br>
>>> Also note - you can *change* the request body at this point as well. For<br>
>>> example you could apply a XML Transformation to the w3c Document,<br>
>>> resulting<br>
>>> in a new w3c Document object, which you could store in the Policy Context<br>
>>> (at the same key, obviously). That new document would then get<br>
>>> serialized<br>
>>> and sent as the request body to the backing API impl. There may be some<br>
>>> Content-Length issues if you do that, I can't remember...<br>
>>><br>
>>> -Eric<br>
>>><br>
>>><br>
>>> On Wed, Apr 25, 2018 at 1:29 AM, 林 柏廷 <btlin1025@hotmail.com> wrote:<br>
>>><br>
>>> Hi all,<br>
>>> I would like to customize a policy, which parses the request body and<br>
>>> blocks the request in case.<br>
>>> in <a href="http://www.apiman.io/latest/developer-guide.html">http://www.apiman.io/latest/developer-guide.html</a> 4.2.1.2 IData policy,<br>
>>> it describes:<br>
>>> The request or response body will not begin streaming before the<br>
>>> corresponding doApply has been called, however, it is still possible to<br>
>>> interrupt the conversation during the streaming phase by signalling<br>
>>> doFailure or doError.<br>
>>> When I trace the transformation-policy source code, doApply() executes<br>
>>> before getRequestDataHandler() which matches the description.<br>
>>> In doApply() I can blocks the request via chain.doFailure() however I<br>
>>> have<br>
>>> no idea how to interrupt/block request in getRequestDataHandler().<br>
>>> Besides, I found following mail group which is similar to my question.<br>
>>> Eric also points it's possible to parse the body before apply in request:<br>
>>><br>
>>> On Thu, Feb 2, 2017 at 10:31 PM, Eric Wittmann <<br>
>>> eric.wittmann at redhat.com> wrote:<br>
>>><br>
>>> The bottom line here is that you cannot return a Policy Failure (or<br>
>>> customize it) based on information in the response body. The response<br>
>>> is<br>
>>> streamed from the back-end to the client, and at the time streaming<br>
>>> begins,<br>
>>> the response code and HTTP headers have already been sent.<br>
>>><br>
>>> It sounds to me like you're asking for a feature where you can parse<br>
>>> the response body *before* the policy's "apply" method is invoked. we<br>
>>> have<br>
>>> such a feature for requests, but not for responses. I suspect core<br>
>>> changes<br>
>>> to apiman would be required to enable that. It seems like a reasonable<br>
>>> request to me, as long as users of the feature understand the<br>
>>> performance<br>
>>> and memory requirements of enabling it.<br>
>>><br>
>>> -Eric<br>
>>><br>
>>> Thanks for any comments in advance.<br>
>>> Kind Regards<br>
>>> BT<br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> Apiman-user mailing list<br>
>>> Apiman-user@lists.jboss.org<br>
>>> <a href="https://lists.jboss.org/mailman/listinfo/apiman-user">https://lists.jboss.org/mailman/listinfo/apiman-user</a><br>
>>><br>
>>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> Apiman-user mailing list<br>
>> Apiman-user@lists.jboss.org<br>
>> <a href="https://lists.jboss.org/mailman/listinfo/apiman-user">https://lists.jboss.org/mailman/listinfo/apiman-user</a><br>
>><br>
</div>
</span></font></div>
</body>
</html>