comparison src/luan/modules/http/AuthenticationHandler.java @ 808:b3176fd168bf

replace use of jetty.util.B64Code with java.util.Base64
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 08 Sep 2016 16:13:27 -0600
parents e2a446c5c7c4
children 32d4b569567c
comparison
equal deleted inserted replaced
807:947b11aa3157 808:b3176fd168bf
1 package luan.modules.http; 1 package luan.modules.http;
2 2
3 import java.io.IOException; 3 import java.io.IOException;
4 import java.util.Base64;
4 import javax.servlet.http.HttpServletRequest; 5 import javax.servlet.http.HttpServletRequest;
5 import javax.servlet.http.HttpServletResponse; 6 import javax.servlet.http.HttpServletResponse;
6 import org.eclipse.jetty.server.Request; 7 import org.eclipse.jetty.server.Request;
7 import org.eclipse.jetty.server.handler.AbstractHandler; 8 import org.eclipse.jetty.server.handler.AbstractHandler;
8 import org.eclipse.jetty.util.B64Code;
9 9
10 10
11 public class AuthenticationHandler extends AbstractHandler { 11 public class AuthenticationHandler extends AbstractHandler {
12 private final String path; 12 private final String path;
13 private String password = "password"; 13 private String password = "password";
40 String[] a = auth.split(" +"); 40 String[] a = auth.split(" +");
41 if( a.length != 2 ) 41 if( a.length != 2 )
42 throw new RuntimeException("auth = "+auth); 42 throw new RuntimeException("auth = "+auth);
43 if( !a[0].equals("Basic") ) 43 if( !a[0].equals("Basic") )
44 throw new RuntimeException("auth = "+auth); 44 throw new RuntimeException("auth = "+auth);
45 auth = new String(B64Code.decode(a[1])); 45 auth = new String(Base64.getDecoder().decode(a[1]));
46 a = auth.split(":"); 46 a = auth.split(":");
47 if( a.length != 2 ) 47 if( a.length != 2 )
48 throw new RuntimeException("auth = "+auth); 48 throw new RuntimeException("auth = "+auth);
49 return a[1]; 49 return a[1];
50 } 50 }