001/* 002 * Copyright 2024 Emmanuel Bourg 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package net.jsign.spi; 018 019import java.io.File; 020import java.io.IOException; 021import java.nio.charset.Charset; 022 023import net.jsign.Signable; 024 025/** 026 * Service Provider Interface for {@link Signable} implementations 027 * 028 * @since 7.0 029 */ 030public interface SignableProvider { 031 032 /** 033 * Tells if the provider supports the specified file. 034 * 035 * @param file the file to be signed 036 * @return <tt>true</tt> if the provider supports the file, <tt>false</tt> otherwise 037 * @throws IOException if an I/O error occurs 038 */ 039 boolean isSupported(File file) throws IOException; 040 041 /** 042 * Creates a Signable instance for the specified file. 043 * 044 * @param file the file to be signed 045 * @param encoding the character encoding (for text files only). 046 * @return the signable object for the specified file 047 * @throws IOException if an I/O error occurs 048 */ 049 Signable create(File file, Charset encoding) throws IOException; 050}