View Javadoc

1   package org.apache.commons.openpgp;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  import java.io.IOException;
21  
22  /**
23   * An interface for updating an OpenPGP signature on the fly with streaming data.
24   *
25   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
26   */
27  public interface OpenPgpStreamingSigner
28  {
29      String ROLE = OpenPgpStreamingSigner.class.getName();
30  
31      /**
32       * Update the signature with the next block from the data buffer.
33       *
34       * @param buf the buffer
35       * @throws OpenPgpException if the buffer is not valid for updating the signature
36       */
37      void update( byte[] buf )
38          throws OpenPgpException;
39  
40      /**
41       * Update the signature with the next block from the data buffer.
42       *
43       * @param buf    the buffer
44       * @param offset offset within the buffer to start from
45       * @param length number of bytes in the buffer to read from
46       * @throws OpenPgpException if the buffer is not valid for updating the signature
47       */
48      void update( byte[] buf, int offset, int length )
49          throws OpenPgpException;
50  
51      /**
52       * Finish creating the signature.
53       *
54       * @return the completed signature
55       * @throws OpenPgpException if the signature is not in a consistent or complete state
56       */
57      byte[] finish()
58          throws OpenPgpException, IOException;
59  }