001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.springframework.boot.autoconfigure.security.servlet;
017
018import org.springframework.boot.autoconfigure.web.servlet.JerseyApplicationPath;
019import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
020import org.springframework.security.web.util.matcher.RequestMatcher;
021
022/**
023 * {@link RequestMatcherProvider} that provides an {@link AntPathRequestMatcher} that can
024 * be used for Jersey applications.
025 *
026 * @author Madhura Bhave
027 * @since 2.0.7
028 */
029public class JerseyRequestMatcherProvider implements RequestMatcherProvider {
030
031        private final JerseyApplicationPath jerseyApplicationPath;
032
033        public JerseyRequestMatcherProvider(JerseyApplicationPath jerseyApplicationPath) {
034                this.jerseyApplicationPath = jerseyApplicationPath;
035        }
036
037        @Override
038        public RequestMatcher getRequestMatcher(String pattern) {
039                return new AntPathRequestMatcher(
040                                this.jerseyApplicationPath.getRelativePath(pattern));
041        }
042
043}