changeset 1318:35a6a195819f

in authorization rename user to username
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 Feb 2019 22:17:50 -0700
parents c286c1e36b81
children f7355714742f
files conv.txt src/luan/modules/url/LuanUrl.java
diffstat 2 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
diff -r c286c1e36b81 -r 35a6a195819f conv.txt
--- a/conv.txt	Fri Feb 01 03:46:56 2019 -0700
+++ b/conv.txt	Sun Feb 03 22:17:50 2019 -0700
@@ -1,3 +1,4 @@
+authorization user
 Hosting.domain
 
 Thread.fork
diff -r c286c1e36b81 -r 35a6a195819f src/luan/modules/url/LuanUrl.java
--- a/src/luan/modules/url/LuanUrl.java	Fri Feb 01 03:46:56 2019 -0700
+++ b/src/luan/modules/url/LuanUrl.java	Sun Feb 03 22:17:50 2019 -0700
@@ -37,7 +37,7 @@
 	private String content = "";
 	private MultipartClient multipart = null;
 	private int timeout = 0;
-	private String authUser = null;
+	private String authUsername = null;
 	private String authPassword = null;
 
 	public LuanUrl(URL url,LuanTable options) throws LuanException {
@@ -75,8 +75,8 @@
 			if( auth != null ) {
 				if( headers!=null && headers.containsKey("authorization") )
 					throw new LuanException( "can't define authorization with header 'authorization' defined" );
-				String user = getString(auth,"user");
-				if( user==null )  user = "";
+				String username = getString(auth,"username");
+				if( username==null )  username = "";
 				String password = getString(auth,"password");
 				if( password==null )  password = "";
 				String type = getString(auth,"type");
@@ -85,10 +85,10 @@
 				if( type != null ) {
 					if( !type.toLowerCase().equals("basic") )
 						throw new LuanException( "authorization type can only be 'basic' or nil" );
-					String val = basicAuth(user,password);
+					String val = basicAuth(username,password);
 					headers.put("authorization",val);
 				} else {
-					authUser = user;
+					authUsername = username;
 					authPassword = password;
 				}
 			}
@@ -279,13 +279,13 @@
 			throw e;
 		} catch(IOException e) {
 			int responseCode = httpCon.getResponseCode();
-			if( responseCode == 401 && authUser != null && authorization==null ) {
+			if( responseCode == 401 && authUsername != null && authorization==null ) {
 				String authStr = httpCon.getHeaderField("www-authenticate");
 				//System.out.println("auth = "+authStr);
 				try {
 					WwwAuthenticate auth = new WwwAuthenticate(authStr);
 					if( auth.type.equals("Basic") ) {
-						String val = basicAuth(authUser,authPassword);
+						String val = basicAuth(authUsername,authPassword);
 						throw new AuthException(val);
 					} else if( auth.type.equals("Digest") ) {
 						String realm = auth.options.get("realm");
@@ -299,7 +299,7 @@
 						String nonce = auth.options.get("nonce");
 						if(nonce==null) throw new RuntimeException("missing nonce");
 						String uri = fullPath(url);
-						String a1 = authUser + ':' + realm + ':' + authPassword;
+						String a1 = authUsername + ':' + realm + ':' + authPassword;
 						String a2 = "" + method + ':' + uri;
 						String nc = "00000001";
 						String cnonce = "7761faf2daa45b3b";  // who cares?
@@ -310,7 +310,7 @@
 						response += ':' + md5(a2);
 						response = md5(response);
 						String val = "Digest";
-						val += " username=\"" + authUser + "\"";
+						val += " username=\"" + authUsername + "\"";
 						val += ", realm=\"" + realm + "\"";
 						val += ", uri=\"" + uri + "\"";
 						val += ", nonce=\"" + nonce + "\"";
@@ -351,8 +351,8 @@
 		return url.toString();
 	}
 
-	private static String basicAuth(String user,String password) {
-		String s = user + ':' + password;
+	private static String basicAuth(String username,String password) {
+		String s = username + ':' + password;
 		return "Basic " + Base64.getEncoder().encodeToString(s.getBytes());
 	}