This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.xss-2.0.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-xss.git
commit d91fe2a05d40ae5736cbe642b728426b81210a0d Author: Karl Pauls <[email protected]> AuthorDate: Fri Apr 28 09:39:08 2017 +0000 Remove unused methods from XSSAPI and drop XSSAPIAdapterFactory (SLING-6793). git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/xss@1793026 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/sling/xss/XSSAPI.java | 23 ------ .../sling/xss/impl/XSSAPIAdapterFactory.java | 84 ---------------------- .../java/org/apache/sling/xss/impl/XSSAPIImpl.java | 20 ------ .../org/apache/sling/xss/impl/XSSAPIImplTest.java | 5 -- 4 files changed, 132 deletions(-) diff --git a/src/main/java/org/apache/sling/xss/XSSAPI.java b/src/main/java/org/apache/sling/xss/XSSAPI.java index 1819663..efb33ff 100644 --- a/src/main/java/org/apache/sling/xss/XSSAPI.java +++ b/src/main/java/org/apache/sling/xss/XSSAPI.java @@ -239,27 +239,4 @@ public interface XSSAPI { @Nonnull String filterHTML(@Nullable String source); - - // ============================================================================================= - // JCR-based URL MAPPING - // - - /** - * Returns an XSSAPI instance capable of mapping resource URLs. - * EITHER THIS OR THE RESOURCERESOLVER VERSION MUST BE USED WHEN VALIDATING HREFs! - * - * @param request the request from which to obtain the {@link org.apache.sling.xss.XSSAPI} - * @return an XSSAPI service capable of validating hrefs. - */ - XSSAPI getRequestSpecificAPI(SlingHttpServletRequest request); - - /** - * Returns an XSSAPI instance capable of mapping resource URLs. - * EITHER THIS OR THE REQUEST VERSION MUST BE USED WHEN VALIDATING HREFs! - * - * @param resourceResolver the resolver from which to obtain the {@link org.apache.sling.xss.XSSAPI} - * @return an XSSAPI service capable of validating hrefs. - */ - XSSAPI getResourceResolverSpecificAPI(ResourceResolver resourceResolver); - } diff --git a/src/main/java/org/apache/sling/xss/impl/XSSAPIAdapterFactory.java b/src/main/java/org/apache/sling/xss/impl/XSSAPIAdapterFactory.java deleted file mode 100644 index ab11816..0000000 --- a/src/main/java/org/apache/sling/xss/impl/XSSAPIAdapterFactory.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Licensed to the Apache Software Foundation (ASF) under one or - * more contributor license agreements. See the NOTICE file - * distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you 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.apache.sling.xss.impl; - -import javax.annotation.Nonnull; - -import org.apache.sling.api.SlingHttpServletRequest; -import org.apache.sling.api.adapter.AdapterFactory; -import org.apache.sling.api.resource.ResourceResolver; -import org.apache.sling.xss.XSSAPI; -import org.osgi.framework.Constants; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Adapter factory that adapts a {@link ResourceResolver} to a resourceResolver-specific - * {@link XSSAPI} service. - */ -@Component( - property = { - Constants.SERVICE_DESCRIPTION + "=Adapter for the XSSAPI service.", - Constants.SERVICE_VENDOR + "=The Apache Software Foundation", - AdapterFactory.ADAPTER_CLASSES + "=org.apache.sling.xss.XSSAPI", - AdapterFactory.ADAPTABLE_CLASSES + "=org.apache.sling.api.resource.ResourceResolver", - AdapterFactory.ADAPTABLE_CLASSES + "=org.apache.sling.api.SlingHttpServletRequest" - } -) -public class XSSAPIAdapterFactory implements AdapterFactory { - - private final Logger LOGGER = LoggerFactory.getLogger(XSSAPIAdapterFactory.class); - - @Reference - XSSAPI xssApi; - - @Override - public <AdapterType> AdapterType getAdapter(@Nonnull Object adaptable, @Nonnull Class<AdapterType> type) { - if (adaptable instanceof ResourceResolver) { - return getAdapter((ResourceResolver) adaptable, type); - } else if (adaptable instanceof SlingHttpServletRequest) { - return getAdapter((SlingHttpServletRequest) adaptable, type); - } else { - LOGGER.warn("Unable to handle adaptable {}", adaptable.getClass().getName()); - return null; - } - } - - @SuppressWarnings("unchecked") - private <AdapterType> AdapterType getAdapter(ResourceResolver resourceResolver, Class<AdapterType> type) { - if (resourceResolver != null) { - if (type == XSSAPI.class) { - return (AdapterType) xssApi.getResourceResolverSpecificAPI(resourceResolver); - } - } - LOGGER.error(String.format("Unable to adapt resourceResolver to type %s.", type.getName())); - return null; - } - - @SuppressWarnings("unchecked") - private <AdapterType> AdapterType getAdapter(SlingHttpServletRequest request, Class<AdapterType> type) { - if (request != null) { - if (type == XSSAPI.class) { - return (AdapterType) xssApi.getRequestSpecificAPI(request); - } - } - LOGGER.error(String.format("Unable to adapt request to type %s.", type.getName())); - return null; - } -} diff --git a/src/main/java/org/apache/sling/xss/impl/XSSAPIImpl.java b/src/main/java/org/apache/sling/xss/impl/XSSAPIImpl.java index c7cdac9..7fe2812 100644 --- a/src/main/java/org/apache/sling/xss/impl/XSSAPIImpl.java +++ b/src/main/java/org/apache/sling/xss/impl/XSSAPIImpl.java @@ -468,24 +468,4 @@ public class XSSAPIImpl implements XSSAPI { public String filterHTML(String source) { return xssFilter.filter(ProtectionContext.HTML_HTML_CONTENT, source); } - - // ============================================================================================= - // JCR-NAMESPACE MANGLING - // - - /** - * @see org.apache.sling.xss.XSSAPI#getRequestSpecificAPI(org.apache.sling.api.SlingHttpServletRequest) - */ - @Override - public XSSAPI getRequestSpecificAPI(final SlingHttpServletRequest request) { - return this; - } - - /** - * @see org.apache.sling.xss.XSSAPI#getResourceResolverSpecificAPI(org.apache.sling.api.resource.ResourceResolver) - */ - @Override - public XSSAPI getResourceResolverSpecificAPI(final ResourceResolver resourceResolver) { - return this; - } } diff --git a/src/test/java/org/apache/sling/xss/impl/XSSAPIImplTest.java b/src/test/java/org/apache/sling/xss/impl/XSSAPIImplTest.java index 11faf28..9590dc8 100644 --- a/src/test/java/org/apache/sling/xss/impl/XSSAPIImplTest.java +++ b/src/test/java/org/apache/sling/xss/impl/XSSAPIImplTest.java @@ -68,11 +68,6 @@ public class XSSAPIImplTest { return url.replaceAll("jcr:", "_jcr_"); } }); - - SlingHttpServletRequest mockRequest = mock(SlingHttpServletRequest.class); - when(mockRequest.getResourceResolver()).thenReturn(mockResolver); - - xssAPI = xssAPI.getRequestSpecificAPI(mockRequest); } catch (Exception e) { e.printStackTrace(); } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
