iOS Developer Library

Developer

CoreServices 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.

  • Returns a Boolean value that indicates whether a CFHTTPAuthentication object is associated with a CFHTTPMessage object.

    Declaration

    Swift

    func CFHTTPAuthenticationAppliesToRequest(_ auth: CFHTTPAuthentication!, _ request: CFHTTPMessage!) -> Boolean

    Objective-C

    Boolean CFHTTPAuthenticationAppliesToRequest ( CFHTTPAuthenticationRef auth, CFHTTPMessageRef request );

    Parameters

    auth

    The CFHTTPAuthentication object to examine.

    request

    Request that auth is to be tested against.

    Return Value

    TRUE if auth is associated with request, otherwise FALSE.

    Discussion

    If this function returns TRUE, you can use auth to provide authentication information when using request.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Returns an array of domain URLs to which a given CFHTTPAuthentication object can be applied.

    Declaration

    Swift

    func CFHTTPAuthenticationCopyDomains(_ auth: CFHTTPAuthentication!) -> Unmanaged<CFArray>!

    Objective-C

    CFArrayRef CFHTTPAuthenticationCopyDomains ( CFHTTPAuthenticationRef auth );

    Parameters

    auth

    The CFHTTPAuthentication object to examine.

    Return Value

    A CFArray object that contains the domain URL’s to which auth should be applied. Ownership follows the Create Rule.

    Discussion

    This function is provided for informational purposes only.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Gets the strongest authentication method that will be used when a CFHTTPAuthentication object is applied to a request.

    Declaration

    Swift

    func CFHTTPAuthenticationCopyMethod(_ auth: CFHTTPAuthentication!) -> Unmanaged<CFString>!

    Objective-C

    CFStringRef CFHTTPAuthenticationCopyMethod ( CFHTTPAuthenticationRef auth );

    Parameters

    auth

    The CFHTTPAuthentication object to examine.

    Return Value

    A string containing the authentication method that will be used auth is applied to a request. If more than one authentication method is available, the strongest authentication method is returned. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Gets an authentication information’s namespace.

    Declaration

    Swift

    func CFHTTPAuthenticationCopyRealm(_ auth: CFHTTPAuthentication!) -> Unmanaged<CFString>!

    Objective-C

    CFStringRef CFHTTPAuthenticationCopyRealm ( CFHTTPAuthenticationRef auth );

    Parameters

    auth

    The CFHTTPAuthentication object to examine.

    Return Value

    The namespace, if there is one; otherwise NULL. Ownership follows the Create Rule.

    Discussion

    Some authentication methods provide a namespace, and it is usually used to prompt the user for a name and password.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Returns a Boolean value that indicates whether a CFHTTPAuthentication object is valid.

    Declaration

    Swift

    func CFHTTPAuthenticationIsValid(_ auth: CFHTTPAuthentication!, _ error: UnsafeMutablePointer<CFStreamError>) -> Boolean

    Objective-C

    Boolean CFHTTPAuthenticationIsValid ( CFHTTPAuthenticationRef auth, CFStreamError *error );

    Parameters

    auth

    The CFHTTPAuthentication object to examine.

    error

    Pointer to a CFStreamError structure, whose fields, if an error has occurred, are set to the error and the error’s domain.

    Return Value

    TRUE if auth contains enough information to be applied to a request.

    If this function returns FALSE, the CFHTTPAuthentication object may still contain useful information, such as the name of an unsupported authentication method.

    Discussion

    If this function returns TRUE for auth, the object is good for use with functions such as CFHTTPMessageApplyCredentials and CFHTTPMessageApplyCredentialDictionary. If this function returns FALSE, auth is invalid, and authentications using it will not succeed.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Returns a Boolean value that indicates whether a CFHTTPAuthentication object uses an authentication method that requires an account domain.

    Declaration

    Swift

    func CFHTTPAuthenticationRequiresAccountDomain(_ auth: CFHTTPAuthentication!) -> Boolean

    Objective-C

    Boolean CFHTTPAuthenticationRequiresAccountDomain ( CFHTTPAuthenticationRef auth );

    Parameters

    auth

    The CFHTTPAuthentication object to examine.

    Return Value

    TRUE if auth uses an authentication method that requires an account domain, otherwise FALSE.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Returns a Boolean value that indicates whether authentication requests should be made one at a time.

    Declaration

    Swift

    func CFHTTPAuthenticationRequiresOrderedRequests(_ auth: CFHTTPAuthentication!) -> Boolean

    Objective-C

    Boolean CFHTTPAuthenticationRequiresOrderedRequests ( CFHTTPAuthenticationRef auth );

    Parameters

    auth

    The CFHTTPAuthentication object to examine.

    Return Value

    TRUE if auth requires ordered requests, otherwise FALSE.

    Discussion

    Some authentication methods require that future requests must be performed in an ordered manner. If this function returns TRUE, clients can improve their chances of authenticating successfully by issuing requests one at a time as responses come back from the server.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Returns a Boolean value that indicates whether a CFHTTPAuthentication object uses an authentication method that requires a username and a password.

    Declaration

    Swift

    func CFHTTPAuthenticationRequiresUserNameAndPassword(_ auth: CFHTTPAuthentication!) -> Boolean

    Objective-C

    Boolean CFHTTPAuthenticationRequiresUserNameAndPassword ( CFHTTPAuthenticationRef auth );

    Parameters

    auth

    The CFHTTPAuthentication object to examine.

    Return Value

    TRUE if auth requires a username and password when it is applied to a request; otherwise, FALSE.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • 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.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

Data Types

  • An opaque reference representing HTTP authentication information.

    Declaration

    Swift

    typealias CFHTTPAuthenticationRef = CFHTTPAuthentication

    Objective-C

    typedef struct __CFHTTPAuthentication *CFHTTPAuthenticationRef;

    Availability

    Available in iOS 2.0 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 iOS 2.0 and later.

    • kCFHTTPAuthenticationSchemeDigest

      kCFHTTPAuthenticationSchemeDigest

      Reserved.

      Available in iOS 2.0 and later.

    • kCFHTTPAuthenticationSchemeNegotiate

      kCFHTTPAuthenticationSchemeNegotiate

      Specifies the Negotiate authentication scheme.

      Available in iOS 2.0 and later.

    • kCFHTTPAuthenticationSchemeNTLM

      kCFHTTPAuthenticationSchemeNTLM

      Specifies the NTLM authentication scheme.

      Available in iOS 2.0 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 iOS 2.0 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 iOS 2.0 and later.

    • BadPassword

      kCFStreamErrorHTTPAuthenticationBadPassword

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

      Available in iOS 2.0 and later.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 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 iOS 2.0 and later.

    • kCFHTTPAuthenticationPassword

      kCFHTTPAuthenticationPassword

      Password to use for authentication.

      Available in iOS 2.0 and later.

    • kCFHTTPAuthenticationAccountDomain

      kCFHTTPAuthenticationAccountDomain

      Account domain to use for authentication.

      Available in iOS 2.0 and later.