View Javadoc

1   package com.atlassian.plugins.rest.common.sal.websudo;
2   
3   import static com.google.common.base.Preconditions.checkNotNull;
4   import com.sun.jersey.api.model.AbstractMethod;
5   import com.sun.jersey.spi.container.ResourceFilter;
6   import com.sun.jersey.spi.container.ResourceFilterFactory;
7   
8   import javax.ws.rs.ext.Provider;
9   import java.util.Collections;
10  import java.util.List;
11  
12  /**
13   * <p>A {@link com.sun.jersey.spi.container.ResourceFilterFactory} that checks wether the client is authenticated or not.<p>
14   * @see WebSudoResourceFilter
15   */
16  @Provider
17  public class WebSudoResourceFilterFactory implements ResourceFilterFactory
18  {
19      private final WebSudoResourceContext authenticationContext;
20  
21      public WebSudoResourceFilterFactory(final WebSudoResourceContext authenticationContext)
22      {
23          this.authenticationContext = checkNotNull(authenticationContext);
24      }
25  
26      public List<ResourceFilter> create(final AbstractMethod abstractMethod)
27      {
28          return Collections.<ResourceFilter>singletonList(new WebSudoResourceFilter(abstractMethod, authenticationContext));
29      }
30  }