View Javadoc

1   /*
2    * $Id: SecurityFilterMessageProcessor.java 22566 2011-07-27 22:52:53Z julien.eluard $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.processor;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.MuleException;
15  import org.mule.api.endpoint.ImmutableEndpoint;
16  import org.mule.api.security.SecurityFilter;
17  import org.mule.endpoint.EndpointAware;
18  
19  /**
20   * Filters the flow using the specified {@link SecurityFilter}. 
21   * If unauthorised the flow is stopped and therefore the
22   * message is not send or dispatched by the transport. When unauthorised the request
23   * message is returned as the response.
24   */
25  public class SecurityFilterMessageProcessor extends AbstractInterceptingMessageProcessor implements EndpointAware
26  {
27      private SecurityFilter filter;
28  
29      /**
30       * For IoC only
31       * @deprecated Use SecurityFilterMessageProcessor(SecurityFilter filter) instead
32       */
33      public SecurityFilterMessageProcessor()
34      {
35          super();
36      }
37  
38      public SecurityFilterMessageProcessor(SecurityFilter filter)
39      {
40          this.filter = filter;
41      }
42  
43      public SecurityFilter getFilter()
44      {
45          return filter;
46      }
47  
48      public MuleEvent process(MuleEvent event) throws MuleException
49      {
50          if (filter != null)
51          {
52              filter.doFilter(event);
53          }
54          return processNext(event);
55      }
56  
57      public void setFilter(SecurityFilter filter)
58      {
59          this.filter = filter;
60      }
61  
62      public void setEndpoint(ImmutableEndpoint ep)
63      {
64          if (filter instanceof EndpointAware)
65          {
66              ((EndpointAware) filter).setEndpoint(ep);
67          }
68      }
69  }