diff src/luan/modules/url/LuanUrl.java @ 1575:0160650180bc

better http authentication
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 27 Jan 2021 15:31:26 -0700
parents 3ebf9781707c
children f7e2df85fc0a
line wrap: on
line diff
--- a/src/luan/modules/url/LuanUrl.java	Sun Dec 20 13:17:27 2020 -0700
+++ b/src/luan/modules/url/LuanUrl.java	Wed Jan 27 15:31:26 2021 -0700
@@ -280,8 +280,13 @@
 			if( responseCode == 401 && authUsername != null && authorization==null ) {
 				String authStr = httpCon.getHeaderField("www-authenticate");
 				//System.out.println("auth = "+authStr);
+				List<WwwAuthenticate> auths;
 				try {
-					WwwAuthenticate auth = new WwwAuthenticate(authStr);
+					auths = WwwAuthenticate.parse(authStr);
+				} catch(ParseException pe) {
+					throw new LuanException(pe);
+				}
+				for( WwwAuthenticate auth : auths ) {
 					if( auth.type.equals("Basic") ) {
 						String val = basicAuth(authUsername,authPassword);
 						throw new AuthException(val);
@@ -320,11 +325,9 @@
 						}
 						//System.out.println("val = "+val);
 						throw new AuthException(val);
-					} else
-						throw new RuntimeException(auth.type);
-				} catch(ParseException pe) {
-					throw new LuanException(pe);
+					}
 				}
+				throw new RuntimeException(authStr);
 			}
 			String msg = "" + responseCode;
 			String responseMessage = httpCon.getResponseMessage();