|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 #ifndef _nsCrypto_h_ |
|
7 #define _nsCrypto_h_ |
|
8 |
|
9 #include "mozilla/dom/BindingDeclarations.h" |
|
10 #include "mozilla/ErrorResult.h" |
|
11 #ifndef MOZ_DISABLE_CRYPTOLEGACY |
|
12 #include "mozilla/dom/NonRefcountedDOMObject.h" |
|
13 #include "Crypto.h" |
|
14 #include "nsCOMPtr.h" |
|
15 #include "nsIDOMCryptoLegacy.h" |
|
16 #include "nsIRunnable.h" |
|
17 #include "nsString.h" |
|
18 #include "nsIPrincipal.h" |
|
19 |
|
20 #define NS_CRYPTO_CID \ |
|
21 {0x929d9320, 0x251e, 0x11d4, { 0x8a, 0x7c, 0x00, 0x60, 0x08, 0xc8, 0x44, 0xc3} } |
|
22 #define PSM_VERSION_STRING "2.4" |
|
23 |
|
24 class nsIPSMComponent; |
|
25 class nsIDOMScriptObjectFactory; |
|
26 |
|
27 namespace mozilla { |
|
28 namespace dom { |
|
29 |
|
30 class CRMFObject : public NonRefcountedDOMObject |
|
31 { |
|
32 public: |
|
33 CRMFObject(); |
|
34 virtual ~CRMFObject(); |
|
35 |
|
36 nsresult SetCRMFRequest(char *inRequest); |
|
37 |
|
38 JSObject* WrapObject(JSContext *aCx, bool* aTookOwnership); |
|
39 |
|
40 void GetRequest(nsAString& aRequest); |
|
41 |
|
42 private: |
|
43 nsString mBase64Request; |
|
44 }; |
|
45 |
|
46 } |
|
47 } |
|
48 |
|
49 class nsCrypto: public mozilla::dom::Crypto |
|
50 { |
|
51 public: |
|
52 nsCrypto(); |
|
53 virtual ~nsCrypto(); |
|
54 |
|
55 NS_DECL_ISUPPORTS_INHERITED |
|
56 |
|
57 // If legacy DOM crypto is enabled this is the class that actually |
|
58 // implements the legacy methods. |
|
59 NS_DECL_NSIDOMCRYPTO |
|
60 |
|
61 virtual bool EnableSmartCardEvents() MOZ_OVERRIDE; |
|
62 virtual void SetEnableSmartCardEvents(bool aEnable, |
|
63 mozilla::ErrorResult& aRv) MOZ_OVERRIDE; |
|
64 |
|
65 virtual void GetVersion(nsString& aVersion) MOZ_OVERRIDE; |
|
66 |
|
67 virtual mozilla::dom::CRMFObject* |
|
68 GenerateCRMFRequest(JSContext* aContext, |
|
69 const nsCString& aReqDN, |
|
70 const nsCString& aRegToken, |
|
71 const nsCString& aAuthenticator, |
|
72 const nsCString& aEaCert, |
|
73 const nsCString& aJsCallback, |
|
74 const mozilla::dom::Sequence<JS::Value>& aArgs, |
|
75 mozilla::ErrorResult& aRv) MOZ_OVERRIDE; |
|
76 |
|
77 virtual void ImportUserCertificates(const nsAString& aNickname, |
|
78 const nsAString& aCmmfResponse, |
|
79 bool aDoForcedBackup, |
|
80 nsAString& aReturn, |
|
81 mozilla::ErrorResult& aRv) MOZ_OVERRIDE; |
|
82 |
|
83 virtual void SignText(JSContext* aContext, |
|
84 const nsAString& aStringToSign, |
|
85 const nsAString& aCaOption, |
|
86 const mozilla::dom::Sequence<nsCString>& aArgs, |
|
87 nsAString& aReturn) MOZ_OVERRIDE; |
|
88 |
|
89 virtual void Logout(mozilla::ErrorResult& aRv) MOZ_OVERRIDE; |
|
90 |
|
91 private: |
|
92 static already_AddRefed<nsIPrincipal> GetScriptPrincipal(JSContext *cx); |
|
93 |
|
94 bool mEnableSmartCardEvents; |
|
95 }; |
|
96 #endif // MOZ_DISABLE_CRYPTOLEGACY |
|
97 |
|
98 #include "nsIPKCS11.h" |
|
99 |
|
100 #define NS_PKCS11_CID \ |
|
101 {0x74b7a390, 0x3b41, 0x11d4, { 0x8a, 0x80, 0x00, 0x60, 0x08, 0xc8, 0x44, 0xc3} } |
|
102 |
|
103 class nsPkcs11 : public nsIPKCS11 |
|
104 { |
|
105 public: |
|
106 nsPkcs11(); |
|
107 virtual ~nsPkcs11(); |
|
108 |
|
109 NS_DECL_ISUPPORTS |
|
110 NS_DECL_NSIPKCS11 |
|
111 |
|
112 }; |
|
113 |
|
114 #endif //_nsCrypto_h_ |