+2004-02-04 Jeffrey Altman <jaltman@mit.edu>
+
+ * resource.h: add new component id values for ccache
+
+ * Makefile.in: add conditional linkage to krbcc32.lib (if KRB5_KFW_BUILD)
+
+ * gss.rc: add new component for ccache selection
+
+ * gss.h, gss.c, gss-client.c: add support for ccache selection and
+ if built with USE_LEASH add support for dynamic querying of the
+ available ccache list
+
2004-01-30 Jeffrey Altman <jaltman@mit.edu>
* resource.h: new file containing new ui component id values
* gss.h, gss-misc.c, gss-client.c: Updates to support new UI and
corrections to add compatibility with the Unix gss-server
- * Makefile: add linkage to comctl32.lib
+ * Makefile.in: add linkage to comctl32.lib
2002-06-13 Ken Raeburn <raeburn@mit.edu>
##### Options
# Set NODEBUG if building release instead of debug
BUILDTOP=..\..
-LOCALINCLUDES= /I$(BUILDTOP)\include /I$(BUILDTOP)\include\krb5
+
+!if defined(KRB5_KFW_COMPILE)
+KFWINC= /I$(BUILDTOP)\..\..\krbcc\include
+KFWLIB= krbcc32.lib
+!endif
+LOCALINCLUDES= /I$(BUILDTOP)\include /I$(BUILDTOP)\include\krb5 $(KFWINC)
##### RC Compiler
RFLAGS = $(LOCALINCLUDES)
##### Linker
LINK = link
LIBS = $(GLIB) $(CLIB) $(WLIB)
-SYSLIBS = kernel32.lib ws2_32.lib user32.lib gdi32.lib comdlg32.lib comctl32.lib
+SYSLIBS = kernel32.lib ws2_32.lib user32.lib gdi32.lib comdlg32.lib comctl32.lib $(KFWLIB)
LFLAGS = /nologo $(LOPTS)
all:: Makefile $(OUTPRE)gss.exe
#include <winsock.h>
#include <gssapi/gssapi_generic.h>
+#include <gssapi\gssapi_krb5.h>
#include "gss.h"
#include "gss-misc.h"
int
gss (char *server_host, char *service_name, char *mechanism, char *msg, int port,
int verbose, int delegate, int v1_format, int auth_flag, int wrap_flag,
- int encrypt_flag, int mic_flag, int ccount, int mcount)
+ int encrypt_flag, int mic_flag, int ccount, int mcount, char *ccache)
{
int use_file = 0;
OM_uint32 deleg_flag = (delegate ? GSS_C_DELEG_FLAG : 0), min_stat;
gss_OID oid = GSS_C_NULL_OID;
+ OM_uint32 minor_status;
int i;
int rc = 0;
- if (ccount <= 0) ccount = 1;
- if (mcount <= 0) mcount = 1;
+ if (ccount <= 0) ccount = 1;
+ if (mcount <= 0) mcount = 1;
- if (mechanism && mechanism[0])
- parse_oid(mechanism, &oid);
+ if (mechanism && mechanism[0])
+ parse_oid(mechanism, &oid);
- for (i = 0; i < ccount; i++) {
- if (call_server(server_host, port, oid, service_name,
+ /* By using this function the independence between the application and
+ * the underlying authentication system is broken
+ */
+ if ( ccache && ccache[0] )
+ gss_krb5_ccache_name(&minor_status, ccache, NULL);
+
+ for (i = 0; i < ccount; i++) {
+ if (call_server(server_host, port, oid, service_name,
deleg_flag, auth_flag, wrap_flag, encrypt_flag, mic_flag,
v1_format, msg, use_file, mcount) < 0)
- rc = -1;
- break;
- }
+ rc = -1;
+ break;
+ }
if (oid != GSS_C_NULL_OID)
(void) gss_release_oid(&min_stat, &oid);
#include <stdlib.h>
#include <commctrl.h>
#include "gss.h"
+#include <krb5.h>
+#ifdef USE_LEASH
+#include <cacheapi.h>
+#endif
#include "resource.h"
#define INI_LAST_NOWRAP "No Wrap"
#define INI_LAST_NOCRYPT "No Encrypt"
#define INI_LAST_NOMIC "No Mic"
+#define INI_LAST_CCACHE "CCache"
#define MAX_SAVED 9
char hosts[MAX_SAVED][256];
char szService[256]; // Service to do
char szMessage[256]; // Message to send
char szMech[256]; // OID to use
+char szCCache[256]; // CCache to use
int port = 0; // Which port to use
int delegate = 0; // Delegate?
int verbose = 1; // Verbose?
hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
n = gss (szHost, szService, szMech, szMessage[0] ? szMessage : "Test Gssapi Message", port,
- verbose, delegate, gssv1, !noauth, !nowrap, !nocrypt, !nomic, ccount, mcount);
+ verbose, delegate, gssv1, !noauth, !nowrap, !nocrypt, !nomic, ccount, mcount,
+ szCCache);
SetCursor(hcursor);
if (n)
HDC hDC; // For getting graphic info
DWORD Ext; // Size of dialog
int xExt, yExt; // Size broken apart
- char buff[32];
+ char buff[64];
switch (message) {
case WM_INITDIALOG:
SendMessage(hDlg, WM_SETFOCUS, 0, 0);
return (TRUE);
+ case WM_HSCROLL:
+ switch (LOWORD(wParam)) {
+ case TB_THUMBTRACK:
+ case TB_THUMBPOSITION:
+ {
+ long pos = HIWORD(wParam); // the position of the slider
+ int ctrlID = GetDlgCtrlID((HWND)lParam);
+
+ if (ctrlID == GSS_CALL_COUNT) {
+ sprintf(buff,"Call Count: %d",pos);
+ SetWindowText(GetDlgItem(hDialog, IDC_STATIC_CCOUNT),buff);
+ }
+ if (ctrlID == GSS_MESSAGE_COUNT) {
+ sprintf(buff,"Message Count: %d",pos);
+ SetWindowText(GetDlgItem(hDialog, IDC_STATIC_MSG_COUNT),buff);
+ }
+ }
+ break;
+ case TB_BOTTOM:
+ case TB_TOP:
+ case TB_ENDTRACK:
+ case TB_LINEDOWN:
+ case TB_LINEUP:
+ case TB_PAGEDOWN:
+ case TB_PAGEUP:
+ default:
+ {
+ int ctrlID = GetDlgCtrlID((HWND)lParam);
+ long pos = SendMessage(GetDlgItem(hDialog,ctrlID), TBM_GETPOS, 0, 0); // the position of the slider
+
+ if (ctrlID == GSS_CALL_COUNT) {
+ sprintf(buff,"Call Count: %d",pos);
+ SetWindowText(GetDlgItem(hDialog, IDC_STATIC_CCOUNT),buff);
+ }
+ if (ctrlID == GSS_MESSAGE_COUNT) {
+ sprintf(buff,"Message Count: %d",pos);
+ SetWindowText(GetDlgItem(hDialog, IDC_STATIC_MSG_COUNT),buff);
+ }
+ }
+ }
+ break;
+
+
case WM_COMMAND:
switch (wParam) {
case GSS_CANCEL: // Only way out of the dialog
}
GetDlgItemText(hDlg, GSS_MECHANISM, szMech, 256);
+ GetDlgItemText(hDlg, GSS_CCACHE_NAME, szCCache, 256);
GetDlgItemText(hDlg, GSS_MESSAGE, szMessage, 256);
GetDlgItemText(hDlg, GSS_PORT, buff, 32);
if (!*buff) {
update_saved (); // Add it to the host list
fill_combo (hDlg); // Update the combo box
- SetDlgItemText(hDlg, GSS_OUTPUT, "", 0);
+ SetDlgItemText(hDlg, GSS_OUTPUT, "");
do_gssapi_test (); // Test GSSAPI
//EndDialog(hDlg, TRUE);
GetPrivateProfileString(INI_LAST, INI_LAST_SVC, "", szService, 256, GSSAPI_INI);
GetPrivateProfileString(INI_LAST, INI_LAST_MSG, "", szMessage, 256, GSSAPI_INI);
GetPrivateProfileString(INI_LAST, INI_LAST_MECH, "", szMech, 256, GSSAPI_INI);
+ GetPrivateProfileString(INI_LAST, INI_LAST_CCACHE, "", szCCache, 256, GSSAPI_INI);
GetPrivateProfileString(INI_LAST, INI_LAST_DELEGATE, "", buff, 32, GSSAPI_INI);
if ( buff[0] )
delegate = atoi(buff);
WritePrivateProfileString(INI_LAST, INI_LAST_PORT, buff, GSSAPI_INI);
WritePrivateProfileString(INI_LAST, INI_LAST_SVC, szService, GSSAPI_INI);
WritePrivateProfileString(INI_LAST, INI_LAST_MECH, szMech, GSSAPI_INI);
+ WritePrivateProfileString(INI_LAST, INI_LAST_CCACHE, szCCache, GSSAPI_INI);
WritePrivateProfileString(INI_LAST, INI_LAST_MSG, szMessage, GSSAPI_INI);
wsprintf(buff, "%d", delegate);
WritePrivateProfileString(INI_LAST, INI_LAST_DELEGATE, buff, GSSAPI_INI);
static void
fill_combo (HWND hDlg) {
int i; // Index
- char buff[32];
+ char buff[256];
+#ifdef USE_LEASH
+ krb5_error_code retval;
+ apiCB * cc_ctx = 0;
+ struct _infoNC ** pNCi = 0;
+#endif
SendDlgItemMessage(hDlg, GSS_HOST_NAME, CB_RESETCONTENT, 0, 0);
SetDlgItemText(hDlg, GSS_HOST_NAME, szHost);
SendDlgItemMessage(hDlg, GSS_MECHANISM, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) mechs[i]));
}
+ SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_RESETCONTENT, 0, 0);
+ SetDlgItemText(hDlg, GSS_CCACHE_NAME, szCCache);
+ SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_SETEDITSEL, 0, 0);
+
+#ifdef USE_LEASH
+ retval = cc_initialize(&cc_ctx, CC_API_VER_2, NULL, NULL);
+ if (retval)
+ goto skip_ccache;
+
+ retval = cc_get_NC_info(cc_ctx, &pNCi);
+ if (retval)
+ goto clean_ccache;
+
+ for ( i=0; pNCi[i]; i++ ) {
+ if (pNCi[i]->vers == CC_CRED_V5) {
+ sprintf(buff,"API:%s",pNCi[i]->name);
+ SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) buff));
+ }
+ }
+
+ clean_ccache:
+ if (pNCi)
+ cc_free_NC_info(cc_ctx, &pNCi);
+ if (cc_ctx)
+ cc_shutdown(&cc_ctx);
+ skip_ccache:
+#endif /* USE_LEASH */
+ if ( szCCache[0] )
+ SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) szCCache));
+ SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) "MSLSA:"));
+
SendDlgItemMessage(hDlg, GSS_MESSAGE, CB_RESETCONTENT, 0, 0);
SetDlgItemText(hDlg, GSS_MESSAGE, szMessage);
SendDlgItemMessage(hDlg, GSS_MESSAGE, CB_SETEDITSEL, 0, 0);
EnableWindow(GetDlgItem(hDlg, GSS_NO_MIC), TRUE);
}
- SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 0);
+ SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 1);
SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETRANGEMAX, (WPARAM) FALSE, (LPARAM) 20);
SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETPOS, (WPARAM) FALSE, (LPARAM) ccount);
+ sprintf(buff,"Call Count: %d",ccount);
+ SetWindowText(GetDlgItem(hDialog, IDC_STATIC_CCOUNT),buff);
- SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 0);
+ SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 1);
SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETRANGEMAX, (WPARAM) FALSE, (LPARAM) 20);
SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETPOS, (WPARAM) FALSE, (LPARAM) mcount);
-
+ sprintf(buff,"Message Count: %d",mcount);
+ SetWindowText(GetDlgItem(hDialog, IDC_STATIC_MSG_COUNT),buff);
}
int
int
gss (char *server_host, char *service_name, char *mechanism, char *msg, int port,
int verbose, int delegate, int v1_format, int auth_flag, int wrap_flag,
- int encrypt_flag, int mic_flag, int ccount, int mcount);
+ int encrypt_flag, int mic_flag, int ccount, int mcount, char * ccache);
int call_server(char *host, u_short port, gss_OID oid, char *service_name,
OM_uint32 deleg_flag, int auth_flag,
int wrap_flag, int encrypt_flag, int mic_flag, int v1_format,
-//Microsoft Developer Studio generated resource script.
+// Microsoft Visual C++ generated resource script.
//
-#include "resource.h"
-
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
-GSS ICON DISCARDABLE "gss.ico"
+GSS ICON "gss.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
-GSSAPIDLG DIALOG DISCARDABLE 63, 65, 330, 311
-STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU
+GSSAPIDLG DIALOGEX 63, 65, 330, 311
+STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
CAPTION "Test GSSAPI Connection"
-FONT 8, "MS Sans Serif"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
- RTEXT "Hostname:",IDC_STATIC_PORT,5,12,60,10,NOT WS_GROUP
- COMBOBOX GSS_HOST_NAME,70,9,246,60,CBS_DROPDOWN | CBS_AUTOHSCROLL |
+ RTEXT "Hostname:",IDC_STATIC_HOST,5,12,60,10,NOT WS_GROUP
+ COMBOBOX GSS_HOST_NAME,70,9,245,60,CBS_DROPDOWN | CBS_AUTOHSCROLL |
WS_VSCROLL | WS_GROUP | WS_TABSTOP
DEFPUSHBUTTON "Test",GSS_OK,80,290,51,14,WS_GROUP
PUSHBUTTON "Exit",GSS_CANCEL,185,290,51,14
RTEXT "Port:",IDC_STATIC_PORT,16,27,50,8
EDITTEXT GSS_PORT,70,25,40,14,ES_RIGHT | ES_AUTOHSCROLL |
ES_NUMBER
- COMBOBOX GSS_SERVICE_NAME,69,41,246,30,CBS_DROPDOWN | CBS_SORT |
+ COMBOBOX GSS_SERVICE_NAME,70,41,245,60,CBS_DROPDOWN | CBS_SORT |
WS_VSCROLL | WS_TABSTOP
RTEXT "GSS Service Name:",IDC_STATIC_SERVICE,1,44,64,8
- COMBOBOX GSS_MECHANISM,70,110,245,30,CBS_DROPDOWN |
+ COMBOBOX GSS_CCACHE_NAME,70,69,245,60,CBS_DROPDOWN | CBS_SORT |
+ WS_VSCROLL | WS_TABSTOP
+ RTEXT "CCache Name:",IDC_STATIC_CCACHE,16,71,49,8
+ COMBOBOX GSS_MECHANISM,70,110,245,60,CBS_DROPDOWN |
CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
RTEXT "Mechanism (OID):",IDC_STATIC_MECH,0,115,65,8
RTEXT "Test Message:",IDC_STATIC_MSG,0,55,65,8
- COMBOBOX GSS_MESSAGE,70,55,245,30,CBS_DROPDOWN | CBS_AUTOHSCROLL |
+ COMBOBOX GSS_MESSAGE,70,55,245,60,CBS_DROPDOWN | CBS_AUTOHSCROLL |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
LTEXT "The following items are optional and should only be altered by those who understand their implications.",
IDC_STATIC_OPTIONS,10,85,305,20
// TEXTINCLUDE
//
-1 TEXTINCLUDE DISCARDABLE
+1 TEXTINCLUDE
BEGIN
"resrc1.h\0"
END
-2 TEXTINCLUDE DISCARDABLE
+2 TEXTINCLUDE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"\0"
END
-3 TEXTINCLUDE DISCARDABLE
+3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
#define GSS_OK 1024
#define GSS_CANCEL 1025
#define IDC_STATIC_PORT 1026
+#define IDC_STATIC_HOST 1027
+#define GSS_CCACHE_NAME 1028
+#define IDC_STATIC_CCACHE 1029
#define IDD_GSSAPIDLG 101
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1027
+#define _APS_NEXT_CONTROL_VALUE 1030
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif