diff options
| author | Theodore Tso <tytso@mit.edu> | 1997-06-11 20:46:25 +0000 |
|---|---|---|
| committer | Theodore Tso <tytso@mit.edu> | 1997-06-11 20:46:25 +0000 |
| commit | cbe0e8e0928c6ddd8f1be2ba3e68e2f94b11022e (patch) | |
| tree | 790333f4cbbd224fb17e80769e34252cf514c271 /src | |
| parent | eac86677d66fe140f7ca54205773c95687e4abe5 (diff) | |
| download | krb5-cbe0e8e0928c6ddd8f1be2ba3e68e2f94b11022e.tar.gz krb5-cbe0e8e0928c6ddd8f1be2ba3e68e2f94b11022e.tar.xz krb5-cbe0e8e0928c6ddd8f1be2ba3e68e2f94b11022e.zip | |
New snapshot from Meeroh; eliminated the GSS Window class
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10097 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
| -rw-r--r-- | src/mac/gss/CGSSDocument.cp | 173 | ||||
| -rw-r--r-- | src/mac/gss/CGSSDocument.h | 50 | ||||
| -rw-r--r-- | src/mac/gss/CGSSWindow.cp | 52 | ||||
| -rw-r--r-- | src/mac/gss/CGSSWindow.h | 25 | ||||
| -rw-r--r-- | src/mac/gss/CW-Project.hqx | 1041 | ||||
| -rw-r--r-- | src/mac/gss/GSSSample.cp | 67 | ||||
| -rw-r--r-- | src/mac/gss/GSSSample.h | 36 | ||||
| -rw-r--r-- | src/mac/gss/GSSSample.rsrc.hqx | 133 | ||||
| -rw-r--r-- | src/mac/gss/gss.h | 19 |
9 files changed, 756 insertions, 840 deletions
diff --git a/src/mac/gss/CGSSDocument.cp b/src/mac/gss/CGSSDocument.cp index ea46cbc4d..db98f2f44 100644 --- a/src/mac/gss/CGSSDocument.cp +++ b/src/mac/gss/CGSSDocument.cp @@ -1,3 +1,18 @@ +// =========================================================================== +// CGSSdocument.cp +// ©1997 Massachusetts Institute of Technology, All Rights Reserved +// By meeroh@mit.edu +// Started 2/28/97 +// =========================================================================== +// Implementation of CGSSDocument, a document class derived from LSingleDoc +// CGSSDocument is the core of the GSS Sample app: it contains the interface +// to GSS (in member functions whose name starts with GSS). It also provides +// AppleEvent handler for query events and supports saving itself into a +// file. +// CGSSDocument is also derived from LListener so it can easily respond to +// Query button being clicked + + #include "CGSSDocument.h" #include <stdio.h> @@ -6,11 +21,9 @@ #include <ctype.h> extern "C" { -#include <mit-sock.h> + #include <mit-sock.h> } -#include "CGSSWindow.h" - const ResIDT wind_GSS = 128; const PaneIDT pane_Status = 904; const PaneIDT pane_QueryArgument = 900; @@ -18,13 +31,16 @@ const PaneIDT pbut_Query = 901; const PaneIDT text_Output = 903; // Message the Query button broadcasts const MessageT msg_Query = 'GSSq'; -// AppleEvent reference number -const long ae_Query = 4001; + +// --------------------------------------------------------------------------- +// € CGSSDocument +// --------------------------------------------------------------------------- +// Constructor CGSSDocument::CGSSDocument () { // Make us a window - mWindow = CGSSWindow::CreateGSSWindow (wind_GSS, this); + mWindow = LWindow::CreateWindow (wind_GSS, this); // A window, I said SignalIf_ (mWindow == nil); @@ -34,10 +50,20 @@ CGSSDocument::CGSSDocument () ((LControl*) mWindow -> FindPaneByID (pbut_Query)) -> AddListener (this); } +// --------------------------------------------------------------------------- +// € ~CGSSDocument +// --------------------------------------------------------------------------- +// Destructor + CGSSDocument::~CGSSDocument () { } +// --------------------------------------------------------------------------- +// € HandleAppleEvent +// --------------------------------------------------------------------------- +// AppleEvent handler + void CGSSDocument::HandleAppleEvent ( const AppleEvent& inAppleEvent, @@ -49,8 +75,9 @@ CGSSDocument::HandleAppleEvent ( case ae_Query: // extract the query string from the appleevent - AEDesc queryData; + AEDesc queryData = {typeNull, nil}; OSErr err = ::AEGetParamDesc (&inAppleEvent, keyDirectObject, typeChar, &queryData); + ThrowIfOSErr_ (err); char queryString [255]; UInt8 dataSize; { @@ -67,12 +94,18 @@ CGSSDocument::HandleAppleEvent ( ::AEDisposeDesc (&queryData); break; + // Unhandled events passed up to LSingleDoc default: LSingleDoc::HandleAppleEvent (inAppleEvent, outAEReply, outResult, inAENumber); break; } } +// --------------------------------------------------------------------------- +// € ObeyCommand +// --------------------------------------------------------------------------- +// Handle our own commands + Boolean CGSSDocument::ObeyCommand( CommandT inCommand, @@ -86,6 +119,9 @@ CGSSDocument::ObeyCommand( // Any that you don't handle will be passed to LApplication case msg_Query: + // Handle query command by figuring out the query string and calling GSSQuery + // The reason why this is in ObeyCommand and not in ListenToMessage is to allow us + // to add a Query menu command easily Str255 theArgument = "\0"; (LEditField*) (mWindow -> FindPaneByID (pane_QueryArgument)) -> GetDescriptor (theArgument); P2CStr (theArgument); @@ -101,11 +137,17 @@ CGSSDocument::ObeyCommand( } +// --------------------------------------------------------------------------- +// € DoAESave +// --------------------------------------------------------------------------- +// Save self + void CGSSDocument::DoAESave( FSSpec& inFileSpec, OSType inFileType) { + // Get a handle to text TEHandle teHandle = ((LTextEdit*) (mWindow -> FindPaneByID (text_Output))) -> GetMacTEH (); Handle textHandle = (*teHandle) -> hText; UInt32 textSize = ::GetHandleSize (textHandle); @@ -121,15 +163,22 @@ CGSSDocument::DoAESave( // If opening failed, try creating the file saveStream.CreateNewDataFile ('CWIE', 'TEXT', smSystemScript); saveStream.OpenDataFork (fsRdWrPerm); + // If creating andopening fails, OpenDataFork will throw } saveStream.SetLength (0); // Zap! - + + // Write the data StHandleLocker dataLock (textHandle); saveStream.WriteData (*textHandle, (*teHandle) -> teLength); SetModified (false); } +// --------------------------------------------------------------------------- +// € ListenToMessage +// --------------------------------------------------------------------------- +// Deal with broadcast messages + void CGSSDocument::ListenToMessage ( MessageT inMessage, @@ -172,9 +221,18 @@ CGSSDocument::AppendCString ( AppendPString ((ConstStringPtr) inString); } +// --------------------------------------------------------------------------- +// GSS Interface +// --------------------------------------------------------------------------- + #pragma mark - #pragma mark € GSS Functions € +// --------------------------------------------------------------------------- +// € GSSQuery +// --------------------------------------------------------------------------- +// Do some basic parsing of the input string + void CGSSDocument::GSSQuery ( char* inQueryString) @@ -267,7 +325,7 @@ CGSSDocument::GSSQuery ( } /* - * Function: call_server + * Function: GSSCallServer * * Purpose: Call the "sign" service. * @@ -289,8 +347,6 @@ CGSSDocument::GSSQuery ( * verifies it with gss_verify. -1 is returned if any step fails, * otherwise 0 is returned. */ - // meeroh: put this in CGSSDocument for easier access to Stderr - // could have done in a different way; this simplifies the code int CGSSDocument::GSSCallServer ( char *host, @@ -569,53 +625,6 @@ CGSSDocument::GSSCallServer ( return 0; } -void -CGSSDocument::GSSDisplayStatus ( - char *m, - OM_uint32 maj_stat, - OM_uint32 min_stat) -{ - OM_uint32 my_maj_stat, my_min_stat; - gss_buffer_desc msg; - #ifdef GSSAPI_V2 - OM_uint32 msg_ctx; - #else /* GSSAPI_V2 */ - int msg_ctx; - #endif /* GSSAPI_V2 */ - - Str255 msgString; - - msg_ctx = 0; - while (1) { - my_maj_stat = gss_display_status( - &my_min_stat, maj_stat, GSS_C_GSS_CODE, GSS_C_NULL_OID, &msg_ctx, &msg); - - sprintf ((char*) msgString, "GSS-API error %s: %s\r", m, (char *)msg.value); - C2PStr ((char*) msgString); - AppendPString (msgString); - - (void) gss_release_buffer(&min_stat, &msg); - - if (!msg_ctx) - break; - } - - msg_ctx = 0; - while (1) { - my_maj_stat = gss_display_status( - &my_min_stat, min_stat, GSS_C_MECH_CODE, GSS_C_NULL_OID, &msg_ctx, &msg); - - sprintf ((char*) msgString, "GSS-API error %s: %s\r", m, (char *)msg.value); - C2PStr ((char*) msgString); - AppendPString (msgString); - - (void) gss_release_buffer(&min_stat, &msg); - - if (!msg_ctx) - break; - } -} - /* * Function: connect_to_server * @@ -923,3 +932,51 @@ CGSSDocument::GSSReceiveToken ( return 0; } /* recv_token */ + +void +CGSSDocument::GSSDisplayStatus ( + char *m, + OM_uint32 maj_stat, + OM_uint32 min_stat) +{ + OM_uint32 my_maj_stat, my_min_stat; + gss_buffer_desc msg; + #ifdef GSSAPI_V2 + OM_uint32 msg_ctx; + #else /* GSSAPI_V2 */ + int msg_ctx; + #endif /* GSSAPI_V2 */ + + Str255 msgString; + + msg_ctx = 0; + while (1) { + my_maj_stat = gss_display_status( + &my_min_stat, maj_stat, GSS_C_GSS_CODE, GSS_C_NULL_OID, &msg_ctx, &msg); + + sprintf ((char*) msgString, "GSS-API error %s: %s\r", m, (char *)msg.value); + C2PStr ((char*) msgString); + AppendPString (msgString); + + (void) gss_release_buffer(&min_stat, &msg); + + if (!msg_ctx) + break; + } + + msg_ctx = 0; + while (1) { + my_maj_stat = gss_display_status( + &my_min_stat, min_stat, GSS_C_MECH_CODE, GSS_C_NULL_OID, &msg_ctx, &msg); + + sprintf ((char*) msgString, "GSS-API error %s: %s\r", m, (char *)msg.value); + C2PStr ((char*) msgString); + AppendPString (msgString); + + (void) gss_release_buffer(&min_stat, &msg); + + if (!msg_ctx) + break; + } +} + diff --git a/src/mac/gss/CGSSDocument.h b/src/mac/gss/CGSSDocument.h index cc7afb93c..512582362 100644 --- a/src/mac/gss/CGSSDocument.h +++ b/src/mac/gss/CGSSDocument.h @@ -1,36 +1,58 @@ +// =========================================================================== +// CGSSdocument.h +// ©1997 Massachusetts Institute of Technology, All Rights Reserved +// By meeroh@mit.edu +// Started 2/28/97 +// =========================================================================== + +#pragma once + #include <LSingleDoc.h> #include "gss.h" +// AppleEvent reference number for the query event +const long ae_Query = 4001; + class CGSSDocument: public LSingleDoc, public LListener { public: + // Constructors / destuctors CGSSDocument (); ~CGSSDocument (); - void ListenToMessage ( + + // Overrides from LListener + + virtual void ListenToMessage ( MessageT inMessage, void* ioParam); - Boolean ObeyCommand ( + + // Overrides from LSingleDoc + + virtual Boolean ObeyCommand ( CommandT inCommand, void *ioParam); - void GSSQuery ( - char* inQueryString); - void HandleAppleEvent ( + virtual void HandleAppleEvent ( const AppleEvent& inAppleEvent, AppleEvent& outAEReply, AEDesc& outResult, long inAENumber); - void DoAESave( + virtual void DoAESave( FSSpec& inFileSpec, OSType inFileType); - + + // Interface to GSS + // The query string has the format: + // [-port port] [-v2] host service msg + // e.g., + // -port 13136 dcl.mit.edu sample@dcl.mit.edu hi + + void GSSQuery ( + char* inQueryString); private: - void AppendPString ( - ConstStringPtr inString); - void AppendCString ( - char* inString); + // GSS calls int GSSCallServer ( char *host, u_short port, @@ -54,4 +76,10 @@ class CGSSDocument: int GSSReceiveToken ( SOCKET s, gss_buffer_t tok); + + // String display utilities + void AppendPString ( + ConstStringPtr inString); + void AppendCString ( + char* inString); };
\ No newline at end of file diff --git a/src/mac/gss/CGSSWindow.cp b/src/mac/gss/CGSSWindow.cp deleted file mode 100644 index 49e7464a0..000000000 --- a/src/mac/gss/CGSSWindow.cp +++ /dev/null @@ -1,52 +0,0 @@ -#include "CGSSWindow.h" - -const PaneIDT text_Output = 903; - -CGSSWindow::CGSSWindow (): - LWindow () -{ -}; - -CGSSWindow::CGSSWindow ( - LStream* inStream): - LWindow (inStream) -{ -} - -CGSSWindow::~CGSSWindow () -{ -} - -CGSSWindow* -CGSSWindow::CreateGSSWindow ( - ResIDT inWindowID, - LCommander* inSuperCommander) -{ - return (CGSSWindow*) LWindow::CreateWindow (inWindowID, inSuperCommander); -} - -CGSSWindow* -CGSSWindow::CreateGSSWindowStream ( - LStream* inStream) -{ - return new CGSSWindow (inStream); -} - -Boolean -CGSSWindow::ObeyCommand ( - CommandT inCommand, - void *ioParam) -{ - switch (inCommand) - { - case cmd_Close: - // Quit when we close the window - // We shouldn't get this message because the close box is disabled - GetSuperCommander () -> ObeyCommand (cmd_Quit); - return true; - break; - - default: - return LWindow::ObeyCommand (inCommand, ioParam); - } -} diff --git a/src/mac/gss/CGSSWindow.h b/src/mac/gss/CGSSWindow.h deleted file mode 100644 index 8f3b0cde4..000000000 --- a/src/mac/gss/CGSSWindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#include <LWindow.h> - -#pragma once - -class CGSSWindow: - public LWindow { -public: - enum { class_ID = 'GSSw' }; - CGSSWindow (); - CGSSWindow ( - LStream* inStream); - ~CGSSWindow (); - static CGSSWindow* CreateGSSWindow ( - ResIDT inWindowID, - LCommander* inSuperCommander); - static CGSSWindow* CreateGSSWindowStream ( - LStream* inStream); - - virtual Boolean ObeyCommand( - CommandT inCommand, - void *ioParam); -/* Boolean AttemptQuit ( - long inSaveOption);*/ - -};
\ No newline at end of file diff --git a/src/mac/gss/CW-Project.hqx b/src/mac/gss/CW-Project.hqx index 64e33c8be..a436393b3 100644 --- a/src/mac/gss/CW-Project.hqx +++ b/src/mac/gss/CW-Project.hqx @@ -1,554 +1,489 @@ (This file must be converted with BinHex 4.0) -:#d&bBfKTGQ8ZFfPd!&0*9%46593K!*!%CeB!N!3aKe0*9#%!"!!!CeCb6'&e!J# -3""C#4!d0&8G6N!0KEA"XC5if1'XZBfCY,R"bDJ#!!*!%""-qG+@3!!#3&"TF!*! -%rj!%68e38N0A588"!+a9%Fq[Y-Z*!!