home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / winsock / wvnsc926 / wvauth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  3.6 KB  |  127 lines

  1.  
  2. /*
  3.  *
  4.  * $Id: wvauth.c 1.4 1994/09/16 00:57:44 jcooper Exp $
  5.  * $Log: wvauth.c $
  6.  * Revision 1.4  1994/09/16  00:57:44  jcooper
  7.  * rearranged headers to allow precompiled headers
  8.  *
  9.  * Revision 1.3  1994/08/24  18:40:15  mrr
  10.  * authorization enables post/mail
  11.  *
  12.  * Revision 1.2  1993/12/08  01:28:38  rushing
  13.  * new version box and cr lf consistency
  14.  *
  15.  * Revision 1.1  1993/02/16  20:53:50  rushing
  16.  * Initial revision
  17.  *
  18.  *
  19.  */
  20.  
  21. /*--- WVAUTH.C -- Routines for authentication in WinVN
  22.  *
  23.  *   Mark Riordan  14 August 1990
  24.  */
  25.  
  26. #include <windows.h>
  27. #include <windowsx.h>
  28. #include "wvglob.h"
  29. #include "winvn.h"
  30. #pragma hdrstop
  31.  
  32. unsigned int newdes_buf (unsigned char *buf, unsigned int block_length);
  33. void newdes_block (unsigned char *block);
  34. void newdes_set_key_encipher (unsigned char *key);
  35. void newdes_set_key_decipher (unsigned char *key);
  36.  
  37. int uuencode (unsigned char *bufin, unsigned int nbytes,
  38.          unsigned char *bufcoded);
  39. int uudecode (unsigned char *bufcoded, unsigned char *bufplain);
  40.  
  41.  
  42. static unsigned char key[]=
  43. {
  44.   0x58, 0x20, 0x41, 0xaf, 0xb4, 0xce, 0x58, 0xbb, 0xb0,
  45.   0x1a, 0xaf, 0x6e, 0x00, 0x5e, 0x60
  46. };
  47.  
  48.  
  49. /*--- function AuthenticatePosting --------------------------------
  50.  *
  51.  *   Determine whether the user has sent valid authentication
  52.  *   information to the host.
  53.  *
  54.  *    Entry    Authenticated  is TRUE if we're already authorized.
  55.  *             AuthReq        is TRUE if we need authorization.
  56.  *
  57.  *    Exit     Returns TRUE if we are authorized, else FALSE.
  58.  *                                                             
  59.  *    This routine is largely unimplemented.
  60.  *    Intended
  61.  *    Method   If we're already authorized, just return TRUE.
  62.  *             Otherwise, make sure the comm channel to the server
  63.  *             isn't busy.  If it is, put up a message to that
  64.  *             effect and quit.
  65.  *             If not busy, get authorization information from the
  66.  *             user and present it to the server (in encoded form).
  67.  *             Wait until the server responds or until the Abort
  68.  *             Protocol flag is set (by the user via a menu).
  69.  *             If authorized, return TRUE, else put up a
  70.  *             message to the user and return FALSE.
  71.  */
  72. BOOL
  73. AuthenticatePosting (AuthReq)
  74. BOOL AuthReq;
  75. {  
  76.    BOOL whetherOK=FALSE;
  77.                       
  78.    if(AuthReq && !Authenticated) {
  79.       MessageBox(hWndConf,
  80.       "Sorry, you must identify yourself to the news server \
  81. before sending.  Choose the Config/Configure Comm... menu option \
  82. and enter your username and password.  \
  83. Then Choose Network/Disconnect and Network/Connect.",
  84. "No permission",MB_OK);
  85.    } else {
  86.       whetherOK = TRUE;
  87.    }
  88.    
  89.    return(whetherOK);
  90. }
  91.  
  92. /*-- function WinVnAuthDlg ---------------------------------------
  93.  *
  94.  *  Window function to handle Save Article dialog box.
  95.  */
  96.  
  97. BOOL FAR PASCAL 
  98. WinVnAuthDlg (hDlg, iMessage, wParam, lParam)
  99.      HWND hDlg;
  100.      unsigned iMessage;
  101.      WORD wParam;
  102.      LONG lParam;
  103. {
  104.    return (TRUE);
  105.  
  106. }
  107.    
  108. /*--- function AddAuthHeader --------------------------------
  109.  *
  110.  *  Add an X-Authenticated-User: line to the beginning
  111.  *  of an edit control.
  112.  *
  113.  *  Entry:  hWndEdit    is the handle of an edit control.
  114.  *          AuthenticatedName    is the name of the user; it's been
  115.  *                               checked by the server.
  116.  */    
  117. void
  118. AddAuthHeader(hWndEdit)
  119. HWND hWndEdit;
  120. {
  121.    char line[MAXHEADERLINE];
  122.    
  123.    sprintf(line,"X-Authenticated-User: %s\r\n",AuthenticatedName);
  124.    SendMessage(hWndEdit,EM_SETSEL,1,MAKELPARAM(0,0));
  125.    SendMessage(hWndEdit,EM_REPLACESEL,0, (LPARAM) ((LPCSTR) line));
  126.