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