001 package org.apache.commons.openpgp; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one or more 005 * contributor license agreements. See the NOTICE file distributed with 006 * this work for additional information regarding copyright ownership. 007 * The ASF licenses this file to You under the Apache License, Version 2.0 008 * (the "License"); you may not use this file except in compliance with 009 * the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 */ 019 020 import java.io.IOException; 021 import java.io.InputStream; 022 023 import org.bouncycastle.openpgp.PGPException; 024 import org.bouncycastle.openpgp.PGPPublicKey; 025 import org.bouncycastle.openpgp.PGPSecretKey; 026 027 /** 028 * Interface describing a key ring for use in signing or verifying data. 029 * 030 * @todo separate pub/priv and better error handling 031 * 032 * @author <a href="mailto:brett@apache.org">Brett Porter</a> 033 */ 034 public interface KeyRing 035 { 036 String ROLE = KeyRing.class.getName(); 037 038 /** 039 * Get the key ID of the first secret key that was added to the keyring. 040 */ 041 String getFirstKeyId(); 042 043 /** 044 * @return 045 * @todo seems like the wrong place 046 */ 047 char[] getPassword(); 048 049 /** 050 * @param keyId 051 * @return 052 * @todo remove BC specifics 053 */ 054 PGPSecretKey getSecretKey( String keyId ); 055 056 /** 057 * @param keyId 058 * @return 059 * @todo remove BC specifics 060 */ 061 PGPPublicKey getPublicKey( String keyId ); 062 063 /** 064 * @param keyId 065 * @return 066 * @todo remove BC specifics 067 */ 068 PGPSecretKey getSecretKey( long keyId ); 069 070 /** 071 * @param keyId 072 * @return 073 * @todo remove BC specifics 074 */ 075 PGPPublicKey getPublicKey( long keyId ); 076 077 void addPublicKeyRing( InputStream inputStream ) 078 throws IOException, PGPException; 079 }