Revision: 27853 http://sourceforge.net/p/bibdesk/svn/27853 Author: hofman Date: 2022-09-04 18:10:44 +0000 (Sun, 04 Sep 2022) Log Message: ----------- Always authenticate message components, but register legacy authentication methods. Raise exception when legacy authentication fails for keyedRootObject message, to simulate exception taht the legacy clients expects at authentication failure.
Modified Paths: -------------- trunk/bibdesk/BDSKSharingServer.m Modified: trunk/bibdesk/BDSKSharingServer.m =================================================================== --- trunk/bibdesk/BDSKSharingServer.m 2022-09-03 17:10:36 UTC (rev 27852) +++ trunk/bibdesk/BDSKSharingServer.m 2022-09-04 18:10:44 UTC (rev 27853) @@ -95,6 +95,10 @@ [pool release]; } +@interface NSConnection (BDSKPrivateDeclarations) +- (id)keyedRootObject; +@end + #pragma mark - @interface BDSKConnectedClient : NSObject <NSConnectionDelegate> { @@ -101,6 +105,7 @@ NSConnection *connection; id proxy; BOOL authenticated; + BOOL legacyAuthentication; } - (id)initWithConnection:(NSConnection *)aConnection; @@ -880,23 +885,28 @@ char zero = 0; zeroData = [[NSData alloc] initWithBytes:&zero length:1]; } - BOOL status = YES; // legacy clients use this method to authenticate if ([authenticationData isEqual:zeroData] == NO && [self isAuthenticated] == NO) { NSData *myPasswordHashed = [[BDSKPasswordController passwordForKeychainService:BDSKServiceNameForKeychain account:nil name:nil] sha1Signature]; - status = [authenticationData isEqual:myPasswordHashed]; - if (status) + if ([authenticationData isEqual:myPasswordHashed]) [self setAuthenticated:YES]; + legacyAuthentication = YES; } - return status; + return YES; } - (BOOL)connection:(NSConnection *)aConnection handleRequest:(NSDistantObjectRequest *)doRequest { // accept all messages from the server protocol // but archivedSnapshotOfPublications only when authenticated - if ([[doRequest invocation] selector] == @selector(archivedSnapshotOfPublications) && [self isAuthenticated] == NO){ - [doRequest replyWithException:[NSException exceptionWithName:@"BDSKUnauthenticatedException" reason:@"Client was not authenticated" userInfo:nil]]; - return YES; + if ([self isAuthenticated] == NO) { + SEL aSelector = [[doRequest invocation] selector]; + if (aSelector == @selector(archivedSnapshotOfPublications)){ + [doRequest replyWithException:[NSException exceptionWithName:NSFailedAuthenticationException reason:@"Client was not authenticated" userInfo:nil]]; + return YES; + } else if (legacyAuthentication && (aSelector == @selector(keyedRootObject) || aSelector == @selector(rootObject))){ + [doRequest replyWithException:[NSException exceptionWithName:NSFailedAuthenticationException reason:@"Client was not authenticated" userInfo:nil]]; + return YES; + } } return NO; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit