NSURLProtectionSpace Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in OS X v10.2 with Safari 1.0 installed. Available in 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
Tasks
Creating a Protection Space
-
– initWithHost:port:protocol:realm:authenticationMethod: -
– initWithProxyHost:port:type:realm:authenticationMethod:
Getting Protection Space Properties
Instance Methods
authenticationMethod
Returns the authentication method used by the receiver.
Return Value
The authentication method used by the receiver. The supported authentication methods are listed in “Constants.”
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hdistinguishedNames
Returns an array of acceptable certificate-issuing authorities for client certificate authentication.
Return Value
An array of acceptable certificate-issuing authorities, or nil if the authentication method of the protection space is not client certificate.
Discussion
The returned issuing authorities are encoded with Distinguished Encoding Rules (DER).
Availability
- Available in OS X v10.6 and later.
Declared In
NSURLProtectionSpace.hhost
Returns the receiver’s host.
Return Value
The receiver's host.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hinitWithHost:port:protocol:realm:authenticationMethod:
Initializes a protection space object.
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
nilif 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
nilto use the default,NSURLAuthenticationMethodDefault.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hinitWithProxyHost:port:type:realm:authenticationMethod:
Initializes a protection space object representing a proxy server.
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
nilif 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
nilto use the default,NSURLAuthenticationMethodDefault.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hisProxy
Returns whether the receiver represents a proxy server.
Return Value
YES if the receiver represents a proxy server, NO otherwise.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hport
Returns the receiver’s port.
Return Value
The receiver's port.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hprotocol
Returns the receiver’s protocol.
Return Value
The receiver's protocol, or nil if the receiver represents a proxy protection space.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hproxyType
Returns the receiver's proxy type.
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
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hrealm
Returns the receiver’s authentication 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
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hreceivesCredentialSecurely
Returns whether the credentials for the protection space can be sent securely.
Return Value
YES if the credentials for the protection space represented by the receiver can be sent securely, NO otherwise.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hserverTrust
Returns a representation of the server’s SSL transaction state.
Return Value
The server’s SSL transaction state, or nil if the authentication method of the protection space is not server trust.
Availability
- Available in OS X v10.6 and later.
Declared In
NSURLProtectionSpace.hConstants
NSURLProtectionSpace Protocol Types
These constants describe the supported protocols for a protection space, as returned by protocol.
NSString * const NSURLProtectionSpaceHTTP; NSString * const NSURLProtectionSpaceHTTPS; NSString * const NSURLProtectionSpaceFTP;
Constants
NSURLProtectionSpaceHTTPThe protocol type for HTTP.
Available in OS X v10.6 and later.
Declared in
NSURLProtectionSpace.h.NSURLProtectionSpaceHTTPSThe protocol type for HTTPS.
Available in OS X v10.6 and later.
Declared in
NSURLProtectionSpace.h.NSURLProtectionSpaceFTPThe protocol type for FTP.
Available in OS X v10.6 and later.
Declared in
NSURLProtectionSpace.h.
NSURLProtectionSpace Proxy Types
These constants describe the supported proxy types used in initWithProxyHost:port:type:realm:authenticationMethod: and returned by proxyType.
NSString *NSURLProtectionSpaceHTTPProxy; NSString *NSURLProtectionSpaceHTTPSProxy; NSString *NSURLProtectionSpaceFTPProxy; NSString *NSURLProtectionSpaceSOCKSProxy;
Constants
NSURLProtectionSpaceHTTPProxyThe proxy type for HTTP proxies.
Available in OS X v10.2 and later.
Declared in
NSURLProtectionSpace.h.NSURLProtectionSpaceHTTPSProxyThe proxy type for HTTPS proxies.
Available in OS X v10.2 and later.
Declared in
NSURLProtectionSpace.h.NSURLProtectionSpaceFTPProxyThe proxy type for FTP proxies.
Available in OS X v10.2 and later.
Declared in
NSURLProtectionSpace.h.NSURLProtectionSpaceSOCKSProxyThe proxy type for SOCKS proxies.
Available in OS X v10.2 and later.
Declared in
NSURLProtectionSpace.h.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.hNSURLProtectionSpace 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.
NSString *NSURLAuthenticationMethodDefault; NSString *NSURLAuthenticationMethodHTTPBasic; NSString *NSURLAuthenticationMethodHTTPDigest; NSString *NSURLAuthenticationMethodHTMLForm; NSString *NSURLAuthenticationMethodNegotiate; NSString *NSURLAuthenticationMethodNTLM; NSString *NSURLAuthenticationMethodClientCertificate; NSString *NSURLAuthenticationMethodServerTrust;
Constants
NSURLAuthenticationMethodDefaultUse the default authentication method for a protocol.
Available in OS X v10.2 and later.
Declared in
NSURLProtectionSpace.h.NSURLAuthenticationMethodHTTPBasicUse HTTP basic authentication for this protection space.
This is equivalent to
NSURLAuthenticationMethodDefaultfor HTTP.Available in OS X v10.2 and later.
Declared in
NSURLProtectionSpace.h.NSURLAuthenticationMethodHTTPDigestUse HTTP digest authentication for this protection space.
Available in OS X v10.2 and later.
Declared in
NSURLProtectionSpace.h.NSURLAuthenticationMethodHTMLFormUse HTML form authentication for this protection space.
This authentication method can apply to any protocol.
Available in OS X v10.2 and later.
Declared in
NSURLProtectionSpace.h.NSURLAuthenticationMethodNegotiateNegotiate authentication for this protection space.
Available in OS X v10.5 and later.
Declared in
NSURLProtectionSpace.h.NSURLAuthenticationMethodNTLMUse NTLM authentication for this protection space.
Available in OS X v10.5 and later.
Declared in
NSURLProtectionSpace.h.NSURLAuthenticationMethodClientCertificateUse client certificate authentication for this protection space.
This authentication method can apply to any protocol.
Available in OS X v10.6 and later.
Declared in
NSURLProtectionSpace.h.NSURLAuthenticationMethodServerTrustUse server trust authentication for this protection space.
This authentication method can apply to any protocol.
Available in OS X v10.6 and later.
Declared in
NSURLProtectionSpace.h.
Availability
- Available in OS X v10.2 with Safari 1.0 installed.
- Available in OS X v10.2.7 and later.
Declared In
NSURLProtectionSpace.h© 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-05-03)