Next Page > Hide TOC

NSURLProtectionSpace Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.2 with Safari 1.0 installed.
Available in Mac OS X v10.2.7 and later.
Companion guide
Declared in
NSURLProtectionSpace.h

Overview

NSURLProtectionSpace represents a server or an area on a server, commonly referred to as a realm, that requires authentication. An NSURLProtectionSpace’s credentials apply to any requests within that protection space.

Adopted Protocols

NSCopying

Tasks

Creating a Protection Space

Getting Protection Space Properties

Instance Methods

authenticationMethod

Returns the authentication method used by the receiver.

- (NSString *)authenticationMethod

Return Value

The authentication method used by the receiver. The supported authentication methods are listed in “Constants.”

Availability
Declared In
NSURLProtectionSpace.h

host

Returns the receiver’s host.

- (NSString *)host

Return Value

The receiver's host.

Availability
Declared In
NSURLProtectionSpace.h

initWithHost:port:protocol:realm:authenticationMethod:

Initializes a protection space object.

- (id)initWithHost:(NSString *)host port:(NSInteger)port protocol:(NSString *)protocol realm:(NSString *)realm authenticationMethod:(NSString *)authenticationMethod

Parameters
host

The host name for the protection space object.

port

The port for the protection space object. If port is 0 the default port for the specified protocol is used, for example, port 80 for HTTP. Note that servers can, and do, treat these values differently.

protocol

The protocol for the protection space object. The value of protocol is equivalent to the scheme for a URL in the protection space, for example, “http”, “https”, “ftp”, etc.

realm

A string indicating a protocol specific subdivision of the host. realm may be nil if there is no specified realm or if the protocol doesn’t support realms.

authenticationMethod

The type of authentication to use. authenticationMethod should be set to one of the values in “Constants” or nil to use the default, NSURLAuthenticationMethodDefault.

Availability
See Also
Declared In
NSURLProtectionSpace.h

initWithProxyHost:port:type:realm:authenticationMethod:

Initializes a protection space object representing a proxy server.

- (id)initWithProxyHost:(NSString *)host port:(NSInteger)port type:(NSString *)proxyType realm:(NSString *)realm authenticationMethod:(NSString *)authenticationMethod

Parameters
host

The host of the proxy server for the protection space object.

port

The port for the protection space object. If port is 0 the default port for the specified proxy type is used, for example, port 80 for HTTP. Note that servers can, and do, treat these values differently.

proxyType

The type of proxy server. The value of proxyType should be set to one of the values specified in “Constants.”

realm

A string indicating a protocol specific subdivision of the host. realm may be nil if there is no specified realm or if the protocol doesn’t support realms.

authenticationMethod

The type of authentication to use. authenticationMethod should be set to one of the values in “Constants” or nil to use the default, NSURLAuthenticationMethodDefault.

Availability
See Also
Declared In
NSURLProtectionSpace.h

isProxy

Returns whether the receiver represents a proxy server.

- (BOOL)isProxy

Return Value

YES if the receiver represents a proxy server, NO otherwise.

Availability
Declared In
NSURLProtectionSpace.h

port

Returns the receiver’s port.

- (NSInteger)port

Return Value

The receiver's port.

Availability
Declared In
NSURLProtectionSpace.h

protocol

Returns the receiver’s protocol.

- (NSString *)protocol

Return Value

The receiver's protocol, or nil if the receiver represents a proxy protection space.

Availability
Declared In
NSURLProtectionSpace.h

proxyType

Returns the receiver's proxy type.

- (NSString *)proxyType

Return Value

The receiver's proxy type, or nil if the receiver does not represent a proxy protection space. The supported proxy types are listed in “Constants.”

Availability
Declared In
NSURLProtectionSpace.h

realm

Returns the receiver’s authentication realm

- (NSString *)realm

Return Value

The receiver’s authentication realm, or nil if no realm has been set.

Discussion

A realm is generally only specified for HTTP and HTTPS authentication.

Availability
Declared In
NSURLProtectionSpace.h

receivesCredentialSecurely

Returns whether the credentials for the protection space can be sent securely.

- (BOOL)receivesCredentialSecurely

Return Value

YES if the credentials for the protection space represented by the receiver can be sent securely, NO otherwise.

Availability
Declared In
NSURLProtectionSpace.h

Constants

NSURLProtectionSpace Proxy Types

These constants describe the supported proxy types used in initWithProxyHost:port:type:realm:authenticationMethod: and returned by proxyType.

extern NSString *NSURLProtectionSpaceHTTPProxy;
extern NSString *NSURLProtectionSpaceHTTPSProxy;
extern NSString *NSURLProtectionSpaceFTPProxy;
extern NSString *NSURLProtectionSpaceSOCKSProxy;

Constants
NSURLProtectionSpaceHTTPProxy

The proxy type for HTTP proxies.

Available in Mac OS X v10.2 and later.

Declared in NSURLProtectionSpace.h.

NSURLProtectionSpaceHTTPSProxy

The proxy type for HTTPS proxies.

Available in Mac OS X v10.2 and later.

Declared in NSURLProtectionSpace.h.

NSURLProtectionSpaceFTPProxy

The proxy type for FTP proxies.

Available in Mac OS X v10.2 and later.

Declared in NSURLProtectionSpace.h.

NSURLProtectionSpaceSOCKSProxy

The proxy type for SOCKS proxies.

Available in Mac OS X v10.2 and later.

Declared in NSURLProtectionSpace.h.

Availability
Declared In
NSURLProtectionSpace.h

NSURLProtectionSpace Authentication Methods

These constants describe the available authentication methods used in initWithHost:port:protocol:realm:authenticationMethod:, initWithProxyHost:port:type:realm:authenticationMethod: and returned by authenticationMethod.

extern NSString *NSURLAuthenticationMethodDefault;
extern NSString *NSURLAuthenticationMethodHTTPBasic;
extern NSString *NSURLAuthenticationMethodHTTPDigest;
extern NSString *NSURLAuthenticationMethodHTMLForm;

Constants
NSURLAuthenticationMethodDefault

Use the default authentication method for a protocol.

Available in Mac OS X v10.2 and later.

Declared in NSURLProtectionSpace.h.

NSURLAuthenticationMethodHTTPBasic

Use HTTP basic authentication for this protection space.

This is equivalent to NSURLAuthenticationMethodDefault for HTTP.

Available in Mac OS X v10.2 and later.

Declared in NSURLProtectionSpace.h.

NSURLAuthenticationMethodHTTPDigest

Use HTTP digest authentication for this protection space.

Available in Mac OS X v10.2 and later.

Declared in NSURLProtectionSpace.h.

NSURLAuthenticationMethodHTMLForm

Use HTML form authentication for this protection space.

This authentication method can apply to any protocol.

Available in Mac OS X v10.2 and later.

Declared in NSURLProtectionSpace.h.

Availability
Declared In
NSURLProtectionSpace.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.