mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Updates for message authentication stuff
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6871 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
705958575c
commit
1df9368648
8 changed files with 96 additions and 30 deletions
|
@ -5,12 +5,41 @@
|
|||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <assert.h>
|
||||
#include "server.h"
|
||||
|
||||
@interface Auth : NSObject
|
||||
@end
|
||||
|
||||
@implementation Auth
|
||||
- (BOOL) authenticateComponents: (NSMutableArray*)components
|
||||
withData: (NSData*)authData
|
||||
{
|
||||
unsigned count = [components count];
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
id obj = [components objectAtIndex: count];
|
||||
|
||||
if ([obj isKindOfClass: [NSData class]] == YES)
|
||||
{
|
||||
NSMutableData *d = [obj mutableCopy];
|
||||
unsigned l = [d length];
|
||||
char *p = (char*)[d mutableBytes];
|
||||
|
||||
while (l-- > 0)
|
||||
p[l] ^= 42;
|
||||
[components replaceObjectAtIndex: count withObject: d];
|
||||
RELEASE(d);
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
|
@ -36,6 +65,7 @@ int main (int argc, char *argv[])
|
|||
BOOL b;
|
||||
const char *type;
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
Auth *auth = [Auth new];
|
||||
|
||||
GSDebugAllocationActive(YES);
|
||||
[NSConnection setDebug: 10];
|
||||
|
@ -59,6 +89,7 @@ printf("oneway %d\n", _F_ONEWAY);
|
|||
p = [NSConnection rootProxyForConnectionWithRegisteredName:@"test2server"
|
||||
host:nil];
|
||||
c = [p connectionForProxy];
|
||||
[c setDelegate:auth];
|
||||
[c setRequestTimeout:180.0];
|
||||
[c setReplyTimeout:180.0];
|
||||
localObj = [[NSObject alloc] init];
|
||||
|
|
|
@ -5,12 +5,36 @@
|
|||
#include <Foundation/NSDistantObject.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <base/BinaryCStream.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include "server.h"
|
||||
|
||||
@implementation Server
|
||||
- (NSData*) authenticationDataForComponents: (NSMutableArray*)components
|
||||
{
|
||||
unsigned count = [components count];
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
id obj = [components objectAtIndex: count];
|
||||
|
||||
if ([obj isKindOfClass: [NSData class]] == YES)
|
||||
{
|
||||
NSMutableData *d = [obj mutableCopy];
|
||||
unsigned l = [d length];
|
||||
char *p = (char*)[d mutableBytes];
|
||||
|
||||
while (l-- > 0)
|
||||
p[l] ^= 42;
|
||||
[components replaceObjectAtIndex: count withObject: d];
|
||||
RELEASE(d);
|
||||
}
|
||||
}
|
||||
return [NSData data];
|
||||
}
|
||||
|
||||
- init
|
||||
{
|
||||
the_array = [[NSMutableArray alloc] init];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue