Package org.apache.cxf.resource
Class URIResolver
- java.lang.Object
-
- org.apache.cxf.resource.URIResolver
-
- All Implemented Interfaces:
AutoCloseable
public class URIResolver extends Object implements AutoCloseable
Resolves a File, classpath resource, or URL according to the follow rules:- Check to see if a file exists, relative to the base URI.
- If the file doesn't exist, check the classpath
- If the classpath doesn't exist, try to create URL from the URI.
-
-
Constructor Summary
Constructors Constructor Description URIResolver()URIResolver(String path)URIResolver(String baseUriStr, String uriStr)URIResolver(String baseUriStr, String uriStr, Class<?> calling)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidcheckAllowedScheme(URL targetUrl)Verifies that the URL scheme is permitted by URIResolver allowlist policy.voidclose()static Set<String>getAllowedSchemes()FilegetFile()InputStreamgetInputStream()static Set<String>getLocalSchemes()Returns the URL schemes that refer to local resources: the allowed schemes (including any configured with the "org.apache.cxf.resource.uriresolver.allowedSchemes" system property) plus the OSGi bundle schemes, minus the network schemes (http, https, ftp).URIgetURI()URLgetURL()booleanisFile()static booleanisLocalReference(String href, String base)Returns whether a reference refers to a local resource, i.e. whether its scheme is one ofgetLocalSchemes().booleanisResolved()voidresolve(String baseUriStr, String uriStr, Class<?> callingCls)voidunresolve()
-
-
-
Constructor Detail
-
URIResolver
public URIResolver()
-
URIResolver
public URIResolver(String path) throws IOException
- Throws:
IOException
-
URIResolver
public URIResolver(String baseUriStr, String uriStr) throws IOException
- Throws:
IOException
-
URIResolver
public URIResolver(String baseUriStr, String uriStr, Class<?> calling) throws IOException
- Throws:
IOException
-
-
Method Detail
-
unresolve
public void unresolve()
-
resolve
public void resolve(String baseUriStr, String uriStr, Class<?> callingCls) throws IOException
- Throws:
IOException
-
checkAllowedScheme
public static void checkAllowedScheme(URL targetUrl) throws IOException
Verifies that the URL scheme is permitted by URIResolver allowlist policy.- Throws:
IOException
-
getLocalSchemes
public static Set<String> getLocalSchemes()
Returns the URL schemes that refer to local resources: the allowed schemes (including any configured with the "org.apache.cxf.resource.uriresolver.allowedSchemes" system property) plus the OSGi bundle schemes, minus the network schemes (http, https, ftp).
-
isLocalReference
public static boolean isLocalReference(String href, String base)
Returns whether a reference refers to a local resource, i.e. whether its scheme is one ofgetLocalSchemes(). A relative reference is checked against the scheme of the base URI, or is treated as local if there is no base URI. An archive URL such as jar:http://host/a.jar!/a.xsl is checked against the scheme of the archive location. A reference that is not a valid URI is not local.
-
getURI
public URI getURI()
-
getURL
public URL getURL()
-
getInputStream
public InputStream getInputStream()
-
isFile
public boolean isFile()
-
getFile
public File getFile()
-
isResolved
public boolean isResolved()
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
-