00001 /* 00002 * Copyright (c) 2004 X-Way Rights 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_BEE_SECURITY_SECURITY_H 00024 #define _CLASS_BEE_SECURITY_SECURITY_H 00025 00026 #ifdef __cplusplus 00027 00028 #include "beecrypt/c++/util/ArrayList.h" 00029 using beecrypt::util::ArrayList; 00030 #include "beecrypt/c++/security/cert/CertificateFactory.h" 00031 using beecrypt::security::cert::CertificateFactory; 00032 #include "beecrypt/c++/security/cert/CertPathValidator.h" 00033 using beecrypt::security::cert::CertPathValidator; 00034 #include "beecrypt/c++/crypto/Cipher.h" 00035 using beecrypt::crypto::Cipher; 00036 #include "beecrypt/c++/crypto/KeyAgreement.h" 00037 using beecrypt::crypto::KeyAgreement; 00038 #include "beecrypt/c++/crypto/Mac.h" 00039 using beecrypt::crypto::Mac; 00040 #include "beecrypt/c++/crypto/SecretKeyFactory.h" 00041 using beecrypt::crypto::SecretKeyFactory; 00042 00043 namespace beecrypt { 00044 namespace security { 00047 class BEECRYPTCXXAPI Security 00048 { 00049 friend class AlgorithmParameterGenerator; 00050 friend class AlgorithmParameters; 00051 friend class ::CertificateFactory; 00052 friend class ::CertPathValidator; 00053 friend class ::Cipher; 00054 friend class ::KeyAgreement; 00055 friend class KeyFactory; 00056 friend class KeyPairGenerator; 00057 friend class KeyStore; 00058 friend class ::Mac; 00059 friend class MessageDigest; 00060 friend class ::SecretKeyFactory; 00061 friend class SecureRandom; 00062 friend class Signature; 00063 00064 private: 00065 struct spi 00066 { 00067 Object* cspi; 00068 String name; 00069 const Provider* prov; 00070 00071 spi(Object* cspi, const Provider*, const String&); 00072 }; 00073 00074 static spi* getSpi(const String& name, const String& type) throw (NoSuchAlgorithmException); 00075 static spi* getSpi(const String& algo, const String& type, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException); 00076 static spi* getSpi(const String& algo, const String& type, const Provider&) throw (NoSuchAlgorithmException); 00077 static spi* getFirstSpi(const String& type); 00078 00079 static const String& getKeyStoreDefault(); 00080 00081 static bool _init; 00082 static Properties _props; 00083 static ArrayList<Provider> _providers; 00084 00085 static void initialize(); 00086 00087 public: 00088 static int addProvider(Provider* provider); 00089 static int insertProviderAt(Provider* provider, int position) throw (IndexOutOfBoundsException); 00090 static void removeProvider(const String& name); 00091 static Provider* getProvider(const String& name); 00092 static array<Provider*> getProviders(); 00093 static const String* getProperty(const String& key) throw (); 00094 }; 00095 } 00096 } 00097 00098 #endif 00099 00100 #endif