summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/certsrv/kra/IKeyRecoveryAuthority.java
blob: b2d02f2a3ad441a77f2014b688d7de913703dc97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.kra;


import java.util.*;
import java.io.*;
import java.net.*;
import java.security.*;
import java.math.*;
import netscape.security.x509.*;
import com.netscape.certsrv.logging.*;
import com.netscape.certsrv.base.*;
import com.netscape.certsrv.dbs.*;
import com.netscape.certsrv.dbs.keydb.*;
import com.netscape.certsrv.dbs.replicadb.*;
import com.netscape.certsrv.request.*;
import com.netscape.certsrv.policy.*;
import com.netscape.certsrv.security.*;
import org.mozilla.jss.crypto.*;


/**
 * An interface represents key recovery authority. The
 * key recovery authority is responsibile for archiving
 * and recovering user encryption private keys.
 * <P>
 *
 * @version $Revision$, $Date$
 */
public interface IKeyRecoveryAuthority extends ISubsystem {

    public static final String ID = "kra";

    public final static String PROP_NAME = "name";
    public final static String PROP_HTTP = "http";
    public final static String PROP_POLICY = "policy";
    public final static String PROP_DBS = "dbs";
    public final static String PROP_TOKEN = "token";
    public final static String PROP_SHARE = "share";
    public final static String PROP_PROTECTOR = "protector";
    public final static String PROP_LOGGING = "logging";
    public final static String PROP_QUEUE_REQUESTS = "queueRequests";
    public final static String PROP_STORAGE_KEY = "storageUnit";
    public final static String PROP_TRANSPORT_KEY = "transportUnit";
    public static final String PROP_NEW_NICKNAME = "newNickname";
    public static final String PROP_KEYDB_INC = "keydbInc";

    public final static String PROP_NOTIFY_SUBSTORE = "notification";
    public final static String PROP_REQ_IN_Q_SUBSTORE = "requestInQ";

    /**
     * Returns the name of this subsystem.
     * <P>
     *
     * @return KRA name
     */
    public X500Name getX500Name();

    /**
     * Retrieves KRA request repository.
     * <P>
     *
     * @return request repository
     */
    public IRequestQueue getRequestQueue();

    /**
     * Retrieves the key repository. The key repository 
     * stores archived keys.
     * <P>
     */
    public IKeyRepository getKeyRepository();

    /**
     * Retrieves the Replica ID repository.
     *
     * @return KRA's Replica ID repository
     */
    public IReplicaIDRepository getReplicaRepository();

    /**
     * Enables the auto recovery state. Once KRA is in the auto 
     * recovery state, no recovery agents need to be present for
     * providing credentials. This feature is for enabling
     * user-based recovery operation.
     * <p>
     * 
     * @param cs list of agent credentials
     * @param on true if auto recovery state is on
     * @return current auto recovery state
     */
    public boolean setAutoRecoveryState(Credential cs[], boolean on);

    /**
     * Returns the current auto recovery state.
     *
     * @return true if auto recvoery state is on
     */
    public boolean getAutoRecoveryState();

    /**
     * Adds credentials to the given authorizated recovery operation.
     * In distributed recovery mode, recovery agent login to the
     * agent interface and submit its credential for a particular
     * recovery operation.
     *
     * @param id authorization identifier
     * @param creds list of credentials
     */
    public void addAutoRecovery(String id, Credential creds[]);

    /**
     * Removes a particular auto recovery operation.
     *
     * @param id authorization identifier
     */
    public void removeAutoRecovery(String id);

    /**
     * Returns the number of required agents. In M-out-of-N
     * recovery schema, only M agents are required even there
     * are N agents. This method returns M.
     *
     * @return number of required agents
     */
    public int getNoOfRequiredAgents() throws EBaseException;

    /**
     * Sets the number of required recovery agents
     *
     * @param number number of agents
     */
    public void setNoOfRequiredAgents(int number) throws EBaseException;

    /**
     * Returns the current recovery identifier.
     *
     * @return recovery identifier
     */
    public String getRecoveryID();

    /**
     * Returns a list of recovery identifiers.
     *
     * @return list of auto recovery identifiers
     */
    public Enumeration getAutoRecoveryIDs();

    /**
     * Returns the storage key unit that manages the
     * stoarge key.
     *
     * @return storage key unit
     */
    public IStorageKeyUnit getStorageKeyUnit();

    /**
     * Returns the transport key unit that manages the
     * transport key.
     *
     * @return transport key unit
     */
    public ITransportKeyUnit getTransportKeyUnit();

    /**
     * Returns the token that generates user key pairs for supporting server-side keygen
     *
     * @return keygen token
     */
    public CryptoToken getKeygenToken();

    /**
     * Adds entropy to the token used for supporting server-side keygen
	 * Parameters are set in the config file
     * @param logflag create log messages at info level to report entropy shortage
     */
	public void addEntropy(boolean logflag);


    /**
     * Returns the request listener that listens on
     * the request completion event.
     *
     * @return request listener
     */
    public IRequestListener getRequestInQListener();

    /**
     * Returns policy processor of the key recovery
     * authority.
     *
     * @return policy processor
     */
    public IPolicyProcessor getPolicyProcessor();

    /**
     * Returns the nickname of the transport certificate.
     *
     * @return transport certificate nickname.
     */
    public String getNickname();

    /**
     * Sets the nickname of the transport certificate.
     *
     * @param str nickname
     */
    public void setNickname(String str);

    /**
     * Returns the new nickname of the transport certifiate.
     *
     * @return new nickname
     */
    public String getNewNickName() throws EBaseException;

    /**
     * Sets the new nickname of the transport certifiate.
     *
     * @param name new nickname
     */
    public void setNewNickName(String name);

    /**
     * Logs event into key recovery authority logging.
     *
     * @param level log level
     * @param msg log message
     */
    public void log(int level, String msg);

    /**
     * Creates a request object to store attributes that
     * will not be serialized. Currently, request queue
     * framework will try to serialize all the attribute into
     * persistent storage. Things like passwords are not
     * desirable to be stored.
     *
     * @param id request id
     * @return volatile requests
     */
    public Hashtable createVolatileRequest(RequestId id);

    /**
     * Retrieves the request object.
     *
     * @param id request id
     * @return volatile requests
     */
    public Hashtable getVolatileRequest(RequestId id);

    /**
     * Destroys the request object.
     *
     * @param id request id
     */
    public void destroyVolatileRequest(RequestId id);

    public Vector getAppAgents(
        String recoveryID) throws EBaseException;

    /**
     * Creates error for a specific recovery operation.
     *
     * @param recoveryID recovery id
     * @param error error
     * @exception EBaseException failed to create error
     */
    public void createError(String recoveryID, String error)
        throws EBaseException;

    /**
     * Retrieves error by recovery identifier.
     *
     * @param recoveryID recovery id
     * @return error message
     */
    public String getError(String recoveryID)
        throws EBaseException;

    /**
     * Retrieves PKCS12 package by recovery identifier.
     * 
     * @param recoveryID recovery id
     * @return pkcs12 package in bytes
     */
    public byte[] getPk12(String recoveryID)
        throws EBaseException;

    /**
     * Creates PKCS12 package in memory.
     *
     * @param recoveryID recovery id
     * @param pk12 package in bytes
     */ 
    public void createPk12(String recoveryID, byte[] pk12)
        throws EBaseException;

    /**
     * Retrieves the transport certificate.
     */
    public org.mozilla.jss.crypto.X509Certificate getTransportCert();
}