Connecting to TFS from iPhone
I'm building this iPhone application to connect to a secured TFS server (one that requires authentication before letting you access its web services). When I access this server in a browser, the first thing it will do is ask me for credentials (username/password) and then connect me to the TFS server if those credentials are correct开发者_如何转开发.
I am using web services, as I don't think there is any other way to use TFS functionality for an outside platform...without changing stuff on the TFS host machine. So my questions are:
- Are there any web services that can be accessed to log into the TFS server?
- This authentication mechanism seems to be something common among multiple websites (I have seen it in other websites). Is there a way to replicate that authentication mechanism by sending an HTTP request?
- Is there a way to replicate this authentication procedure in any way?
Use NSURLConnection to connect to the web server. Implement the following delegate method:
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
After asking the user for credentials, or reading them from saved settings or whatever, call the challenge sender with the credentials:
- (void)useCredential:(NSURLCredential *)credential forAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
When you create an NSURLCredential you can set the persistence. If you create a persistent credential, then it should be checked automatically in future attempts to connect to the same server. That is the proposedCredential of an authentication challenge.
精彩评论