<fim-prefix>/*
 * Copyright 2012 JBoss Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.uberfire.security.server;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.uberfire.security.Resource;
import org.uberfire.security.ResourceManager;
import org.uberfire.security.Role;
import org.uberfire.security.impl.RoleImpl;
// BUG: CWE-264 Permissions, Privileges, and Access Controls
// import org.uberfire.security.server.util.AntPathMatcher;
// FIXED:
i<fim-middle>mport org.uberfire.commons.regex.util.AntPathMatcher;
import org.yaml.snakeyaml.Yaml;

import static java.util.Collections.*;
import static org.uberfire.commons.validation.PortablePreconditions.checkNo<fix-suffix>tNull;
import static org.uberfire.commons.validation.Preconditions.*;
import static org.uberfire.security.server.SecurityConstants.*;

public class URLResourceManager implements ResourceManager {

    private static final AntPathMatcher ANT_PATH_MATCHER = new AntPathMatcher();
    private static final Collection<Class<? extends Resource>> SUPPORTED_TYPES = new ArrayList<Class<? extends Resource>>( 1 ) {{
        add( URLResource.class );
    }};

    private static final String DEFAULT_CONFIG = "exclude:\n" +
            "   - /*.ico\n" +
            "   - /image/**\n" +
            "   - /css/**";

    private String configFile = URL_FILTER_CONFIG_YAML;

    private final Resources resources;
    private final Set<String> excludeCache = Collections.newSetFromMap( new ConcurrentHashMap<String, Boolean>() );

    public URLResourceManager( final String configFile ) {
        if ( configFile != null && !configFile.isEmpty() ) {
            this.configFile = configFile;
        }
        <|endoftext|>