mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Improve authentication handling ... only send authentication information in
response to a challenge from the server. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23123 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5ee10ff9c7
commit
a35bf27851
5 changed files with 322 additions and 266 deletions
|
@ -43,8 +43,8 @@ typedef struct {
|
|||
int port;
|
||||
NSString *protocol;
|
||||
NSString *realm;
|
||||
NSString *proxyType;
|
||||
NSString *authenticationMethod;
|
||||
NSString *proxyType; // Not retained
|
||||
NSString *authenticationMethod; // Not retained
|
||||
BOOL isProxy;
|
||||
} Internal;
|
||||
|
||||
|
@ -90,7 +90,7 @@ typedef struct {
|
|||
if (o != nil)
|
||||
{
|
||||
inst->isProxy = this->isProxy;
|
||||
ASSIGN(inst->proxyType, this->proxyType);
|
||||
inst->proxyType = this->proxyType;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
@ -102,9 +102,7 @@ typedef struct {
|
|||
{
|
||||
RELEASE(this->host);
|
||||
RELEASE(this->protocol);
|
||||
RELEASE(this->proxyType);
|
||||
RELEASE(this->realm);
|
||||
RELEASE(this->authenticationMethod);
|
||||
NSZoneFree([self zone], this);
|
||||
}
|
||||
[super dealloc];
|
||||
|
@ -114,7 +112,7 @@ typedef struct {
|
|||
{
|
||||
return [[self host] hash] + [self port]
|
||||
+ [[self realm] hash] + [[self protocol] hash]
|
||||
+ [[self proxyType] hash] + [[self authenticationMethod] hash];
|
||||
+ (uintptr_t)this->proxyType + (uintptr_t)this->authenticationMethod;
|
||||
}
|
||||
|
||||
- (NSString *) host
|
||||
|
@ -133,7 +131,25 @@ authenticationMethod: (NSString *)authenticationMethod
|
|||
this->host = [host copy];
|
||||
this->protocol = [protocol copy];
|
||||
this->realm = [realm copy];
|
||||
this->authenticationMethod = [authenticationMethod copy];
|
||||
if ([authenticationMethod isEqualToString:
|
||||
NSURLAuthenticationMethodHTMLForm] == YES)
|
||||
{
|
||||
this->authenticationMethod = NSURLAuthenticationMethodHTMLForm;
|
||||
}
|
||||
else if ([authenticationMethod isEqualToString:
|
||||
NSURLAuthenticationMethodHTTPBasic] == YES)
|
||||
{
|
||||
this->authenticationMethod = NSURLAuthenticationMethodHTTPBasic;
|
||||
}
|
||||
else if ([authenticationMethod isEqualToString:
|
||||
NSURLAuthenticationMethodHTTPDigest] == YES)
|
||||
{
|
||||
this->authenticationMethod = NSURLAuthenticationMethodHTTPDigest;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->authenticationMethod = NSURLAuthenticationMethodDefault;
|
||||
}
|
||||
this->port = port;
|
||||
this->proxyType = nil;
|
||||
this->isProxy = NO;
|
||||
|
@ -155,9 +171,28 @@ authenticationMethod: (NSString *)authenticationMethod
|
|||
if (self != nil)
|
||||
{
|
||||
this->isProxy = YES;
|
||||
ASSIGNCOPY(this->proxyType, type);
|
||||
if ([type isEqualToString: NSURLProtectionSpaceFTPProxy] == YES)
|
||||
{
|
||||
this->proxyType = NSURLProtectionSpaceFTPProxy;
|
||||
}
|
||||
else if ([type isEqualToString: NSURLProtectionSpaceHTTPProxy] == YES)
|
||||
{
|
||||
this->proxyType = NSURLProtectionSpaceHTTPProxy;
|
||||
}
|
||||
else if ([type isEqualToString: NSURLProtectionSpaceHTTPSProxy] == YES)
|
||||
{
|
||||
this->proxyType = NSURLProtectionSpaceHTTPSProxy;
|
||||
}
|
||||
else if ([type isEqualToString: NSURLProtectionSpaceSOCKSProxy] == YES)
|
||||
{
|
||||
this->proxyType = NSURLProtectionSpaceSOCKSProxy;
|
||||
}
|
||||
else
|
||||
{
|
||||
DESTROY(self); // Bad proxy type.
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isEqual: (id)other
|
||||
|
@ -237,13 +272,13 @@ authenticationMethod: (NSString *)authenticationMethod
|
|||
|
||||
- (BOOL) receivesCredentialSecurely
|
||||
{
|
||||
if ([this->authenticationMethod isEqual: NSURLAuthenticationMethodHTTPDigest])
|
||||
if (this->authenticationMethod == NSURLAuthenticationMethodHTTPDigest)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
if (this->isProxy)
|
||||
{
|
||||
if ([this->proxyType isEqual: NSURLProtectionSpaceHTTPSProxy] == YES)
|
||||
if (this->proxyType == NSURLProtectionSpaceHTTPSProxy)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue