c++/security/KeyStore.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 Beeyond Software Holding BV
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00023 #ifndef _CLASS_KEYSTORE_H
00024 #define _CLASS_KEYSTORE_H
00025 
00026 #include "beecrypt/api.h"
00027 
00028 #ifdef __cplusplus
00029 
00030 #include "beecrypt/c++/io/InputStream.h"
00031 using beecrypt::io::InputStream;
00032 #include "beecrypt/c++/io/OutputStream.h"
00033 using beecrypt::io::OutputStream;
00034 #include "beecrypt/c++/lang/Object.h"
00035 using beecrypt::lang::Object;
00036 #include "beecrypt/c++/security/KeyStoreSpi.h"
00037 using beecrypt::security::KeyStoreSpi;
00038 #include "beecrypt/c++/security/KeyStoreException.h"
00039 using beecrypt::security::KeyStoreException;
00040 #include "beecrypt/c++/security/PrivateKey.h"
00041 using beecrypt::security::PrivateKey;
00042 #include "beecrypt/c++/security/Provider.h"
00043 using beecrypt::security::Provider;
00044 #include "beecrypt/c++/security/NoSuchProviderException.h"
00045 using beecrypt::security::NoSuchProviderException;
00046 
00047 namespace beecrypt {
00048     namespace security {
00051         class BEECRYPTCXXAPI KeyStore : public beecrypt::lang::Object
00052         {
00053         #if FOR_NEXT_VERSION_COMPATIBLE_WITH_JAVA_1_5
00054         public:
00055             class BEECRYPTCXXAPI Entry : public beecrypt::lang::Object
00056             {
00057             public:
00058                 virtual ~Entry() {};
00059             };
00060 
00061             class BEECRYPTCXXAPI PrivateKeyEntry : public Entry
00062             {
00063             private:
00064                 PrivateKey* _pri;
00065                 vector<Certificate*> _chain;
00066 
00067             public:
00068                 PrivateKeyEntry(const PrivateKey* privateKey, vector<Certificate*> chain);
00069                 virtual ~PrivateKeyEntry() {};
00070 
00071                 virtual const Certificate* getCertificate() const;
00072                 virtual const vector<Certificate*>* getCertificateChain() const;
00073                 virtual const PrivateKey* getPrivateKey() const;
00074             };
00075 
00076             class TrustedCertificateEntry : public Entry
00077             {
00078             private:
00079                 Certificate* _cert;
00080 
00081             public:
00082                 TrustedCertificateEntry(const Certificate& cert);
00083                 virtual ~TrustedCertificateEntry() {};
00084 
00085                 virtual const Certificate* getTrustedCertificate() const;
00086             };
00087         #endif
00088 
00089         public:
00090             static KeyStore* getInstance(const String& type) throw (KeyStoreException);
00091             static KeyStore* getInstance(const String& type, const String& provider) throw (KeyStoreException, NoSuchProviderException);
00092             static KeyStore* getInstance(const String& type, const Provider& provider) throw (KeyStoreException);
00093 
00094             static const String& getDefaultType();
00095 
00096         private:
00097             KeyStoreSpi*    _kspi;
00098             const Provider* _prov;
00099             String          _type;
00100             bool            _init;
00101 
00102         protected:
00103             KeyStore(KeyStoreSpi* spi, const Provider* provider, const String& type);
00104 
00105         public:
00106             virtual ~KeyStore();
00107 
00108             Enumeration* aliases();
00109             bool containsAlias(const String& alias) throw (KeyStoreException);
00110 
00111             const Certificate* getCertificate(const String& alias) throw (KeyStoreException);
00112             const String& getCertificateAlias(const Certificate& cert) throw (KeyStoreException);
00113             const vector<Certificate*>* getCertificateChain(const String& alias) throw (KeyStoreException);
00114             bool isCertificateEntry(const String& alias) throw (KeyStoreException);
00115             void setCertificateEntry(const String& alias, const Certificate& cert) throw (KeyStoreException);
00116                 
00117             void deleteEntry(const String& alias) throw (KeyStoreException);
00118                 
00119             Key* getKey(const String& alias, const array<javachar>& password) throw (KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException);
00120             bool isKeyEntry(const String& alias) throw (KeyStoreException);
00121             void setKeyEntry(const String& alias, const bytearray& key, const vector<Certificate*>&) throw (KeyStoreException);
00122             void setKeyEntry(const String& alias, const Key& key, const array<javachar>& password, const vector<Certificate*>&) throw (KeyStoreException);
00123 
00124             size_t size() const throw (KeyStoreException);
00125 
00126             void load(InputStream* in, const array<javachar>* password) throw (IOException, NoSuchAlgorithmException, CertificateException);
00127             void store(OutputStream& out, const array<javachar>* password) throw (KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException);
00128 
00129             const String& getType() const throw ();
00130             const Provider& getProvider() const throw ();
00131         };
00132     }
00133 }
00134 
00135 #endif
00136 
00137 #endif

Generated on Wed Aug 22 06:25:06 2007 for BeeCrypt by  doxygen 1.5.2