| 1 | /* KeyStoreSpi.java --- Key Store Service Provider Interface
|
|---|
| 2 | Copyright (C) 1999 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This file is part of GNU Classpath.
|
|---|
| 5 |
|
|---|
| 6 | GNU Classpath is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | any later version.
|
|---|
| 10 |
|
|---|
| 11 | GNU Classpath is distributed in the hope that it will be useful, but
|
|---|
| 12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 14 | General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
|---|
| 18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|---|
| 19 | 02111-1307 USA.
|
|---|
| 20 |
|
|---|
| 21 | Linking this library statically or dynamically with other modules is
|
|---|
| 22 | making a combined work based on this library. Thus, the terms and
|
|---|
| 23 | conditions of the GNU General Public License cover the whole
|
|---|
| 24 | combination.
|
|---|
| 25 |
|
|---|
| 26 | As a special exception, the copyright holders of this library give you
|
|---|
| 27 | permission to link this library with independent modules to produce an
|
|---|
| 28 | executable, regardless of the license terms of these independent
|
|---|
| 29 | modules, and to copy and distribute the resulting executable under
|
|---|
| 30 | terms of your choice, provided that you also meet, for each linked
|
|---|
| 31 | independent module, the terms and conditions of the license of that
|
|---|
| 32 | module. An independent module is a module which is not derived from
|
|---|
| 33 | or based on this library. If you modify this library, you may extend
|
|---|
| 34 | this exception to your version of the library, but you are not
|
|---|
| 35 | obligated to do so. If you do not wish to do so, delete this
|
|---|
| 36 | exception statement from your version. */
|
|---|
| 37 |
|
|---|
| 38 | package java.security;
|
|---|
| 39 | import java.io.InputStream;
|
|---|
| 40 | import java.io.IOException;
|
|---|
| 41 | import java.io.OutputStream;
|
|---|
| 42 | import java.security.cert.CertificateException;
|
|---|
| 43 | import java.util.Date;
|
|---|
| 44 | import java.util.Enumeration;
|
|---|
| 45 |
|
|---|
| 46 | /**
|
|---|
| 47 | KeyStoreSpi is the Service Provider Interface (SPI) for the
|
|---|
| 48 | KeyStore class. This is the interface for providers to
|
|---|
| 49 | supply to implement a keystore for a particular keystore
|
|---|
| 50 | type.
|
|---|
| 51 |
|
|---|
| 52 | @since JDK 1.2
|
|---|
| 53 | @author Mark Benvenuto
|
|---|
| 54 | */
|
|---|
| 55 | public abstract class KeyStoreSpi
|
|---|
| 56 | {
|
|---|
| 57 | /**
|
|---|
| 58 | Constructs a new KeyStoreSpi
|
|---|
| 59 | */
|
|---|
| 60 | public KeyStoreSpi()
|
|---|
| 61 | {
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | /**
|
|---|
| 65 | Returns the key associated with given alias using the
|
|---|
| 66 | supplied password.
|
|---|
| 67 |
|
|---|
| 68 | @param alias an alias for the key to get
|
|---|
| 69 | @param password password to access key with
|
|---|
| 70 |
|
|---|
| 71 | @return the requested key, or null otherwise
|
|---|
| 72 |
|
|---|
| 73 | @throws NoSuchAlgorithmException if there is no algorithm
|
|---|
| 74 | for recovering the key
|
|---|
| 75 | @throws UnrecoverableKeyException key cannot be reocovered
|
|---|
| 76 | (wrong password).
|
|---|
| 77 | */
|
|---|
| 78 | public abstract Key engineGetKey(String alias, char[]password)
|
|---|
| 79 | throws NoSuchAlgorithmException, UnrecoverableKeyException;
|
|---|
| 80 |
|
|---|
| 81 | /**
|
|---|
| 82 | Gets a Certificate chain for the specified alias.
|
|---|
| 83 |
|
|---|
| 84 | @param alias the alias name
|
|---|
| 85 |
|
|---|
| 86 | @return a chain of Certificates ( ordered from the user's
|
|---|
| 87 | certificate to the Certificate Authority's ) or
|
|---|
| 88 | null if the alias does not exist or there is no
|
|---|
| 89 | certificate chain for the alias ( the alias refers
|
|---|
| 90 | to a trusted certificate entry or there is no entry).
|
|---|
| 91 | */
|
|---|
| 92 | public abstract java.security.cert.
|
|---|
| 93 | Certificate[] engineGetCertificateChain(String alias);
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | /**
|
|---|
| 97 | Gets a Certificate for the specified alias.
|
|---|
| 98 |
|
|---|
| 99 | If there is a trusted certificate entry then that is returned.
|
|---|
| 100 | it there is a key entry with a certificate chain then the
|
|---|
| 101 | first certificate is return or else null.
|
|---|
| 102 |
|
|---|
| 103 | @param alias the alias name
|
|---|
| 104 |
|
|---|
| 105 | @return a Certificate or null if the alias does not exist
|
|---|
| 106 | or there is no certificate for the alias
|
|---|
| 107 | */
|
|---|
| 108 | public abstract java.security.cert.
|
|---|
| 109 | Certificate engineGetCertificate(String alias);
|
|---|
| 110 |
|
|---|
| 111 | /**
|
|---|
| 112 | Gets entry creation date for the specified alias.
|
|---|
| 113 |
|
|---|
| 114 | @param alias the alias name
|
|---|
| 115 |
|
|---|
| 116 | @returns the entry creation date or null
|
|---|
| 117 | */
|
|---|
| 118 | public abstract Date engineGetCreationDate(String alias);
|
|---|
| 119 |
|
|---|
| 120 | /**
|
|---|
| 121 | Assign the key to the alias in the keystore, protecting it
|
|---|
| 122 | with the given password. It will overwrite an existing
|
|---|
| 123 | entry and if the key is a PrivateKey, also add the
|
|---|
| 124 | certificate chain representing the corresponding public key.
|
|---|
| 125 |
|
|---|
| 126 | @param alias the alias name
|
|---|
| 127 | @param key the key to add
|
|---|
| 128 | @password the password to protect with
|
|---|
| 129 | @param chain the certificate chain for the corresponding
|
|---|
| 130 | public key
|
|---|
| 131 |
|
|---|
| 132 | @throws KeyStoreException if it fails
|
|---|
| 133 | */
|
|---|
| 134 | public abstract void engineSetKeyEntry(String alias, Key key,
|
|---|
| 135 | char[]password,
|
|---|
| 136 | java.security.cert.
|
|---|
| 137 | Certificate[]chain) throws
|
|---|
| 138 | KeyStoreException;
|
|---|
|
|---|