tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jni/native/src sslutils.c
Date Tue, 07 Jun 2005 12:41:44 GMT
mturk       2005/06/07 05:41:44

  Modified:    jni/native/os/win32 system.c
               jni/native/src sslutils.c
  Added:       jni/native/os/win32 apache.ico libtcnative.rc
  Log:
  Add simple GUI password prompt for WIN32.
  In most cases the password will be provided by Java, so
  this is just for testing.
  
  Revision  Changes    Path
  1.6       +58 -2     jakarta-tomcat-connectors/jni/native/os/win32/system.c
  
  Index: system.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/os/win32/system.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- system.c	28 May 2005 11:40:52 -0000	1.5
  +++ system.c	7 Jun 2005 12:41:44 -0000	1.6
  @@ -20,7 +20,8 @@
    */
   
   #define _WIN32_WINNT 0x0500
  -
  +#include <windows.h>
  +#include <winsock.h>
   #include "apr.h"
   #include "apr_pools.h"
   #include "apr_network_io.h"
  @@ -28,6 +29,7 @@
   #include "apr_arch_atime.h"  /* for FileTimeToAprTime */
   
   #include "tcn.h"
  +#include "ssl_private.h"
   
   #pragma warning(push)
   #pragma warning(disable : 4201)
  @@ -214,3 +216,57 @@
       (*e)->ReleaseLongArrayElements(e, inf, pvals, 0);
       return rv;
   }
  +
  +static DWORD WINAPI password_thread(void *data)
  +{
  +    tcn_pass_cb_t *cb = (tcn_pass_cb_t *)data;
  +    MSG msg;
  +    HWND hwnd = CreateDialog(dll_instance, MAKEINTRESOURCE(1001), NULL, NULL);
  +    if (hwnd != NULL)
  +        ShowWindow(hwnd, SW_SHOW);
  +    else  {
  +        ExitThread(1);
  +        return 1;
  +    }
  +    while (1) {
  +        if (PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE)) {
  +            if (msg.message == WM_KEYUP) {
  +                int nVirtKey = (int)msg.wParam;
  +                if (nVirtKey == VK_ESCAPE) {
  +                    DestroyWindow(hwnd);
  +                    break;
  +                }
  +                else if (nVirtKey == VK_RETURN) {
  +                    HWND he = GetDlgItem(hwnd, 1002);
  +                    if (he) {
  +                        int n = GetWindowText(he, cb->password, SSL_MAX_PASSWORD_LEN
- 1);
  +                        cb->password[n] = '\0';
  +                    }
  +                    DestroyWindow(hwnd);
  +                    break;
  +                }
  +            }
  +            TranslateMessage(&msg);
  +            DispatchMessage(&msg);
  +        }
  +        else
  +            Sleep(100);
  +    }
  +    ExitThread(0);
  +    return 0;
  +}
  +
  +int WIN32_SSL_password_prompt(tcn_pass_cb_t *data)
  +{
  +    DWORD id;
  +    HANDLE thread;
  +    /* TODO: See how to display this from service mode */
  +    thread = CreateThread(NULL, 0,
  +                password_thread, data,
  +                0, &id);
  +    WaitForSingleObject(thread, INFINITE);
  +    CloseHandle(thread);
  +    return strlen(data->password);
  +}
  +
  +
  
  
  
  1.1                  jakarta-tomcat-connectors/jni/native/os/win32/apache.ico
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tomcat-connectors/jni/native/os/win32/libtcnative.rc
  
  Index: libtcnative.rc
  ===================================================================
  #include <windows.h>
  
  1000 ICON "apache.ico"
  
  1001 DIALOGEX 0, 0, 252, 51
  STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_CAPTION
  CAPTION "Password prompt"
  FONT 8, "MS Shell Dlg", 0, 0, 0x0
  BEGIN
      ICON            1000,-1,8,6,21,20
      LTEXT           "Some of your private key files are encrypted for security reasons.\nIn
order to read them you have to provide the pass phrases.",
                      -1,29,5,220,19
      LTEXT           "Enter password:",-1,7,28,75,8
      EDITTEXT        1002,67,27,174,12,ES_PASSWORD | ES_AUTOHSCROLL
  END
  
  1 VERSIONINFO
   FILEVERSION 1,1,0,0
   PRODUCTVERSION 1,1,0,0
   FILEFLAGSMASK 0x3fL
  #ifdef _DEBUG
   FILEFLAGS 0x1L
  #else
   FILEFLAGS 0x0L
  #endif
   FILEOS 0x40004L
   FILETYPE 0x1L
   FILESUBTYPE 0x0L
  BEGIN
      BLOCK "StringFileInfo"
      BEGIN
          BLOCK "040904b0"
          BEGIN
              VALUE "Comments", "Licensed under the Apache License, Version 2.0 (the ""License"");
you may not use this file except in compliance with the License.  You may obtain a copy of
the License at\r\n\r\nhttp://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by
applicable law or agreed to in writing, software distributed under the License is distributed
on an ""AS IS"" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and limitations under the
License."
              VALUE "CompanyName", "Apache Software Foundation"
              VALUE "FileDescription", "Tomcat Native Java Library"
              VALUE "FileVersion", "1.1.0-dev"
              VALUE "InternalName", "libtcnative-1"
              VALUE "LegalCopyright", "Copyright 2000-2005 The Apache Software Foundation"
              VALUE "OriginalFilename", "libtcnative-1.dll"
              VALUE "ProductName", "Apache Portable Runtime"
              VALUE "ProductVersion", "1.1.0-dev"
          END
      END
      BLOCK "VarFileInfo"
      BEGIN
          VALUE "Translation", 0x409, 1200
      END
  END
  
  
  
  1.21      +8 -7      jakarta-tomcat-connectors/jni/native/src/sslutils.c
  
  Index: sslutils.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/sslutils.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- sslutils.c	7 Jun 2005 11:05:07 -0000	1.20
  +++ sslutils.c	7 Jun 2005 12:41:44 -0000	1.21
  @@ -31,6 +31,10 @@
   #ifdef HAVE_OPENSSL
   #include "ssl_private.h"
   
  +#ifdef WIN32
  +extern int WIN32_SSL_password_prompt(tcn_pass_cb_t *data);
  +#endif
  +
   /*  _________________________________________________________________
   **
   **  Additional High-Level Functions for OpenSSL
  @@ -84,14 +88,11 @@
       }
       else {
   #ifdef WIN32
  -        STARTUPINFO si;
  -        GetStartupInfo(&si);
  -        /* Display a new Console window */
  -        if (si.wShowWindow == 0)
  -            return 0;
  -#endif
  +        rv = WIN32_SSL_password_prompt(data);
  +#else
           EVP_read_pw_string(data->password, SSL_MAX_PASSWORD_LEN,
                              data->prompt, 0);
  +#endif
           rv = strlen(data->password);
       }
       if (rv > 0) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message