ctrlconn.h
上传用户:lyxiangda
上传日期:2007-01-12
资源大小:3042k
文件大小:10k
源码类别:

CA认证

开发平台:

WINDOWS

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /*
  3.  * The contents of this file are subject to the Mozilla Public
  4.  * License Version 1.1 (the "License"); you may not use this file
  5.  * except in compliance with the License. You may obtain a copy of
  6.  * the License at http://www.mozilla.org/MPL/
  7.  * 
  8.  * Software distributed under the License is distributed on an "AS
  9.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10.  * implied. See the License for the specific language governing
  11.  * rights and limitations under the License.
  12.  * 
  13.  * The Original Code is the Netscape security libraries.
  14.  * 
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation.  Portions created by Netscape are 
  17.  * Copyright (C) 1994-2000 Netscape Communications Corporation.  All
  18.  * Rights Reserved.
  19.  * 
  20.  * Contributor(s):
  21.  * 
  22.  * Alternatively, the contents of this file may be used under the
  23.  * terms of the GNU General Public License Version 2 or later (the
  24.  * "GPL"), in which case the provisions of the GPL are applicable 
  25.  * instead of those above.  If you wish to allow use of your 
  26.  * version of this file only under the terms of the GPL and not to
  27.  * allow others to use your version of this file under the MPL,
  28.  * indicate your decision by deleting the provisions above and
  29.  * replace them with the notice and other provisions required by
  30.  * the GPL.  If you do not delete the provisions above, a recipient
  31.  * may use your version of this file under either the MPL or the
  32.  * GPL.
  33.  */
  34. #ifndef __SSM_CTRLCONN_H__
  35. #define __SSM_CTRLCONN_H__
  36. #include "connect.h"
  37. #include "cert.h"
  38. #include "key.h"
  39. #include "hashtbl.h"
  40. #include "obscure.h"
  41. #include "prefs.h"
  42. /*
  43.   Control connections.
  44.  */
  45. extern SSMHashTable  * ctrlConnections;
  46. struct SSMControlConnection
  47. {
  48.     SSMConnection super;
  49.     /*
  50.       ---------------------------------------------
  51.       Control connection-specific fields
  52.       ---------------------------------------------
  53.     */
  54.     PRUint32 m_version; /* Protocol version supported by client */
  55.     char * m_nonce; /* Nonce used for verifying data connections */
  56.     PRFileDesc * m_socket;   /* Socket serviced by this connection object */
  57.     PRThread * m_writeThread;/* Write Control thread (writes m_socket) */
  58.     PRThread * m_frontEndThread; /* Front end thread - reads m_socket */
  59.     PRThread * m_certRenewalThread; /* Front end thread - reads m_socket */
  60.     
  61.     char * m_profileName; /* Name of user profile (where to find 
  62.                              certs etc) */
  63.     char * m_dirRoot; /* Path to directory for certs for control connection */
  64.     /* Queue for outgoing messages */
  65.     SSMCollection *m_controlOutQ;    /* Control msg queue: from readMsg thread 
  66.                                      to writeMsg thread  */
  67.     CERTCertDBHandle *m_certdb;
  68.     SECKEYKeyDBHandle *m_keydb;
  69.     /* Fields used for out-of-band password requests */
  70.     SSMHashTable * m_passwdTable;
  71.     PRMonitor * m_passwdLock;
  72.     SSMHashTable * m_encrPasswdTable;
  73.     PRMonitor * m_encrPasswdLock;
  74.     PRInt32 m_waiting;
  75.     SSMHashTable *m_resourceDB;
  76.     SSMHashTable *m_classRegistry;
  77.     SSMHashTable * m_resourceIdDB;
  78.     SSMResourceID m_lastRID;
  79.     SSMHashTable * m_certIdDB;
  80.     SECItem * m_secAdvisorList;
  81.     PRInt32 m_certNext;
  82.     /* Data socket and port */
  83.     PRFileDesc * m_dataSocket;
  84.     PRIntn  m_dataPort;
  85.     
  86.     PRBool m_doesUI;
  87.     PrefSet* m_prefs;
  88.     PRBool m_pkcs11Init;
  89. };
  90. SSMStatus SSM_InitPolicyHandler(void);
  91. SSMStatus SSMControlConnection_Create(void *arg, SSMControlConnection * conn, 
  92.                                      SSMResource **res);
  93. SSMStatus SSMControlConnection_Init(SSMControlConnection *res, 
  94.                                    SSMResourceType type,
  95.                                    PRFileDesc *socket);
  96. SSMStatus SSMControlConnection_Shutdown(SSMResource *conn, SSMStatus status);
  97. SSMStatus SSMControlConnection_Destroy(SSMResource *res, PRBool doFree);
  98. SSMStatus SSMControlConnection_GetAttrIDs(SSMResource* res, SSMAttributeID** ids,
  99.                                          PRIntn* count);
  100. SSMStatus SSMControlConnection_GetAttr(SSMResource *res, SSMAttributeID attrID,
  101.                                        SSMResourceAttrType attrType,
  102.                                       SSMAttributeValue *value);
  103. void SSMControlConnection_Invariant(SSMControlConnection *conn);
  104. SSMStatus SSMControlConnection_ProcessMessage(SSMControlConnection* control, 
  105.                                              SECItem* msg);
  106. void SSM_WriteCtrlThread(void * arg);
  107. void SSM_FrontEndThread(void * arg);
  108. void SSM_CertificateRenewalThread(void * arg);
  109. SSMStatus SSMControlConnection_Authenticate(SSMConnection *arg, char *nonce);
  110. void SSMControlConnection_CertLookUp(SSMControlConnection * connection, 
  111.                                      void * arg, SSMResource ** res);
  112. SSMStatus SSMControlConnection_SendUIEvent(SSMControlConnection *conn,
  113.                                            char *command,
  114.                                            char *baseRef, 
  115.                                            SSMResource *target, /* can pass NULL */
  116.                                            char *otherParams /* can pass NULL */,
  117.                                            CMTItem * clientContext /* can pass NULL */,
  118.                                            PRBool isModal);
  119. /*
  120.  * NOTES
  121.  * These functions save the pref change properly in memory and in client file.
  122.  * They check first whether the value has changed and perform saving
  123.  * operations.
  124.  * These functions do not belong to the prefs API because these specifically
  125.  * send the changes to the plugin.  Once we have our own prefs library ready
  126.  * and complete the migration, these functions should be called only when
  127.  * application-specific prefs are saved back to client pref file.
  128.  * Since these functions pack one item only, if you have to send a lot of
  129.  * pref changes and performance is critical, it is not recommended to call
  130.  * these functions repeatedly.
  131.  *
  132.  */
  133. SSMStatus SSMControlConnection_SaveStringPref(SSMControlConnection* ctrl,
  134.                                               char* key, char* value);
  135. SSMStatus SSMControlConnection_SaveBoolPref(SSMControlConnection* ctrl,
  136.                                             char* key, PRBool value);
  137. SSMStatus SSMControlConnection_SaveIntPref(SSMControlConnection* ctrl,
  138.                                            char* key, PRIntn value);
  139. void SSMControlConnection_CertLookUp(SSMControlConnection * connection,
  140.                                      void * arg, SSMResource ** res);
  141. void SSM_LockPasswdTable(SSMConnection * conn);
  142. SSMStatus SSM_UnlockPasswdTable(SSMConnection *conn);
  143. SSMStatus SSM_WaitPasswdTable(SSMConnection * conn);
  144. SSMStatus SSM_NotifyAllPasswdTable(SSMConnection * conn);
  145. SSMStatus SSMControlConnection_AddResource(SSMResource * res, SSMResourceID rid);
  146. SSMStatus SSMControlConnection_GetResource(SSMControlConnection * connection,
  147.                                           SSMResourceID rid,
  148.                                           SSMResource ** res);
  149. SSMStatus SSMControlConnection_GetGlobalResourceID(SSMControlConnection
  150.                                                   *connection,
  151.                                                   SSMResource * res,
  152.                                                   SSMResourceID * rid);
  153. SSMResourceID SSMControlConnection_GenerateResourceID(SSMControlConnection *conn);
  154. SSMStatus SSM_GetControlConnection(SSMResourceID rid,
  155.                                   SSMControlConnection **connection);
  156. SSMStatus SSMControlConnection_FormSubmitHandler(SSMResource* res,
  157.                                                  HTTPRequest* req);
  158. void SSMControlConnection_RecycleItem(SECItem* msg);
  159. SSMStatus SSMControlConnection_GenerateNonce(SSMControlConnection *conn);
  160. /* from processmsg.c */
  161. SSMStatus 
  162. SSMControlConnection_ProcessVerifyCertRequest(SSMControlConnection * ctrl, 
  163.                                               SECItem * msg);
  164. SSMStatus
  165. SSMControlConnection_ProcessImportCertRequest(SSMControlConnection * ctrl,
  166.                                               SECItem * msg);
  167. SSMStatus
  168. SSMControlConnection_ProcessConserveRequest(SSMControlConnection * ctrl, 
  169.                                             SECItem * msg);
  170. SSMStatus 
  171. SSMControlConnection_ProcessPickleRequest(SSMControlConnection * ctrl, 
  172.                                           SECItem * msg);
  173. SSMStatus 
  174. SSMControlConnection_ProcessUnpickleRequest(SSMControlConnection * ctrl, 
  175.                                             SECItem * msg);
  176. SSMStatus 
  177. SSMControlConnection_ProcessCertRequest(SSMControlConnection * ctrl, 
  178.                                         SECItem * msg);
  179. PRStatus
  180. SSMControlConnection_ProcessKeygenTag(SSMControlConnection * ctrl,
  181.                                         SECItem * msg);
  182. SSMStatus
  183. SSMControlConnection_ProcessPKCS11Request(SSMControlConnection * ctrl, 
  184.   SECItem * msg);
  185. SSMStatus
  186. SSMControlConnection_ProcessCRMFRequest(SSMControlConnection * ctrl,
  187. SECItem * msg);
  188. SSMStatus
  189. SSMControlConnection_ProcessMiscRequest(SSMControlConnection * ctrl,
  190.                                         SECItem * msg);
  191. SSMStatus
  192. SSMControlConnection_ProcessFormSigningRequest(SSMControlConnection * ctrl,
  193.                                         SECItem *msg);
  194. SSMStatus 
  195. SSMControlConnection_ProcessTLSRequest(SSMControlConnection * ctrl,
  196.                                         SECItem *msg);
  197. SSMStatus
  198. SSMControlConnection_ProcessProxyStepUpRequest(SSMControlConnection* ctrl,
  199.                                                SECItem* msg);
  200. SSMStatus
  201. SSMControlConnection_ProcessSecCfgRequest(SSMControlConnection * ctrl,
  202.                                         SECItem *msg);
  203. SSMStatus
  204. SSMControlConnection_ProcessGenKeyOldStyleToken(SSMControlConnection * ctrl,
  205.                                         SECItem *msg);
  206. SSMStatus
  207. SSMControlConnection_ProcessGenKeyPassword(SSMControlConnection * ctrl, 
  208.    SECItem *msg);
  209. SSMStatus 
  210. SSM_CertCAImportCommandHandler2(HTTPRequest * req);
  211. void
  212. ssm_ShutdownNSS(SSMControlConnection *ctrl);
  213. SSMStatus
  214. SSM_UseAsDefaultEmailIfNoneSet(SSMControlConnection *ctrl, 
  215.                                CERTCertificate *cert, PRBool onFrontEndThread);
  216. CERTCertList *
  217. SSMControlConnection_CreateCertListByNickname(SSMControlConnection * ctrl,
  218.                                               char * nick, PRBool email);
  219. SSMStatus 
  220. ssmcontrolconnection_encode_err_reply(SECItem *msg, SSMStatus rv);
  221. SSMStatus
  222. ssmcontrolconnection_send_message_to_client(SSMControlConnection *ctrl,
  223.                                             SECItem *msg);
  224. #endif /* __SSM_CTRLCONN_H__ */