Back to index

lightning-sunbird  0.9+nobinonly
nsCrypto.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 2001
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Javier Delgadillo <javi@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 #ifndef _nsCrypto_h_
00040 #define _nsCrypto_h_
00041 #include "nsCOMPtr.h"
00042 #include "nsIDOMCRMFObject.h"
00043 #include "nsIDOMCrypto.h"
00044 #include "nsIDOMPkcs11.h"
00045 #include "nsIRunnable.h"
00046 #include "nsString.h"
00047 #include "nsNSSEvent.h"
00048 #include "jsapi.h"
00049 #include "nsIPrincipal.h"
00050 #include "plevent.h"
00051 
00052 #define NS_CRYPTO_CLASSNAME "Crypto JavaScript Class"
00053 #define NS_CRYPTO_CID \
00054   {0x929d9320, 0x251e, 0x11d4, { 0x8a, 0x7c, 0x00, 0x60, 0x08, 0xc8, 0x44, 0xc3} }
00055 
00056 #define NS_PKCS11_CLASSNAME "Pkcs11 JavaScript Class"
00057 #define NS_PKCS11_CID \
00058   {0x74b7a390, 0x3b41, 0x11d4, { 0x8a, 0x80, 0x00, 0x60, 0x08, 0xc8, 0x44, 0xc3} }
00059 
00060 #define PSM_VERSION_STRING "2.4"
00061 
00062 class nsIPSMComponent;
00063 class nsIDOMScriptObjectFactory;
00064 
00065 
00066 class nsCRMFObject : public nsIDOMCRMFObject
00067 {
00068 public:
00069   nsCRMFObject();
00070   virtual ~nsCRMFObject();
00071 
00072   NS_DECL_NSIDOMCRMFOBJECT
00073   NS_DECL_ISUPPORTS
00074 
00075   nsresult init();
00076 
00077   nsresult SetCRMFRequest(char *inRequest);
00078 private:
00079 
00080   nsString mBase64Request;
00081 };
00082 
00083 
00084 class nsCrypto: public nsIDOMCrypto
00085 {
00086 public:
00087   nsCrypto();
00088   virtual ~nsCrypto();
00089   nsresult init();
00090   
00091   NS_DECL_ISUPPORTS
00092   NS_DECL_NSIDOMCRYPTO
00093 
00094 private:
00095   static already_AddRefed<nsIPrincipal> GetScriptPrincipal(JSContext *cx);
00096 
00097   PRBool mEnableSmartCardEvents;
00098 };
00099 
00100 class nsPkcs11 : public nsIDOMPkcs11
00101 {
00102 public:
00103   nsPkcs11();
00104   virtual ~nsPkcs11();
00105 
00106   NS_DECL_ISUPPORTS
00107   NS_DECL_NSIDOMPKCS11
00108 
00109 };
00110 
00111 //
00112 // This is the class we'll use to post ui events
00113 //
00114 struct CryptoRunnableEvent : PLEvent {
00115   CryptoRunnableEvent(nsIRunnable* runnable);
00116   ~CryptoRunnableEvent();
00117 
00118    nsIRunnable* mRunnable;
00119 };
00120 
00121 
00122 #endif //_nsCrypto_h_
00123 
00124 
00125 
00126