Add class to handle http digest authentication.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23082 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-06-19 11:20:17 +00:00
parent cefd7bacac
commit c4cedc4b15
6 changed files with 426 additions and 11 deletions

View file

@ -74,19 +74,26 @@ typedef struct {
- (id) copyWithZone: (NSZone*)z
{
NSURLProtectionSpace *o = [[self class] allocWithZone: z];
o = [o initWithHost: this->host
port: this->port
protocol: this->protocol
realm: this->realm
authenticationMethod: this->authenticationMethod];
if (o != nil)
if (NSShouldRetainWithZone(self, z) == YES)
{
inst->isProxy = this->isProxy;
ASSIGN(inst->proxyType, this->proxyType);
return RETAIN(self);
}
else
{
NSURLProtectionSpace *o = [[self class] allocWithZone: z];
o = [o initWithHost: this->host
port: this->port
protocol: this->protocol
realm: this->realm
authenticationMethod: this->authenticationMethod];
if (o != nil)
{
inst->isProxy = this->isProxy;
ASSIGN(inst->proxyType, this->proxyType);
}
return o;
}
return o;
}
- (void) dealloc
@ -103,6 +110,13 @@ typedef struct {
[super dealloc];
}
- (unsigned) hash
{
return [[self host] hash] + [self port]
+ [[self realm] hash] + [[self protocol] hash]
+ [[self proxyType] hash] + [[self authenticationMethod] hash];
}
- (NSString *) host
{
return this->host;
@ -146,6 +160,52 @@ authenticationMethod: (NSString *)authenticationMethod
return NO;
}
- (unsigned) isEqual: (id)other
{
if ([other isKindOfClass: [NSURLProtocol class]] == NO)
{
return NO;
}
else
{
NSURLProtectionSpace *o = (NSURLProtectionSpace*)other;
if (![[self host] isEqual: [o host]] == NO)
{
return NO;
}
if (![[self realm] isEqual: [o realm]] == NO)
{
return NO;
}
if ([self port] != [o port])
{
return NO;
}
if (![[self authenticationMethod] isEqual: [o authenticationMethod]])
{
return NO;
}
if ([self isProxy] == YES)
{
if ([o isProxy] == NO
|| [[self proxyType] isEqual: [o proxyType]] == NO)
{
return NO;
}
}
else
{
if ([o isProxy] == YES
|| [[self protocol] isEqual: [o protocol]] == NO)
{
return NO;
}
}
return YES;
}
}
- (BOOL) isProxy
{
return this->isProxy;