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 import java.io.InputStream;
22
23 /**
24 * Verify signatures using the Bouncy Castle OpenPGP provider.
25 *
26 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
27 */
28 public class BouncyCastleOpenPgpSignatureVerifier
29 implements OpenPgpSignatureVerifier
30 {
31 private static final int BUFFER_SIZE = 1024;
32
33 public SignatureStatus verifySignature( InputStream data, KeyRing keyRing )
34 throws OpenPgpException, UnknownKeyException
35 {
36 // TODO: implement
37 return null; //To change body of implemented methods use File | Settings | File Templates.
38 }
39
40 public SignatureStatus verifyDetachedSignature( InputStream data, InputStream signature, KeyRing keyRing,
41 boolean asciiArmored )
42 throws OpenPgpException, UnknownKeyException, IOException
43 {
44 OpenPgpStreamingSignatureVerifier verifier =
45 new BouncyCastleOpenPgpStreamingSignatureVerifier( signature, keyRing, asciiArmored );
46
47 byte[] buf = new byte[BUFFER_SIZE];
48
49 int len;
50 do
51 {
52 len = data.read( buf );
53 if ( len > 0 )
54 {
55 verifier.update( buf, 0, len );
56 }
57 }
58 while ( len >= 0 );
59
60 return verifier.finish();
61 }
62 }