All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.foreach.imageserver.client.ImageRequestHashBuilder Maven / Gradle / Ivy

There is a newer version: 6.2.1.RELEASE
Show newest version
package com.foreach.imageserver.client;

import com.foreach.imageserver.dto.ImageResolutionDto;
import com.foreach.imageserver.dto.ImageVariantDto;

/**
 * API for building a secure hash of image request parameters.
 * When the server is not operating in strict mode and both server and client have the same
 * {@link ImageRequestHashBuilder} configured, all requests containing a valid hash for their
 * parameters will be accepted.  Whereas otherwise only requests for resolutions that are registered
 * server-side will be accepted.
 *
 * @author Arne Vandamme
 * @see Md5ImageRequestHashBuilder
 */
public interface ImageRequestHashBuilder
{
	/**
	 * Calculate a security hash of the different parameters.
	 * Result can be empty if no hash could be calculated.
	 *
	 * @param context         of the image
	 * @param ratio           can be null
	 * @param imageResolution can be null
	 * @param imageVariant    requested - can be null
	 * @param size            can be empty
	 * @return calculated hash
	 */
	String calculateHash( String context,
	                      String ratio,
	                      ImageResolutionDto imageResolution,
	                      ImageVariantDto imageVariant,
	                      String... size );

	/**
	 * Create a default {@link Md5ImageRequestHashBuilder} implementation using
	 * a base token to be added to the parameters when calculating the hash.
	 *
	 * @param hashToken token to use for the MD5 hash
	 * @return builder
	 */
	static ImageRequestHashBuilder md5( String hashToken ) {
		return new Md5ImageRequestHashBuilder( hashToken );
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy