| Derived from | |
| Framework | |
| Companion guide | |
| Declared in | CFHTTPAuthentication.h |
The CFHTTPAuthentication opaque type provides an abstraction of HTTP authentication information.
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.
CFHTTPAuthenticationAppliesToRequest
CFHTTPAuthenticationCopyDomains
CFHTTPAuthenticationCopyMethod
CFHTTPAuthenticationCopyRealm
CFHTTPAuthenticationIsValid
CFHTTPAuthenticationRequiresAccountDomain
CFHTTPAuthenticationRequiresOrderedRequests
CFHTTPAuthenticationRequiresUserNameAndPassword
Returns a Boolean value that indicates whether a CFHTTPAuthentication object is associated with a CFHTTPMessage object.
Boolean CFHTTPAuthenticationAppliesToRequest ( CFHTTPAuthenticationRef auth, CFHTTPMessageRef request );
The CFHTTPAuthentication object to examine.
Request that auth is to be tested against.
TRUE if auth is associated with request, otherwise FALSE.
If this function returns TRUE, you can use auth to provide authentication information when using request.
CFHTTPAuthentication.hReturns an array of domain URLs to which a given CFHTTPAuthentication object can be applied.
CFArrayRef CFHTTPAuthenticationCopyDomains ( CFHTTPAuthenticationRef auth );
The CFHTTPAuthentication object to examine.
A CFArray object that contains the domain URL’s to which auth should be applied. Ownership follows the Create Rule.
This function is provided for informational purposes only.
CFHTTPAuthentication.hGets the strongest authentication method that will be used when a CFHTTPAuthentication object is applied to a request.
CFStringRef CFHTTPAuthenticationCopyMethod ( CFHTTPAuthenticationRef auth );
The CFHTTPAuthentication object to examine.
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.
CFHTTPAuthentication.hGets an authentication information’s namespace.
CFStringRef CFHTTPAuthenticationCopyRealm ( CFHTTPAuthenticationRef auth );
The CFHTTPAuthentication object to examine.
The namespace, if there is one; otherwise NULL. Ownership follows the Create Rule.
Some authentication methods provide a namespace, and it is usually used to prompt the user for a name and password.
CFHTTPAuthentication.hUses an authentication failure response to create a CFHTTPAuthentication object.
CFHTTPAuthenticationRef CFHTTPAuthenticationCreateFromResponse ( CFAllocatorRef alloc, CFHTTPMessageRef response );
The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
Response indicating an authentication failure; usually a 401 or a 407 response.
CFHTTPAuthentication object that can be used for adding credentials to future requests. Ownership follows the Create Rule.
This function uses a response containing authentication failure information to create a reference to a CFHTTPAuthentication object. You can use the object to add credentials to future requests. You can query the object to get the following information:
whether it can be used and re-used to authenticate with its corresponding server [CFHTTPAuthenticationIsValid]
the authentication method that will be used when it is used to perform an authentication [CFHTTPAuthenticationCopyMethod]
whether it is associated with a particular CFHTTPMessageRef [CFHTTPAuthenticationAppliesToRequest
whether a user name and a password will be required when it is used to perform an authentication [CFHTTPAuthenticationRequiresUserNameAndPassword]
whether an account domain will be required when it is used to perform an authentication [CFHTTPAuthenticationRequiresAccountDomain]
whether authentication requests should be sent one at a time to the corresponding server [CFHTTPAuthenticationRequiresOrderedRequests]
the namespace (if any) that the domain uses to prompt for a name and password [CFHTTPAuthenticationCopyRealm]
the domain URLs the instance applies to [CFHTTPAuthenticationCopyDomains]
When you have determined what information will be needed to perform the authentication and accumulated that information, call CFHTTPMessageApplyCredentials or CFHTTPMessageApplyCredentialDictionary to perform the authentication.
CFHTTPAuthentication.hGets the Core Foundation type identifier for the CFHTTPAuthentication opaque type.
CFTypeID CFHTTPAuthenticationGetTypeID ();
The Core Foundation type identifier for the CFHTTPAuthentication opaque type.
CFHTTPAuthentication.hReturns a Boolean value that indicates whether a CFHTTPAuthentication object is valid.
Boolean CFHTTPAuthenticationIsValid ( CFHTTPAuthenticationRef auth, CFStreamError *error );
The CFHTTPAuthentication object to examine.
Pointer to a CFStreamError structure, whose fields, if an error has occurred, are set to the error and the error’s domain.
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.
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.
CFHTTPAuthentication.hReturns a Boolean value that indicates whether a CFHTTPAuthentication object uses an authentication method that requires an account domain.
Boolean CFHTTPAuthenticationRequiresAccountDomain ( CFHTTPAuthenticationRef auth );
The CFHTTPAuthentication object to examine.
TRUE if auth uses an authentication method that requires an account domain, otherwise FALSE.
CFHTTPAuthentication.hReturns a Boolean value that indicates whether authentication requests should be made one at a time.
Boolean CFHTTPAuthenticationRequiresOrderedRequests ( CFHTTPAuthenticationRef auth );
The CFHTTPAuthentication object to examine.
TRUE if auth requires ordered requests, otherwise FALSE.
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.
CFHTTPAuthentication.hReturns a Boolean value that indicates whether a CFHTTPAuthentication object uses an authentication method that requires a username and a password.
Boolean CFHTTPAuthenticationRequiresUserNameAndPassword ( CFHTTPAuthenticationRef auth );
The CFHTTPAuthentication object to examine.
TRUE if auth requires a username and password when it is applied to a request; otherwise, FALSE.
CFHTTPAuthentication.hAn opaque reference representing HTTP authentication information.
typedef struct __CFHTTPAuthentication *CFHTTPAuthenticationRef;
CFHTTPAuthentication.hSpecifies the authentication scheme when adding authentication information to a CFHTTP request message object.
const CFStringRef kCFHTTPAuthenticationSchemeBasic; const CFStringRef kCFHTTPAuthenticationSchemeDigest; const CFStringRef kCFHTTPAuthenticationSchemeNegotiate; const CFStringRef kCFHTTPAuthenticationSchemeNTLM;
kCFHTTPAuthenticationSchemeBasicSpecifies basic authentication consisting of a user name and a password.
kCFHTTPAuthenticationSchemeDigestReserved.
kCFHTTPAuthenticationSchemeNegotiateSpecifies the Negotiate authentication scheme.
kCFHTTPAuthenticationSchemeNTLMSpecifies the NTLM authentication scheme.
The authentication scheme constants are used to specify the authentication scheme when calling CFHTTPMessageAddAuthentication.
CFNetwork/CFHTTPMessage.hAuthentication error codes that may be returned when trying to apply authentication to a request.
enum CFStreamErrorHTTPAuthentication{ kCFStreamErrorHTTPAuthenticationTypeUnsupported = -1000, kCFStreamErrorHTTPAuthenticationBadUserName = -1001, kCFStreamErrorHTTPAuthenticationBadPassword = -1002 }; typedef enum CFStreamErrorHTTPAuthentication CFStreamErrorHTTPAuthentication;
kCFStreamErrorHTTPAuthenticationTypeUnsupportedSpecified authentication type is not supported.
Available in Mac OS X v10.4 and later.
Declared in CFHTTPAuthentication.h
kCFStreamErrorHTTPAuthenticationBadUserNameUser name is in a format that is not suitable for the request. Currently, user names are decoded using kCFStringEncodingISOLatin1.
Available in Mac OS X v10.4 and later.
Declared in CFHTTPAuthentication.h
kCFStreamErrorHTTPAuthenticationBadPasswordPassword is in a format that is not suitable for the request. Currently, passwords are decoded using kCFStringEncodingISOLatin1.
Available in Mac OS X v10.4 and later.
Declared in CFHTTPAuthentication.h
CFNetwork/CFHTTPAuthentication.hConstants for keys in the dictionary passed to CFHTTPMessageApplyCredentialDictionary.
const CFStringRef kCFHTTPAuthenticationUserName; const CFStringRef kCFHTTPAuthenticationPassword; const CFStringRef kCFHTTPAuthenticationAccountDomain;
kCFHTTPAuthenticationUserNameUsername to use for authentication.
kCFHTTPAuthenticationPasswordPassword to use for authentication.
kCFHTTPAuthenticationAccountDomainAccount domain to use for authentication.
CFNetwork/CFHTTPAuthentication.h
Last updated: 2007-05-15