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  import java.io.InputStream;
22  
23  import org.bouncycastle.openpgp.PGPException;
24  import org.bouncycastle.openpgp.PGPPublicKey;
25  import org.bouncycastle.openpgp.PGPSecretKey;
26  
27  /**
28   * Interface describing a key ring for use in signing or verifying data.
29   * 
30   * @todo separate pub/priv and better error handling
31   *
32   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
33   */
34  public interface KeyRing
35  {
36      String ROLE = KeyRing.class.getName();
37  
38      /**
39       * Get the key ID of the first secret key that was added to the keyring.
40       */
41      String getFirstKeyId();
42  
43      /**
44       * @return
45       * @todo seems like the wrong place
46       */
47      char[] getPassword();
48  
49      /**
50       * @param keyId
51       * @return
52       * @todo remove BC specifics
53       */
54      PGPSecretKey getSecretKey( String keyId );
55  
56      /**
57       * @param keyId
58       * @return
59       * @todo remove BC specifics
60       */
61      PGPPublicKey getPublicKey( String keyId );
62  
63      /**
64       * @param keyId
65       * @return
66       * @todo remove BC specifics
67       */
68      PGPSecretKey getSecretKey( long keyId );
69  
70      /**
71       * @param keyId
72       * @return
73       * @todo remove BC specifics
74       */
75      PGPPublicKey getPublicKey( long keyId );
76  
77      void addPublicKeyRing( InputStream inputStream )
78          throws IOException, PGPException;
79  }