From 3afaaeb320fc25a0dd9ac1d2eb9d22576ac47f3a Mon Sep 17 00:00:00 2001 From: Alexander Dodatko Date: Mon, 30 Jul 2018 12:20:50 +0300 Subject: [PATCH] [#6] using NSSet for auth scheme support check --- .../ViewController.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/JiveAuthenticatingHTTPProtocolDemo/JiveAuthenticatingHTTPProtocolDemo/ViewController.m b/JiveAuthenticatingHTTPProtocolDemo/JiveAuthenticatingHTTPProtocolDemo/ViewController.m index b1805ec..0b4b91a 100644 --- a/JiveAuthenticatingHTTPProtocolDemo/JiveAuthenticatingHTTPProtocolDemo/ViewController.m +++ b/JiveAuthenticatingHTTPProtocolDemo/JiveAuthenticatingHTTPProtocolDemo/ViewController.m @@ -36,7 +36,19 @@ - (void)viewDidLoad { #pragma mark - JAHPAuthenticatingHTTPProtocolDelegate - (BOOL)authenticatingHTTPProtocol:(JAHPAuthenticatingHTTPProtocol *)authenticatingHTTPProtocol canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { - BOOL canAuthenticate = [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic]; + + NSArray* interceptedAuthMethods = + @[ + NSURLAuthenticationMethodHTTPBasic + , NSURLAuthenticationMethodHTTPDigest + , NSURLAuthenticationMethodNTLM + ]; + + NSSet* interceptedAuthMethodsSet = [NSSet setWithArray: interceptedAuthMethods]; + + BOOL canAuthenticate = + [interceptedAuthMethodsSet containsObject: protectionSpace.authenticationMethod]; + return canAuthenticate; }