Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
KeyStore | 34 | 0 | - | 0 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | ||
21 | package org.xwiki.crypto.store; | |
22 | ||
23 | import org.xwiki.component.annotation.Role; | |
24 | import org.xwiki.crypto.pkix.params.CertifiedKeyPair; | |
25 | import org.xwiki.crypto.pkix.params.CertifiedPublicKey; | |
26 | ||
27 | /** | |
28 | * Store and retrieve private key from a key store. | |
29 | * | |
30 | * @version $Id: 48c57f06586e2ccffe235f0a57b2534241c15e5d $ | |
31 | * @since 6.1M2 | |
32 | */ | |
33 | @Role | |
34 | public interface KeyStore | |
35 | { | |
36 | /** | |
37 | * Store a private key and its certificate into a given store. | |
38 | * | |
39 | * NOT VERY SECURE, since the key will be store AS IS without encryption. | |
40 | * | |
41 | * @param store the store where to save the key and its certificate. | |
42 | * @param keyPair the key pair to be stored. | |
43 | * @throws KeyStoreException on error. | |
44 | */ | |
45 | void store(StoreReference store, CertifiedKeyPair keyPair) throws KeyStoreException; | |
46 | ||
47 | /** | |
48 | * Store a private key and its certificate into a given store, encrypting the key with a password. | |
49 | * | |
50 | * @param store the store where to save the key and its certificate. | |
51 | * @param keyPair the key pair to be stored. | |
52 | * @param password the password to encrypt the private key. | |
53 | * @throws KeyStoreException on error. | |
54 | */ | |
55 | void store(StoreReference store, CertifiedKeyPair keyPair, byte[] password) throws KeyStoreException; | |
56 | ||
57 | /** | |
58 | * Retrieve a private key from a given store that may contains only a single key. | |
59 | * | |
60 | * @param store the single-key store where the key is stored with its certificate. | |
61 | * @return the certified key pair, or null if none have been found. | |
62 | * @throws KeyStoreException on error. | |
63 | */ | |
64 | CertifiedKeyPair retrieve(StoreReference store) throws KeyStoreException; | |
65 | ||
66 | /** | |
67 | * Retrieve the certified key pair from a given store that may contains only a single key and decrypt it using | |
68 | * the given password. | |
69 | * | |
70 | * @param store the single-key store where the key is stored encrypted with its certificate. | |
71 | * @param password the password to decrypt the private key. | |
72 | * @return the certified key pair, or null if none have been found. | |
73 | * @throws KeyStoreException on error. | |
74 | */ | |
75 | CertifiedKeyPair retrieve(StoreReference store, byte[] password) throws KeyStoreException; | |
76 | ||
77 | /** | |
78 | * Retrieve the certified key pair from a given store that match the given certificate. | |
79 | * | |
80 | * @param store the multi-key store where the key has been stored with its certificate. | |
81 | * @param publicKey for which the private key is requested. | |
82 | * @return the certified key pair corresponding to the given certificate, or null if none have been found. | |
83 | * @throws KeyStoreException on error. | |
84 | */ | |
85 | CertifiedKeyPair retrieve(StoreReference store, CertifiedPublicKey publicKey) throws KeyStoreException; | |
86 | ||
87 | /** | |
88 | * Retrieve the certified key pair from a given store that match the given certificate and decrypt it using | |
89 | * the given password. | |
90 | * | |
91 | * @param store the multi-key store where the key has been stored encrypted with its certificate | |
92 | * @param publicKey for which the private key is requested. | |
93 | * @param password the password to decrypt the private key. | |
94 | * @return the certified key pair corresponding to the given certificate, or null if none have been found. | |
95 | * @throws KeyStoreException on error. | |
96 | */ | |
97 | CertifiedKeyPair retrieve(StoreReference store, CertifiedPublicKey publicKey, byte[] password) | |
98 | throws KeyStoreException; | |
99 | } |