View Javadoc
1   /*
2    * This file is part of ***  M y C o R e  ***
3    * See http://www.mycore.de/ for details.
4    *
5    * MyCoRe is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * MyCoRe is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with MyCoRe.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package org.mycore.frontend.jersey.access;
20  
21  import java.io.IOException;
22  import java.util.function.Supplier;
23  
24  import jakarta.annotation.Priority;
25  import jakarta.ws.rs.Priorities;
26  import jakarta.ws.rs.container.ContainerRequestContext;
27  import jakarta.ws.rs.container.ContainerRequestFilter;
28  
29  @Priority(Priorities.AUTHENTICATION - 1)
30  public class MCRRequestScopeACLFilter implements ContainerRequestFilter {
31      public static String ACL_INSTANT_KEY = "requestScopeACL";
32  
33      private static final MCRRequestScopeACLFactory ACL_FACTORY = new MCRRequestScopeACLFactory();
34  
35      @Override
36      public void filter(ContainerRequestContext requestContext) throws IOException {
37          requestContext.setProperty(ACL_INSTANT_KEY, (Supplier<MCRRequestScopeACL>) ACL_FACTORY::provide);
38      }
39  }