2006-06-16 15:21:39 +00:00
|
|
|
/* Implementation for NSURLAuthenticationChallenge for GNUstep
|
|
|
|
Copyright (C) 2006 Software Foundation, Inc.
|
|
|
|
|
2009-03-20 18:52:59 +00:00
|
|
|
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
2006-06-16 15:21:39 +00:00
|
|
|
Date: 2006
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2006-06-16 15:21:39 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2006-06-16 15:21:39 +00:00
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2006-06-16 15:21:39 +00:00
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
|
|
|
*/
|
|
|
|
|
2007-11-29 20:53:26 +00:00
|
|
|
#import "GSURLPrivate.h"
|
|
|
|
#import "Foundation/NSError.h"
|
2006-06-16 15:21:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Internal data storage
|
|
|
|
typedef struct {
|
|
|
|
NSURLProtectionSpace *space;
|
|
|
|
NSURLCredential *credential;
|
|
|
|
int previousFailureCount;
|
|
|
|
NSURLResponse *response;
|
|
|
|
NSError *error;
|
|
|
|
id<NSURLAuthenticationChallengeSender> sender;
|
|
|
|
} Internal;
|
|
|
|
|
|
|
|
#define this ((Internal*)(self->_NSURLAuthenticationChallengeInternal))
|
|
|
|
|
|
|
|
@implementation NSURLAuthenticationChallenge
|
|
|
|
|
|
|
|
+ (id) allocWithZone: (NSZone*)z
|
|
|
|
{
|
|
|
|
NSURLAuthenticationChallenge *o = [super allocWithZone: z];
|
|
|
|
|
|
|
|
if (o != nil)
|
|
|
|
{
|
|
|
|
o->_NSURLAuthenticationChallengeInternal
|
2007-03-01 17:35:43 +00:00
|
|
|
= NSZoneCalloc(z, 1, sizeof(Internal));
|
2006-06-16 15:21:39 +00:00
|
|
|
}
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
if (this != 0)
|
|
|
|
{
|
|
|
|
RELEASE(this->space);
|
|
|
|
RELEASE(this->credential);
|
|
|
|
RELEASE(this->response);
|
|
|
|
RELEASE(this->error);
|
|
|
|
RELEASE(this->sender);
|
|
|
|
NSZoneFree([self zone], this);
|
|
|
|
}
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSError *) error
|
|
|
|
{
|
|
|
|
return this->error;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSURLResponse *) failureResponse
|
|
|
|
{
|
|
|
|
return this->response;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithAuthenticationChallenge:
|
|
|
|
(NSURLAuthenticationChallenge *)challenge
|
|
|
|
sender:
|
|
|
|
(id<NSURLAuthenticationChallengeSender>)sender
|
|
|
|
{
|
|
|
|
return [self initWithProtectionSpace: [challenge protectionSpace]
|
|
|
|
proposedCredential: [challenge proposedCredential]
|
|
|
|
previousFailureCount: [challenge previousFailureCount]
|
|
|
|
failureResponse: [challenge failureResponse]
|
|
|
|
error: [challenge error]
|
|
|
|
sender: sender];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithProtectionSpace: (NSURLProtectionSpace *)space
|
|
|
|
proposedCredential: (NSURLCredential *)credential
|
2009-02-23 20:42:32 +00:00
|
|
|
previousFailureCount: (NSInteger)previousFailureCount
|
2006-06-16 15:21:39 +00:00
|
|
|
failureResponse: (NSURLResponse *)response
|
|
|
|
error: (NSError *)error
|
|
|
|
sender: (id<NSURLAuthenticationChallengeSender>)sender
|
|
|
|
{
|
|
|
|
if ((self = [super init]) != nil)
|
|
|
|
{
|
|
|
|
this->space = [space copy];
|
|
|
|
this->credential = [credential copy];
|
|
|
|
this->response = [response copy];
|
|
|
|
this->error = [error copy];
|
|
|
|
this->sender = RETAIN(sender);
|
|
|
|
this->previousFailureCount = previousFailureCount;
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2009-02-23 20:42:32 +00:00
|
|
|
- (NSInteger) previousFailureCount
|
2006-06-16 15:21:39 +00:00
|
|
|
{
|
|
|
|
return this->previousFailureCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSURLCredential *) proposedCredential
|
|
|
|
{
|
|
|
|
return this->credential;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSURLProtectionSpace *) protectionSpace
|
|
|
|
{
|
|
|
|
return this->space;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id<NSURLAuthenticationChallengeSender>) sender
|
|
|
|
{
|
|
|
|
return this->sender;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|