Back to index

lightning-sunbird  0.9+nobinonly
nsKeyModule.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Initial Developer of the Original Code is Google Inc.
00015  * Portions created by the Initial Developer are Copyright (C) 2006
00016  * the Initial Developer. All Rights Reserved.
00017  *
00018  * Contributor(s):
00019  *   Tony Chang <tc@google.com>
00020  *
00021  * Alternatively, the contents of this file may be used under the terms of
00022  * either the GNU General Public License Version 2 or later (the "GPL"), or
00023  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00024  * in which case the provisions of the GPL or the LGPL are applicable instead
00025  * of those above. If you wish to allow use of your version of this file only
00026  * under the terms of either the GPL or the LGPL, and not to allow others to
00027  * use your version of this file under the terms of the MPL, indicate your
00028  * decision by deleting the provisions above and replace them with the notice
00029  * and other provisions required by the GPL or the LGPL. If you do not delete
00030  * the provisions above, a recipient may use your version of this file under
00031  * the terms of any one of the MPL, the GPL or the LGPL.
00032  *
00033  * ***** END LICENSE BLOCK ***** */
00034 
00035 #ifndef _NS_KEYMODULE_H_
00036 #define _NS_KEYMODULE_H_
00037 
00038 #include "nsIKeyModule.h"
00039 #include "pk11pub.h"
00040 
00041 #define NS_KEYMODULEOBJECT_CLASSNAME "Key Object Component"
00042 /* eae599aa-ecef-49c6-a8af-6ddcc6feb484 */
00043 #define NS_KEYMODULEOBJECT_CID   \
00044 { 0xeae599aa, 0xecef, 0x49c6, {0xa8, 0xaf, 0x6d, 0xdc, 0xc6, 0xfe, 0xb4, 0x84} }
00045 #define NS_KEYMODULEOBJECT_CONTRACTID "@mozilla.org/security/keyobject;1"
00046 
00047 #define NS_KEYMODULEOBJECTFACTORY_CLASSNAME "Key Object Factory Component"
00048 /* a39e0e9d-e567-41e3-b12c-5df67f18174d */
00049 #define NS_KEYMODULEOBJECTFACTORY_CID   \
00050 { 0xa39e0e9d, 0xe567, 0x41e3, {0xb1, 0x2c, 0x5d, 0xf6, 0x7f, 0x18, 0x17, 0x4d} }
00051 #define NS_KEYMODULEOBJECTFACTORY_CONTRACTID \
00052 "@mozilla.org/security/keyobjectfactory;1"
00053 
00054 class nsKeyObject : public nsIKeyObject
00055 {
00056 public:
00057   nsKeyObject();
00058 
00059   NS_DECL_ISUPPORTS
00060   NS_DECL_NSIKEYOBJECT
00061 
00062 private:
00063   ~nsKeyObject();
00064   
00065   // Disallow copy constructor
00066   nsKeyObject(nsKeyObject&);
00067 
00068   // 0 if not yet set, otherwise one of the nsIKeyObject::*KEY values
00069   PRUint32 mKeyType;
00070   
00071   // A union of our possible key types
00072   PK11SymKey* mSymKey;
00073   SECKEYPrivateKey* mPrivateKey;
00074   SECKEYPublicKey* mPublicKey;
00075 
00076   // Helper method to free memory used by keys.
00077   void CleanUp();
00078 };
00079 
00080 
00081 class nsKeyObjectFactory : public nsIKeyObjectFactory
00082 {
00083 public:
00084   nsKeyObjectFactory();
00085 
00086   NS_DECL_ISUPPORTS
00087   NS_DECL_NSIKEYOBJECTFACTORY
00088 
00089 private:
00090   ~nsKeyObjectFactory() {};  
00091 
00092   // Disallow copy constructor
00093   nsKeyObjectFactory(nsKeyObjectFactory&);
00094 };
00095 
00096 #endif // _NS_KEYMODULE_H_