Desidero che la mia applicazione si autentichi contro l'appliance passando il nome utente e la password su https.Autenticazione https IOS
Ho guardato alcuni esempi e fondamentalmente costruire il seguente:
-(void)authentication
{
//setting the string of the url taking from appliance IP.
NSString *urlString =[NSString
stringWithFormat:
@"http://%@",appliance_IP.text];
//define the url with the string
NSURL *url = [NSURL URLWithString:urlString];
//creating request
NSURLRequest *request = [NSURLRequest requestWithURL:url];
//setting credential taking from the username and password field
NSURLCredential *credential = [NSURLCredential credentialWithUser:username.text password:password.text persistence:NSURLCredentialPersistenceForSession];
NSURLProtectionSpace *protectionSpace=
[[NSURLProtectionSpace alloc]initWithHost:urlString port:443 protocol:@"https" realm:nil authenticationMethod:nil ];
[[NSURLCredentialStorage sharedCredentialStorage] setDefaultCredential:credential forProtectionSpace:protectionSpace];
[ NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL];
}
come io uso esempi che ho preso ho bisogno di un po 'di comprensione, NSURLConnection nell'esempio di cui sopra non contiene il nome utente e la password come faccio aggiungilo? quindi la richiesta conterrà anche username e password o forse è meglio passare tali informazioni. Attualmente la richiesta contiene solo la stringa url.
Grazie ER