How to use EventResolver

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use EventResolver

yangjun2
How to use EventResolver , and when use handleEvent of Filter?
Best Regards,
Young
Reply | Threaded
Open this post in threaded view
|

Re: How to use EventResolver

oleksiys
Administrator
Hi,


> How to use EventResolver , and when use handleEvent of Filter?
You shouldn't use EventResolver (we have to change it to be package
private).

handleEvent is used to process Filters events, which they may send each
other using:
FilterChainContext.notifyUpstream/Downstream(...) methods.


Hope this helps.

WBR,
Alexey.

> -----
> Best Regards.
> yangjun
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/How-to-use-EventResolver-tp4510665p4510665.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: How to use EventResolver

yangjun2
Hi,
   When I debug  SSLFilter handleEvent() method,but no hit it.

    @Override
    public NextAction handleEvent(FilterChainContext ctx, FilterChainEvent event) throws IOException {
        if (event.type() == CertificateEvent.TYPE) {
            final CertificateEvent ce = (CertificateEvent) event;
            ce.certs = getPeerCertificateChain(getSSLEngine(ctx.getConnection()),
                                               ctx,
                                               ce.needClientAuth);
            return ctx.getStopAction();
        }
        return ctx.getInvokeAction();
    }
Best Regards,
Young
Reply | Threaded
Open this post in threaded view
|

Re: How to use EventResolver

Ryan Lubke-2
In the case of that particular event, it will only be triggered under
specific circumstances.

See :
org.glassfish.grizzly.http.server.util.RequestUtils.populateCertificateAttribute(final
Request request).



On 6/21/11 7:29 AM, yangjun2 wrote:

> Hi,
>     When I debug  SSLFilter handleEvent() method,but no hit it.
>
>      @Override
>      public NextAction handleEvent(FilterChainContext ctx, FilterChainEvent
> event) throws IOException {
>          if (event.type() == CertificateEvent.TYPE) {
>              final CertificateEvent ce = (CertificateEvent) event;
>              ce.certs =
> getPeerCertificateChain(getSSLEngine(ctx.getConnection()),
>                                                 ctx,
>                                                 ce.needClientAuth);
>              return ctx.getStopAction();
>          }
>          return ctx.getInvokeAction();
>      }
>
> -----
> Best Regards.
> yangjun
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/How-to-use-EventResolver-tp4510665p4510797.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: How to use EventResolver

oleksiys
Administrator
In reply to this post by yangjun2
Hi,

currently this is used in http-server module.

class org.glassfish.grizzly.http.server.util.RequestUtils

     public static Object populateCertificateAttribute(final Request
request) {
         Object certificates = null;

         if (request.getRequest().isSecure()) {
             SSLFilter.CertificateEvent event = new
SSLFilter.CertificateEvent(true);
             try {
                 request.getContext().notifyDownstream(event);
             } catch (IOException ioe) {
                 if (LOGGER.isLoggable(Level.FINE)) {
                     LOGGER.log(Level.FINE, ioe.toString(), ioe);
                 }
             }
             certificates = event.getCertificates();
             request.setAttribute(SSLSupport.CERTIFICATE_KEY, certificates);
         }

         return certificates;
     }


You can try to make a similar notifyDownstream(...) call from the filter
next to SSLFilter to check how it works.

WBR,
Alexey.

On 06/21/2011 04:29 PM, yangjun2 wrote:

> Hi,
>     When I debug  SSLFilter handleEvent() method,but no hit it.
>
>      @Override
>      public NextAction handleEvent(FilterChainContext ctx, FilterChainEvent
> event) throws IOException {
>          if (event.type() == CertificateEvent.TYPE) {
>              final CertificateEvent ce = (CertificateEvent) event;
>              ce.certs =
> getPeerCertificateChain(getSSLEngine(ctx.getConnection()),
>                                                 ctx,
>                                                 ce.needClientAuth);
>              return ctx.getStopAction();
>          }
>          return ctx.getInvokeAction();
>      }
>
> -----
> Best Regards.
> yangjun
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/How-to-use-EventResolver-tp4510665p4510797.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.