| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| BouncyCastleOpenPgpSignatureVerifier |
|
| 2.0;2 |
| 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 | 17 | 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 | 0 | 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 | throws OpenPgpException, UnknownKeyException, IOException | |
| 42 | { | |
| 43 | 17 | OpenPgpStreamingSignatureVerifier verifier = |
| 44 | new BouncyCastleOpenPgpStreamingSignatureVerifier( signature, keyRing ); | |
| 45 | ||
| 46 | 15 | byte[] buf = new byte[BUFFER_SIZE]; |
| 47 | ||
| 48 | int len; | |
| 49 | do | |
| 50 | { | |
| 51 | 30 | len = data.read( buf ); |
| 52 | 30 | if ( len > 0 ) |
| 53 | { | |
| 54 | 15 | verifier.update( buf, 0, len ); |
| 55 | } | |
| 56 | } | |
| 57 | 30 | while ( len >= 0 ); |
| 58 | ||
| 59 | 15 | return verifier.finish(); |
| 60 | } | |
| 61 | } |