comparison src/org/eclipse/jetty/server/Request.java @ 815:07c82fabc46b

remove Authentication
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 09 Sep 2016 14:27:05 -0600
parents f8f7cb485c25
children 8e9db0bbf4f9
comparison
equal deleted inserted replaced
814:95cbe23a96fb 815:07c82fabc46b
178 return AbstractHttpConnection.getCurrentConnection().getRequest(); 178 return AbstractHttpConnection.getCurrentConnection().getRequest();
179 } 179 }
180 protected final AsyncContinuation _async = new AsyncContinuation(); 180 protected final AsyncContinuation _async = new AsyncContinuation();
181 private boolean _asyncSupported = true; 181 private boolean _asyncSupported = true;
182 private volatile Attributes _attributes; 182 private volatile Attributes _attributes;
183 private Authentication _authentication;
184 private MultiMap<String> _baseParameters; 183 private MultiMap<String> _baseParameters;
185 private String _characterEncoding; 184 private String _characterEncoding;
186 protected AbstractHttpConnection _connection; 185 protected AbstractHttpConnection _connection;
187 private ContextHandler.Context _context; 186 private ContextHandler.Context _context;
188 private boolean _newContext; 187 private boolean _newContext;
455 _attributes = new AttributesMap(); 454 _attributes = new AttributesMap();
456 return _attributes; 455 return _attributes;
457 } 456 }
458 457
459 /* ------------------------------------------------------------ */ 458 /* ------------------------------------------------------------ */
460 /**
461 * Get the authentication.
462 *
463 * @return the authentication
464 */
465 public Authentication getAuthentication()
466 {
467 return _authentication;
468 }
469
470 /* ------------------------------------------------------------ */
471 /* 459 /*
472 * @see javax.servlet.http.HttpServletRequest#getAuthType() 460 * @see javax.servlet.http.HttpServletRequest#getAuthType()
473 */ 461 */
474 public String getAuthType() 462 public String getAuthType()
475 { 463 {
476 if (_authentication instanceof Authentication.Deferred)
477 setAuthentication(((Authentication.Deferred)_authentication).authenticate(this));
478
479 if (_authentication instanceof Authentication.User)
480 return ((Authentication.User)_authentication).getAuthMethod();
481 return null; 464 return null;
482 } 465 }
483 466
484 /* ------------------------------------------------------------ */ 467 /* ------------------------------------------------------------ */
485 /* 468 /*
1275 /* 1258 /*
1276 * @see javax.servlet.http.HttpServletRequest#getUserPrincipal() 1259 * @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
1277 */ 1260 */
1278 public Principal getUserPrincipal() 1261 public Principal getUserPrincipal()
1279 { 1262 {
1280 if (_authentication instanceof Authentication.Deferred)
1281 setAuthentication(((Authentication.Deferred)_authentication).authenticate(this));
1282
1283 return null; 1263 return null;
1284 } 1264 }
1285 1265
1286 /* ------------------------------------------------------------ */ 1266 /* ------------------------------------------------------------ */
1287 /** 1267 /**
1361 /* 1341 /*
1362 * @see javax.servlet.http.HttpServletRequest#isUserInRole(java.lang.String) 1342 * @see javax.servlet.http.HttpServletRequest#isUserInRole(java.lang.String)
1363 */ 1343 */
1364 public boolean isUserInRole(String role) 1344 public boolean isUserInRole(String role)
1365 { 1345 {
1366 if (_authentication instanceof Authentication.Deferred)
1367 setAuthentication(((Authentication.Deferred)_authentication).authenticate(this));
1368 return false; 1346 return false;
1369 } 1347 }
1370 1348
1371 /* ------------------------------------------------------------ */ 1349 /* ------------------------------------------------------------ */
1372 public HttpSession recoverNewSession(Object key) 1350 public HttpSession recoverNewSession(Object key)
1390 LOG.ignore(e); 1368 LOG.ignore(e);
1391 _reader = null; 1369 _reader = null;
1392 } 1370 }
1393 } 1371 }
1394 1372
1395 setAuthentication(Authentication.NOT_CHECKED);
1396 _async.recycle(); 1373 _async.recycle();
1397 _asyncSupported = true; 1374 _asyncSupported = true;
1398 _handled = false; 1375 _handled = false;
1399 if (_context != null) 1376 if (_context != null)
1400 throw new IllegalStateException("Request in context!"); 1377 throw new IllegalStateException("Request in context!");
1562 } 1539 }
1563 1540
1564 /* ------------------------------------------------------------ */ 1541 /* ------------------------------------------------------------ */
1565 1542
1566 /* ------------------------------------------------------------ */ 1543 /* ------------------------------------------------------------ */
1567 /**
1568 * Set the authentication.
1569 *
1570 * @param authentication
1571 * the authentication to set
1572 */
1573 public void setAuthentication(Authentication authentication)
1574 {
1575 _authentication = authentication;
1576 }
1577
1578 /* ------------------------------------------------------------ */
1579 /* 1544 /*
1580 * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String) 1545 * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String)
1581 */ 1546 */
1582 public void setCharacterEncoding(String encoding) throws UnsupportedEncodingException 1547 public void setCharacterEncoding(String encoding) throws UnsupportedEncodingException
1583 { 1548 {
1873 } 1838 }
1874 1839
1875 /* ------------------------------------------------------------ */ 1840 /* ------------------------------------------------------------ */
1876 public boolean authenticate(HttpServletResponse response) throws IOException, ServletException 1841 public boolean authenticate(HttpServletResponse response) throws IOException, ServletException
1877 { 1842 {
1878 if (_authentication instanceof Authentication.Deferred) 1843 throw new UnsupportedOperationException();
1879 {
1880 setAuthentication(((Authentication.Deferred)_authentication).authenticate(this,response));
1881 return !(_authentication instanceof Authentication.ResponseSent);
1882 }
1883 response.sendError(HttpStatus.UNAUTHORIZED_401);
1884 return false;
1885 } 1844 }
1886 1845
1887 /* ------------------------------------------------------------ */ 1846 /* ------------------------------------------------------------ */
1888 public Part getPart(String name) throws IOException, ServletException 1847 public Part getPart(String name) throws IOException, ServletException
1889 { 1848 {
1947 } 1906 }
1948 1907
1949 /* ------------------------------------------------------------ */ 1908 /* ------------------------------------------------------------ */
1950 public void login(String username, String password) throws ServletException 1909 public void login(String username, String password) throws ServletException
1951 { 1910 {
1952 if (_authentication instanceof Authentication.Deferred) 1911 throw new UnsupportedOperationException();
1953 {
1954 _authentication=((Authentication.Deferred)_authentication).login(username,password,this);
1955 if (_authentication == null)
1956 throw new ServletException();
1957 }
1958 else
1959 {
1960 throw new ServletException("Authenticated as "+_authentication);
1961 }
1962 } 1912 }
1963 1913
1964 /* ------------------------------------------------------------ */ 1914 /* ------------------------------------------------------------ */
1965 public void logout() throws ServletException 1915 public void logout() throws ServletException
1966 { 1916 {
1967 if (_authentication instanceof Authentication.User) 1917 throw new UnsupportedOperationException();
1968 ((Authentication.User)_authentication).logout();
1969 _authentication=Authentication.UNAUTHENTICATED;
1970 } 1918 }
1971 1919
1972 /* ------------------------------------------------------------ */ 1920 /* ------------------------------------------------------------ */
1973 /** 1921 /**
1974 * Merge in a new query string. The query string is merged with the existing parameters and {@link #setParameters(MultiMap)} and 1922 * Merge in a new query string. The query string is merged with the existing parameters and {@link #setParameters(MultiMap)} and