Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BouncyCastleOpenPgpSigner |
|
| 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 | import java.io.OutputStream; | |
23 | ||
24 | /** | |
25 | * Bouncy Castle implementation of the OpenPGP signer. | |
26 | * | |
27 | * @author <a href="mailto:brett@apache.org">Brett Porter</a> | |
28 | */ | |
29 | 15 | public class BouncyCastleOpenPgpSigner |
30 | implements OpenPgpSigner | |
31 | { | |
32 | private static final int BUFFER_SIZE = 1024; | |
33 | ||
34 | public void sign( InputStream data, OutputStream signedOutput, String keyId, KeyRing keyRing, boolean asciiArmor ) | |
35 | throws OpenPgpException | |
36 | { | |
37 | // TODO | |
38 | 0 | } |
39 | ||
40 | public void detachedSign( InputStream data, OutputStream signature, String keyId, KeyRing keyRing, | |
41 | boolean asciiArmor ) | |
42 | throws OpenPgpException, IOException | |
43 | { | |
44 | 2 | OpenPgpStreamingSigner updater = |
45 | new BouncyCastleOpenPgpStreamingSigner( signature, keyId, keyRing, asciiArmor ); | |
46 | ||
47 | 2 | byte[] buf = new byte[BUFFER_SIZE]; |
48 | ||
49 | int len; | |
50 | do | |
51 | { | |
52 | 4 | len = data.read( buf ); |
53 | 4 | if ( len > 0 ) |
54 | { | |
55 | 2 | updater.update( buf, 0, len ); |
56 | } | |
57 | } | |
58 | 4 | while ( len >= 0 ); |
59 | ||
60 | 2 | updater.finish(); |
61 | 2 | } |
62 | } |