Package org.xwiki.url
Interface URLSecurityManager
-
@Role @Unstable public interface URLSecurityManagerDedicated component to perform security checks on URLs.- Since:
- 13.3RC1, 12.10.7
- Version:
- $Id: 28d96d141d47e4114fcdc83e80e4699273519adf $
-
-
Field Summary
Fields Modifier and Type Field Description static StringBYPASS_DOMAIN_SECURITY_CHECK_CONTEXT_PROPERTYConstant to be used inExecutionContextwith the value"true"to bypass a check ofisDomainTrusted(URL).
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanisDomainTrusted(URL urlToCheck)Check if the givenURLcan be trusted based on the trusted domains of the wiki.default booleanisURITrusted(URI uri)Check if the given URI can be trusted.default URIparseToSafeURI(String serializedURI)Parse the given string to create a URI that is safe to use.
-
-
-
Field Detail
-
BYPASS_DOMAIN_SECURITY_CHECK_CONTEXT_PROPERTY
static final String BYPASS_DOMAIN_SECURITY_CHECK_CONTEXT_PROPERTY
Constant to be used inExecutionContextwith the value"true"to bypass a check ofisDomainTrusted(URL).- See Also:
- Constant Field Values
-
-
Method Detail
-
isDomainTrusted
boolean isDomainTrusted(URL urlToCheck)
Check if the givenURLcan be trusted based on the trusted domains of the wiki. This method check on both the list of trusted domains given by the configuration (seeURLConfiguration.getTrustedDomains()) and the list of aliases used by the wiki descriptors. Note that this method always returnstrueifURLConfiguration.isTrustedDomainsEnabled()returnstrue. Also the method will returntruewhenever theExecutionContextcontains a property namedBYPASS_DOMAIN_SECURITY_CHECK_CONTEXT_PROPERTYwith the value"true".- Parameters:
urlToCheck- the URL for which we want to know if the domain is trusted or not.- Returns:
trueif the URL domain can be trusted or if the check is skipped,falseotherwise
-
isURITrusted
@Unstable default boolean isURITrusted(URI uri)
Check if the given URI can be trusted. A URI can be trusted if:- it's not opaque (see
URIdocumentation for definition of opaque URI. TL;DR: a URI without//is opaque): note that following this, any URI such asmailto:acme@foo.orgwon't be trusted - it refers to a specific domain and this domain is trusted (see
isDomainTrusted(URL)) - it's completely relative: it doesn't refer to an external domain
- Parameters:
uri- the URI to check if it can be trusted or not- Returns:
trueonly if the URI can be trusted per the criteria given in the above documentation- Since:
- 14.10.4, 15.0
- it's not opaque (see
-
parseToSafeURI
@Unstable default URI parseToSafeURI(String serializedURI) throws URISyntaxException, SecurityException
Parse the given string to create a URI that is safe to use. This method throws aSecurityExceptionif the parsed URI is not safe to use according toisURITrusted(URI). It might also throw aURISyntaxExceptionif the parameter cannot be properly parsed. Note that this method might try to "repair" URI that are not parsed correctly byURI(String)(e.g. serialized uri containing spaces).- Parameters:
serializedURI- a string representing a URI that needs to be parsed.- Returns:
- a URI safe to use
- Throws:
URISyntaxException- if the given parameter cannot be properly parsedSecurityException- if the parsed URI is not safe according toisURITrusted(URI)- Since:
- 14.10.4, 15.0
-
-