    001// Licensed under the Apache License, Version 2.0 (the "License");
    002// you may not use this file except in compliance with the License.
    003// You may obtain a copy of the License at
    004//
    005//     http://www.apache.org/licenses/LICENSE-2.0
    006//
    007// Unless required by applicable law or agreed to in writing, software
    008// distributed under the License is distributed on an "AS IS" BASIS,
    009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    010// See the License for the specific language governing permissions and
    011// limitations under the License.
    012
    013package org.apache.tapestry5.services;
    014
    015import org.apache.tapestry5.ioc.annotations.UsesConfiguration;
    016
    017import java.net.URL;
    018
    019/**
    020 * Responsible for determining which classpath resources require checksums, and for generating checksums for such
    021 * resources.
    022 *
    023 * The service's configuration identifies which file extensions will be secured using an checksum. The default list
    024 * (in Tapestry 5.3) is
    025 * "class" and "tml". Note that in 5.4, there are no longer any contributions to this service by Tapestry, and
    026 * that the service is not normally instantiated: it is maintained for backwards compatibility, in case
    027 * applications or third-party modules make a contribution.
    028 *
    029 * @see org.apache.tapestry5.ioc.internal.util.ClasspathResource
    030 * @see org.apache.tapestry5.internal.services.ClasspathAssetFactory
    031 * @deprecated Deprecated in 5.4 with no replacement; see release notes about classpath assets moving
    032 *             to /META-INF/assets/, and content checksums inside asset URLs
    033 */
    034@UsesConfiguration(String.class)
    035public interface ResourceDigestGenerator
    036{
    037    /**
    038     * Examines the path (typically, the file name extension at the end of the path) to determine if a checksum is
    039     * required for the path. The path is {@link org.apache.tapestry5.ioc.Resource} style, without a leading slash.
    040     *
    041     * As of Tapestry 5.4, simply returns false.
    042     */
    043    boolean requiresDigest(String path);
    044
    045    /**
    046     * Reads the content of a URL (presumably, for a resource on the classpath) and generates a digest of its content.
    047     * This digest will be incorporated into the URL provided to the client, to verify that the client has been
    048     * "granted" access to this resource. This is only used for resources where {@link #requiresDigest(String)} is
    049     * true.
    050     *
    051     * As of Tapestry 5.4, simply returns null.
    052     *
    053     * @param url
    054     * @return the digest for the resource
    055     */
    056    String generateDigest(URL url);
    057}