Mac Developer Library

Developer

Core Services Framework Reference CFHTTPAuthentication Reference

Options
Deployment Target:

On This Page
Language:

CFHTTPAuthentication Reference

The CFHTTPAuthentication opaque type provides an abstraction of HTTP authentication information.

Functions

This section describes the CFNetwork authentication functions that are used to manage authentication information associated with a request. The functions work with a CFHTTPAuthentication object, which is created from an HTTP response that failed with a 401 or 407 error code.

When you have analyzed the CFHTTPAuthentication object and acquired the necessary credentials to perform the authentication, call CFHTTPMessageApplyCredentials or CFHTTPMessageApplyCredentialDictionary to perform the authentication.

  • Gets the Core Foundation type identifier for the CFHTTPAuthentication opaque type.

    Declaration

    Swift

    func CFHTTPAuthenticationGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CFHTTPAuthenticationGetTypeID ( void );

    Return Value

    The Core Foundation type identifier for the CFHTTPAuthentication opaque type.

    Availability

    Available in OS X version 10.4 and later.

Data Types

  • An opaque reference representing HTTP authentication information.

    Declaration

    Swift

    class CFHTTPAuthentication { }

    Objective-C

    typedef struct __CFHTTPAuthentication *CFHTTPAuthenticationRef;

    Availability

    Available in OS X version 10.4 and later.

Constants

  • Specifies the authentication scheme when adding authentication information to a CFHTTP request message object.

    Declaration

    Swift

    let kCFHTTPAuthenticationSchemeBasic: CFString let kCFHTTPAuthenticationSchemeDigest: CFString let kCFHTTPAuthenticationSchemeNegotiate: CFString let kCFHTTPAuthenticationSchemeNTLM: CFString

    Objective-C

    const CFStringRef kCFHTTPAuthenticationSchemeBasic; const CFStringRef kCFHTTPAuthenticationSchemeDigest; const CFStringRef kCFHTTPAuthenticationSchemeNegotiate; const CFStringRef kCFHTTPAuthenticationSchemeNTLM;

    Constants

    • kCFHTTPAuthenticationSchemeBasic

      kCFHTTPAuthenticationSchemeBasic

      Specifies basic authentication consisting of a user name and a password.

      Available in OS X v10.2 and later.

    • kCFHTTPAuthenticationSchemeDigest

      kCFHTTPAuthenticationSchemeDigest

      Reserved.

      Available in OS X v10.2 and later.

    • kCFHTTPAuthenticationSchemeNegotiate

      kCFHTTPAuthenticationSchemeNegotiate

      Specifies the Negotiate authentication scheme.

      Available in OS X v10.5 and later.

    • kCFHTTPAuthenticationSchemeNTLM

      kCFHTTPAuthenticationSchemeNTLM

      Specifies the NTLM authentication scheme.

      Available in OS X v10.5 and later.

    Discussion

    The authentication scheme constants are used to specify the authentication scheme when calling CFHTTPMessageAddAuthentication.

  • Authentication error codes that may be returned when trying to apply authentication to a request.

    Declaration

    Swift

    enum CFStreamErrorHTTPAuthentication : Int32 { case TypeUnsupported case BadUserName case BadPassword }

    Objective-C

    enum CFStreamErrorHTTPAuthentication { kCFStreamErrorHTTPAuthenticationTypeUnsupported = -1000, kCFStreamErrorHTTPAuthenticationBadUserName = -1001, kCFStreamErrorHTTPAuthenticationBadPassword = -1002 }; typedef enum CFStreamErrorHTTPAuthentication CFStreamErrorHTTPAuthentication;

    Constants

    • typeUnsupported

      kCFStreamErrorHTTPAuthenticationTypeUnsupported

      Specified authentication type is not supported.

      Available in OS X v10.4 and later.

    • badUserName

      kCFStreamErrorHTTPAuthenticationBadUserName

      User name is in a format that is not suitable for the request. Currently, user names are decoded using kCFStringEncodingISOLatin1.

      Available in OS X v10.4 and later.

    • badPassword

      kCFStreamErrorHTTPAuthenticationBadPassword

      Password is in a format that is not suitable for the request. Currently, passwords are decoded using kCFStringEncodingISOLatin1.

      Available in OS X v10.4 and later.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in OS X v10.4 and later.

  • Constants for keys in the dictionary passed to CFHTTPMessageApplyCredentialDictionary.

    Declaration

    Swift

    let kCFHTTPAuthenticationUsername: CFString let kCFHTTPAuthenticationPassword: CFString let kCFHTTPAuthenticationAccountDomain: CFString

    Objective-C

    const CFStringRef kCFHTTPAuthenticationUsername; const CFStringRef kCFHTTPAuthenticationPassword; const CFStringRef kCFHTTPAuthenticationAccountDomain;

    Constants

    • kCFHTTPAuthenticationUsername

      kCFHTTPAuthenticationUsername

      Username to use for authentication.

      Available in OS X v10.4 and later.

    • kCFHTTPAuthenticationPassword

      kCFHTTPAuthenticationPassword

      Password to use for authentication.

      Available in OS X v10.4 and later.

    • kCFHTTPAuthenticationAccountDomain

      kCFHTTPAuthenticationAccountDomain

      Account domain to use for authentication.

      Available in OS X v10.4 and later.