Merge pull request #3797 from eclipse/jetty-10.0.x-remove-deprecated

Remove deprecated in Jetty 10.0.x
This commit is contained in:
Joakim Erdfelt 2019-06-21 14:27:34 -05:00 committed by GitHub
commit 479eb77f6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 26 additions and 1018 deletions

View File

@ -22,6 +22,7 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
@ -43,7 +44,7 @@ public class WebSocketServer
@OnWebSocketMessage
public void onMessage( Session session, String message )
{
session.getRemote().sendStringByFuture(message);
session.getRemote().sendString(message, WriteCallback.NOOP);
}
}

View File

@ -19,7 +19,6 @@
package org.eclipse.jetty.osgi.test;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.api.Session;
@ -52,7 +51,6 @@ public class SimpleEchoSocket
@OnWebSocketClose
public void onClose(int statusCode, String reason)
{
//System.out.printf("Connection closed: %d - %s%n",statusCode,reason);
this.session = null;
this.closeLatch.countDown(); // trigger latch
}
@ -60,17 +58,10 @@ public class SimpleEchoSocket
@OnWebSocketConnect
public void onConnect(Session session)
{
//System.out.printf("Got connect: %s%n",session);
this.session = session;
try
{
Future<Void> fut;
//System.err.println("Sending Foo!");
fut = session.getRemote().sendStringByFuture("Foo");
fut.get(2,TimeUnit.SECONDS); // wait for send to complete.
//System.err.println("Foo complete");
session.getRemote().sendString("Foo");
session.close(StatusCode.NORMAL,"I'm done");
}
catch (Throwable t)
@ -82,6 +73,5 @@ public class SimpleEchoSocket
@OnWebSocketMessage
public void onMessage(String msg)
{
//System.out.printf("Got msg: %s%n",msg);
}
}

View File

@ -39,10 +39,4 @@ public class UserAuthentication extends AbstractUserAuthentication
return "{User,"+getAuthMethod()+","+_userIdentity+"}";
}
@Override
@Deprecated
public void logout()
{
}
}

View File

@ -22,7 +22,6 @@ package org.eclipse.jetty.security.authentication;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionBindingEvent;
@ -98,13 +97,6 @@ public class SessionAuthentication extends AbstractUserAuthentication
LOG.debug("Deserialized and relogged in {}",this);
}
@Override
@Deprecated
public void logout()
{
}
@Override
public String toString()
{

View File

@ -50,8 +50,6 @@ public interface Authentication
String getAuthMethod();
UserIdentity getUserIdentity();
boolean isUserInRole(UserIdentity.Scope scope,String role);
@Deprecated
void logout();
}
/* ------------------------------------------------------------ */

View File

@ -24,7 +24,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -59,9 +58,6 @@ public class ContextHandlerCollection extends HandlerCollection
private static final Logger LOG = Log.getLogger(ContextHandlerCollection.class);
private final SerializedExecutor _serializedExecutor = new SerializedExecutor();
@Deprecated
private Class<? extends ContextHandler> _contextClass = ContextHandler.class;
/* ------------------------------------------------------------ */
public ContextHandlerCollection()
{
@ -239,33 +235,6 @@ public class ContextHandlerCollection extends HandlerCollection
}
}
/* ------------------------------------------------------------ */
/**
* Adds a context handler.
*
* @param contextPath The context path to add
* @param resourceBase the base (root) Resource
* @return the ContextHandler just added
* @deprecated Unused convenience method no longer supported.
*/
@Deprecated
public ContextHandler addContext(String contextPath,String resourceBase)
{
try
{
ContextHandler context = _contextClass.getDeclaredConstructor().newInstance();
context.setContextPath(contextPath);
context.setResourceBase(resourceBase);
addHandler(context);
return context;
}
catch (Exception e)
{
LOG.debug(e);
throw new Error(e);
}
}
/* ------------------------------------------------------------ */
/**
* Thread safe deploy of a Handler.
@ -333,30 +302,6 @@ public class ContextHandlerCollection extends HandlerCollection
});
}
/* ------------------------------------------------------------ */
/**
* @return The class to use to add new Contexts
* @deprecated Unused convenience mechanism not used.
*/
@Deprecated
public Class<?> getContextClass()
{
return _contextClass;
}
/* ------------------------------------------------------------ */
/**
* @param contextClass The class to use to add new Contexts
* @deprecated Unused convenience mechanism not used.
*/
@Deprecated
public void setContextClass(Class<? extends ContextHandler> contextClass)
{
if (contextClass ==null || !(ContextHandler.class.isAssignableFrom(contextClass)))
throw new IllegalArgumentException();
_contextClass = contextClass;
}
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */

View File

@ -1,571 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
import java.util.Base64;
/** Fast B64 Encoder/Decoder as described in RFC 1421.
* <p>Does not insert or interpret whitespace as described in RFC
* 1521. If you require this you must pre/post process your data.
* <p> Note that in a web context the usual case is to not want
* linebreaks or other white space in the encoded output.
* @deprecated use {@link java.util.Base64} instead
*/
@Deprecated
public class B64Code
{
private static final char __pad='=';
private static final char[] __rfc1421alphabet=
{
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
};
private static final byte[] __rfc1421nibbles;
static
{
__rfc1421nibbles=new byte[256];
for (int i=0;i<256;i++)
__rfc1421nibbles[i]=-1;
for (byte b=0;b<64;b++)
__rfc1421nibbles[(byte)__rfc1421alphabet[b]]=b;
__rfc1421nibbles[(byte)__pad]=0;
}
private static final char[] __rfc4648urlAlphabet=
{
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','-','_'
};
private static final byte[] __rfc4648urlNibbles;
static
{
__rfc4648urlNibbles=new byte[256];
for (int i=0;i<256;i++)
__rfc4648urlNibbles[i]=-1;
for (byte b=0;b<64;b++)
__rfc4648urlNibbles[(byte)__rfc4648urlAlphabet[b]]=b;
__rfc4648urlNibbles[(byte)__pad]=0;
}
private B64Code()
{
}
/**
* Base 64 encode as described in RFC 1421.
* <p>Does not insert whitespace as described in RFC 1521.
* @param s String to encode.
* @return String containing the encoded form of the input.
* @deprecated use {@link Base64.Encoder#encodeToString(byte[])}} instead.
*/
public static String encode(String s)
{
// FIXME: no Jetty mainline code uses this anymore
return encode(s, (Charset)null);
}
/**
* Base 64 encode as described in RFC 1421.
* <p>Does not insert whitespace as described in RFC 1521.
* @param s String to encode.
* @param charEncoding String representing the name of
* the character encoding of the provided input String.
* @return String containing the encoded form of the input.
*/
public static String encode(String s,String charEncoding)
{
// FIXME: no Jetty mainline code uses this anymore
byte[] bytes;
if (charEncoding==null)
bytes=s.getBytes(StandardCharsets.ISO_8859_1);
else
bytes=s.getBytes(Charset.forName(charEncoding));
return new String(encode(bytes));
}
/**
* Base 64 encode as described in RFC 1421.
* <p>Does not insert whitespace as described in RFC 1521.
* @param s String to encode.
* @param charEncoding The character encoding of the provided input String.
* @return String containing the encoded form of the input.
*/
public static String encode(String s, Charset charEncoding)
{
// FIXME: no Jetty mainline code uses this anymore
byte[] bytes=s.getBytes(charEncoding==null ? StandardCharsets.ISO_8859_1 : charEncoding);
return new String(encode(bytes));
}
/**
* Fast Base 64 encode as described in RFC 1421.
* <p>Does not insert whitespace as described in RFC 1521.
* <p> Avoids creating extra copies of the input/output.
* @param b byte array to encode.
* @return char array containing the encoded form of the input.
*/
public static char[] encode(byte[] b)
{
// FIXME: no Jetty mainline code uses this anymore
if (b==null)
return null;
int bLen=b.length;
int cLen=((bLen+2)/3)*4;
char c[]=new char[cLen];
int ci=0;
int bi=0;
byte b0, b1, b2;
int stop=(bLen/3)*3;
while (bi<stop)
{
b0=b[bi++];
b1=b[bi++];
b2=b[bi++];
c[ci++]=__rfc1421alphabet[(b0>>>2)&0x3f];
c[ci++]=__rfc1421alphabet[(b0<<4)&0x3f|(b1>>>4)&0x0f];
c[ci++]=__rfc1421alphabet[(b1<<2)&0x3f|(b2>>>6)&0x03];
c[ci++]=__rfc1421alphabet[b2&0x3f];
}
if (bLen!=bi)
{
switch (bLen%3)
{
case 2:
b0=b[bi++];
b1=b[bi++];
c[ci++]=__rfc1421alphabet[(b0>>>2)&0x3f];
c[ci++]=__rfc1421alphabet[(b0<<4)&0x3f|(b1>>>4)&0x0f];
c[ci++]=__rfc1421alphabet[(b1<<2)&0x3f];
c[ci++]=__pad;
break;
case 1:
b0=b[bi++];
c[ci++]=__rfc1421alphabet[(b0>>>2)&0x3f];
c[ci++]=__rfc1421alphabet[(b0<<4)&0x3f];
c[ci++]=__pad;
c[ci++]=__pad;
break;
default:
break;
}
}
return c;
}
/**
* Fast Base 64 encode as described in RFC 1421 and RFC2045
* <p>Does not insert whitespace as described in RFC 1521, unless rfc2045 is passed as true.
* <p> Avoids creating extra copies of the input/output.
* @param b byte array to encode.
* @param rfc2045 If true, break lines at 76 characters with CRLF
* @return char array containing the encoded form of the input.
*/
public static char[] encode(byte[] b, boolean rfc2045)
{
// FIXME: no Jetty mainline code uses this anymore
if (b==null)
return null;
if (!rfc2045)
return encode(b);
int bLen=b.length;
int cLen=((bLen+2)/3)*4;
cLen+=2+2*(cLen/76);
char c[]=new char[cLen];
int ci=0;
int bi=0;
byte b0, b1, b2;
int stop=(bLen/3)*3;
int l=0;
while (bi<stop)
{
b0=b[bi++];
b1=b[bi++];
b2=b[bi++];
c[ci++]=__rfc1421alphabet[(b0>>>2)&0x3f];
c[ci++]=__rfc1421alphabet[(b0<<4)&0x3f|(b1>>>4)&0x0f];
c[ci++]=__rfc1421alphabet[(b1<<2)&0x3f|(b2>>>6)&0x03];
c[ci++]=__rfc1421alphabet[b2&0x3f];
l+=4;
if (l%76==0)
{
c[ci++]=13;
c[ci++]=10;
}
}
if (bLen!=bi)
{
switch (bLen%3)
{
case 2:
b0=b[bi++];
b1=b[bi++];
c[ci++]=__rfc1421alphabet[(b0>>>2)&0x3f];
c[ci++]=__rfc1421alphabet[(b0<<4)&0x3f|(b1>>>4)&0x0f];
c[ci++]=__rfc1421alphabet[(b1<<2)&0x3f];
c[ci++]=__pad;
break;
case 1:
b0=b[bi++];
c[ci++]=__rfc1421alphabet[(b0>>>2)&0x3f];
c[ci++]=__rfc1421alphabet[(b0<<4)&0x3f];
c[ci++]=__pad;
c[ci++]=__pad;
break;
default:
break;
}
}
c[ci++]=13;
c[ci++]=10;
return c;
}
/**
* Base 64 decode as described in RFC 2045.
* <p>Unlike {@link #decode(char[])}, extra whitespace is ignored.
* @param encoded String to decode.
* @param charEncoding String representing the character encoding
* used to map the decoded bytes into a String. If null
* the platforms default charset is used.
* @return String decoded byte array.
* @throws UnsupportedCharsetException if the encoding is not supported
* @throws IllegalArgumentException if the input is not a valid
* B64 encoding.
*/
@SuppressWarnings("DefaultCharset")
public static String decode(String encoded,String charEncoding)
{
// FIXME: no Jetty mainline code uses this anymore
byte[] decoded=decode(encoded);
if (charEncoding==null)
return new String(decoded);
return new String(decoded,Charset.forName(charEncoding));
}
/**
* Base 64 decode as described in RFC 2045.
* <p>Unlike {@link #decode(char[])}, extra whitespace is ignored.
* @param encoded String to decode.
* @param charEncoding Character encoding
* used to map the decoded bytes into a String. If null
* the platforms default charset is used.
* @return String decoded byte array.
* @throws IllegalArgumentException if the input is not a valid
* B64 encoding.
*/
@SuppressWarnings("DefaultCharset")
public static String decode(String encoded, Charset charEncoding)
{
// FIXME: no Jetty mainline code uses this anymore
byte[] decoded=decode(encoded);
if (charEncoding==null)
return new String(decoded);
return new String(decoded, charEncoding);
}
/**
* Fast Base 64 decode as described in RFC 1421.
*
* <p>Unlike other decode methods, this does not attempt to
* cope with extra whitespace as described in RFC 1521/2045.
* <p> Avoids creating extra copies of the input/output.
* <p> Note this code has been flattened for performance.
* @param b char array to decode.
* @return byte array containing the decoded form of the input.
* @throws IllegalArgumentException if the input is not a valid
* B64 encoding.
*/
public static byte[] decode(char[] b)
{
// FIXME: no Jetty mainline code uses this anymore
if (b==null)
return null;
int bLen=b.length;
if (bLen%4!=0)
throw new IllegalArgumentException("Input block size is not 4");
int li=bLen-1;
while (li>=0 && b[li]==(byte)__pad)
li--;
if (li<0)
return new byte[0];
// Create result array of exact required size.
int rLen=((li+1)*3)/4;
byte r[]=new byte[rLen];
int ri=0;
int bi=0;
int stop=(rLen/3)*3;
byte b0,b1,b2,b3;
try
{
while (ri<stop)
{
b0=__rfc1421nibbles[b[bi++]];
b1=__rfc1421nibbles[b[bi++]];
b2=__rfc1421nibbles[b[bi++]];
b3=__rfc1421nibbles[b[bi++]];
if (b0<0 || b1<0 || b2<0 || b3<0)
throw new IllegalArgumentException("Not B64 encoded");
r[ri++]=(byte)(b0<<2|b1>>>4);
r[ri++]=(byte)(b1<<4|b2>>>2);
r[ri++]=(byte)(b2<<6|b3);
}
if (rLen!=ri)
{
switch (rLen%3)
{
case 2:
b0=__rfc1421nibbles[b[bi++]];
b1=__rfc1421nibbles[b[bi++]];
b2=__rfc1421nibbles[b[bi++]];
if (b0<0 || b1<0 || b2<0)
throw new IllegalArgumentException("Not B64 encoded");
r[ri++]=(byte)(b0<<2|b1>>>4);
r[ri++]=(byte)(b1<<4|b2>>>2);
break;
case 1:
b0=__rfc1421nibbles[b[bi++]];
b1=__rfc1421nibbles[b[bi++]];
if (b0<0 || b1<0)
throw new IllegalArgumentException("Not B64 encoded");
r[ri++]=(byte)(b0<<2|b1>>>4);
break;
default:
break;
}
}
}
catch (IndexOutOfBoundsException e)
{
throw new IllegalArgumentException("char "+bi
+" was not B64 encoded");
}
return r;
}
/**
* Base 64 decode as described in RFC 2045.
* <p>Unlike {@link #decode(char[])}, extra whitespace is ignored.
* @param encoded String to decode.
* @return byte array containing the decoded form of the input.
* @throws IllegalArgumentException if the input is not a valid
* B64 encoding.
*/
public static byte[] decode(String encoded)
{
// FIXME: no Jetty mainline code uses this anymore
if (encoded==null)
return null;
ByteArrayOutputStream bout = new ByteArrayOutputStream(4*encoded.length()/3);
decode(encoded, bout);
return bout.toByteArray();
}
/* ------------------------------------------------------------ */
/**
* Base 64 decode as described in RFC 2045.
* <p>Unlike {@link #decode(char[])}, extra whitespace is ignored.
* @param encoded String to decode.
* @param bout stream for decoded bytes
* @throws IllegalArgumentException if the input is not a valid
* B64 encoding.
*/
static public void decode(String encoded, ByteArrayOutputStream bout)
{
// FIXME: no Jetty mainline code uses this anymore
if (encoded==null)
return;
if (bout == null)
throw new IllegalArgumentException("No outputstream for decoded bytes");
int ci=0;
byte nibbles[] = new byte[4];
int s=0;
while (ci<encoded.length())
{
char c=encoded.charAt(ci++);
if (c==__pad)
break;
if (Character.isWhitespace(c))
continue;
byte nibble=__rfc1421nibbles[c];
if (nibble<0)
throw new IllegalArgumentException("Not B64 encoded");
nibbles[s++]=__rfc1421nibbles[c];
switch(s)
{
case 1:
break;
case 2:
bout.write(nibbles[0]<<2|nibbles[1]>>>4);
break;
case 3:
bout.write(nibbles[1]<<4|nibbles[2]>>>2);
break;
case 4:
bout.write(nibbles[2]<<6|nibbles[3]);
s=0;
break;
}
}
return;
}
/* ------------------------------------------------------------ */
public static byte[] decodeRFC4648URL(String encoded)
{
// FIXME: no Jetty mainline code uses this anymore
if (encoded==null)
return null;
ByteArrayOutputStream bout = new ByteArrayOutputStream(4*encoded.length()/3);
decodeRFC4648URL(encoded, bout);
return bout.toByteArray();
}
/* ------------------------------------------------------------ */
/**
* Base 64 decode as described in RFC 4648 URL.
* <p>Unlike {@link #decode(char[])}, extra whitespace is ignored.
* @param encoded String to decode.
* @param bout stream for decoded bytes
* @throws IllegalArgumentException if the input is not a valid
* B64 encoding.
*/
static public void decodeRFC4648URL (String encoded, ByteArrayOutputStream bout)
{
// FIXME: no Jetty mainline code uses this anymore
if (encoded==null)
return;
if (bout == null)
throw new IllegalArgumentException("No outputstream for decoded bytes");
int ci=0;
byte nibbles[] = new byte[4];
int s=0;
while (ci<encoded.length())
{
char c=encoded.charAt(ci++);
if (c==__pad)
break;
if (Character.isWhitespace(c))
continue;
byte nibble=__rfc4648urlNibbles[c];
if (nibble<0)
throw new IllegalArgumentException("Not B64 encoded");
nibbles[s++]=__rfc4648urlNibbles[c];
switch(s)
{
case 1:
break;
case 2:
bout.write(nibbles[0]<<2|nibbles[1]>>>4);
break;
case 3:
bout.write(nibbles[1]<<4|nibbles[2]>>>2);
break;
case 4:
bout.write(nibbles[2]<<6|nibbles[3]);
s=0;
break;
}
}
return;
}
public static void encode(int value,Appendable buf) throws IOException
{
// FIXME: no Jetty mainline code uses this anymore
buf.append(__rfc1421alphabet[0x3f&((0xFC000000&value)>>26)]);
buf.append(__rfc1421alphabet[0x3f&((0x03F00000&value)>>20)]);
buf.append(__rfc1421alphabet[0x3f&((0x000FC000&value)>>14)]);
buf.append(__rfc1421alphabet[0x3f&((0x00003F00&value)>>8)]);
buf.append(__rfc1421alphabet[0x3f&((0x000000FC&value)>>2)]);
buf.append(__rfc1421alphabet[0x3f&((0x00000003&value)<<4)]);
}
public static void encode(long lvalue,Appendable buf) throws IOException
{
// FIXME: no Jetty mainline code uses this anymore
int value=(int)(0xFFFFFFFC&(lvalue>>32));
buf.append(__rfc1421alphabet[0x3f&((0xFC000000&value)>>26)]);
buf.append(__rfc1421alphabet[0x3f&((0x03F00000&value)>>20)]);
buf.append(__rfc1421alphabet[0x3f&((0x000FC000&value)>>14)]);
buf.append(__rfc1421alphabet[0x3f&((0x00003F00&value)>>8)]);
buf.append(__rfc1421alphabet[0x3f&((0x000000FC&value)>>2)]);
buf.append(__rfc1421alphabet[0x3f&((0x00000003&value)<<4) + (0xf&(int)(lvalue>>28))]);
value=0x0FFFFFFF&(int)lvalue;
buf.append(__rfc1421alphabet[0x3f&((0x0FC00000&value)>>22)]);
buf.append(__rfc1421alphabet[0x3f&((0x003F0000&value)>>16)]);
buf.append(__rfc1421alphabet[0x3f&((0x0000FC00&value)>>10)]);
buf.append(__rfc1421alphabet[0x3f&((0x000003F0&value)>>4)]);
buf.append(__rfc1421alphabet[0x3f&((0x0000000F&value)<<2)]);
}
}

View File

@ -355,16 +355,6 @@ public class StringUtil
return buf.toString();
}
/** Remove single or double quotes.
* @param s the input string
* @return the string with quotes removed
*/
@Deprecated
public static String unquote(String s)
{
return QuotedStringTokenizer.unquote(s);
}
/** Append substring to StringBuilder
* @param buf StringBuilder to append to
* @param s String to append from

View File

@ -32,7 +32,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@ -537,26 +536,7 @@ public class TypeUtil
}
}
@Deprecated
public static Object call(Class<?> oClass, String methodName, Object obj, Object[] arg) throws InvocationTargetException, NoSuchMethodException
{
throw new UnsupportedOperationException();
}
@Deprecated
public static Object construct(Class<?> klass, Object[] arguments) throws InvocationTargetException, NoSuchMethodException
{
throw new UnsupportedOperationException();
}
@Deprecated
public static Object construct(Class<?> klass, Object[] arguments, Map<String, Object> namedArgMap) throws InvocationTargetException, NoSuchMethodException
{
throw new UnsupportedOperationException();
}
/* ------------------------------------------------------------ */
/**
/**
* @param o Object to test for true
* @return True if passed object is not null and is either a Boolean with value true or evaluates to a string that evaluates to true.
*/

View File

@ -495,19 +495,6 @@ public abstract class Resource implements ResourceFactory, Closeable
}
/* ------------------------------------------------------------ */
/** Get the resource list as a HTML directory listing.
* @param base The base URL
* @param parent True if the parent directory should be included
* @return String of HTML
* @throws IOException if unable to get the list of resources as HTML
* @deprecated use {@link #getListHTML(String, boolean, String)} instead and supply raw query string.
*/
@Deprecated
public String getListHTML(String base, boolean parent) throws IOException
{
return getListHTML(base, parent, null);
}
/** Get the resource list as a HTML directory listing.
* @param base The base URL
* @param parent True if the parent directory should be included

View File

@ -789,16 +789,6 @@ public class QueuedThreadPool extends ContainerLifeCycle implements SizedThreadP
return _jobs;
}
/**
* @param queue the job queue
* @deprecated pass the queue to the constructor instead
*/
@Deprecated
public void setQueue(BlockingQueue<Runnable> queue)
{
throw new UnsupportedOperationException("Use constructor injection");
}
/**
* @param id the thread ID to interrupt.
* @return true if the thread was found and interrupted.

View File

@ -1,138 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.util;
import java.util.Base64;
import org.junit.jupiter.api.Test;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
public class B64CodeTest
{
String text = "Man is distinguished, not only by his reason, but by this singular passion " +
"from other animals, which is a lust of the mind, that by a perseverance of delight in " +
"the continued and indefatigable generation of knowledge, exceeds the short vehemence " +
"of any carnal pleasure.";
@Test
public void testEncode_RFC1421()
{
String expected = "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz" +
"IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg" +
"dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu" +
"dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo" +
"ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=";
// Default Encode
String b64 = B64Code.encode(text, ISO_8859_1);
assertThat("B64Code.encode(String)", b64, is(expected));
// Specified RFC Encode
byte[] rawInputBytes = text.getBytes(ISO_8859_1);
char[] chars = B64Code.encode(rawInputBytes,false);
b64 = new String(chars,0,chars.length);
assertThat("B64Code.encode(byte[], false)", b64, is(expected));
// Standard Java Encode
String javaBase64 = Base64.getEncoder().encodeToString(rawInputBytes);
assertThat("Base64.getEncoder().encodeToString((byte[])", javaBase64, is(expected));
}
@Test
public void testEncode_RFC2045()
{
byte[] rawInputBytes = text.getBytes(ISO_8859_1);
// Old Jetty way
char[] chars = B64Code.encode(rawInputBytes,true);
String b64 = new String(chars,0,chars.length);
String expected = "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlz\r\n"+
"IHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2Yg\r\n"+
"dGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu\r\n"+
"dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRo\r\n"+
"ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=\r\n";
assertThat(b64, is(expected));
// Standard Java way
String javaBase64 = Base64.getMimeEncoder().encodeToString(rawInputBytes);
// NOTE: MIME standard for encoding should not include final "\r\n"
assertThat(javaBase64 + "\r\n", is(expected));
}
@Test
public void testInteger() throws Exception
{
byte[] bytes = text.getBytes(ISO_8859_1);
int value = (bytes[0] << 24) +
(bytes[1] << 16) +
(bytes[2] << 8) +
(bytes[3]);
String expected = "TWFuIA";
// Old Jetty way
StringBuilder b = new StringBuilder();
B64Code.encode(value,b);
assertThat("Old Jetty B64Code", b.toString(), is(expected));
// Standard Java technique
byte[] intBytes = new byte[Integer.BYTES];
for (int i = Integer.BYTES - 1; i >= 0; i--)
{
intBytes[i] = (byte) (value & 0xFF);
value >>= 8;
}
assertThat("Standard Java Base64", Base64.getEncoder().withoutPadding().encodeToString(intBytes), is(expected));
}
@Test
public void testLong() throws Exception
{
byte[] bytes = text.getBytes(ISO_8859_1);
long value = ((0xffL & bytes[0]) << 56) +
((0xffL & bytes[1]) << 48) +
((0xffL & bytes[2]) << 40) +
((0xffL & bytes[3]) << 32) +
((0xffL & bytes[4]) << 24) +
((0xffL & bytes[5]) << 16) +
((0xffL & bytes[6]) << 8) +
(0xffL & bytes[7]);
String expected = "TWFuIGlzIGQ";
// Old Jetty way
StringBuilder b = new StringBuilder();
B64Code.encode(value,b);
assertThat("Old Jetty B64Code", b.toString(), is(expected));
// Standard Java technique
byte[] longBytes = new byte[Long.BYTES];
for (int i = Long.BYTES - 1; i >= 0; i--)
{
longBytes[i] = (byte) (value & 0xFF);
value >>= 8;
}
assertThat("Standard Java Base64", Base64.getEncoder().withoutPadding().encodeToString(longBytes), is(expected));
}
}

View File

@ -19,10 +19,8 @@
package org.eclipse.jetty.websocket.api;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.util.concurrent.Future;
public interface RemoteEndpoint
{
@ -45,16 +43,6 @@ public interface RemoteEndpoint
*/
void sendBytes(ByteBuffer data, WriteCallback callback);
/**
* Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted.
* Developers may use the returned Future object to track progress of the transmission.
*
* @param data the data being sent
* @return the Future object representing the send operation.
*/
@Deprecated
Future<Void> sendBytesByFuture(ByteBuffer data);
/**
* Send a binary message in pieces, blocking until all of the message has been transmitted.
* The runtime reads the message in order. Non-final pieces are
@ -79,20 +67,6 @@ public interface RemoteEndpoint
*/
void sendPartialBytes(ByteBuffer fragment, boolean isLast, WriteCallback callback);
/**
* Initiates the asynchronous transmission of a partial binary message. This method returns before the message is
* transmitted.
* The runtime reads the message in order. Non-final pieces are sent with isLast
* set to false. The final piece must be sent with isLast set to true.
* Developers may use the returned Future object to track progress of the transmission.
*
* @param fragment the data being sent
* @param isLast true if this is the last piece of the partial bytes
* @return the Future object representing the send operation.
*/
@Deprecated
Future<Void> sendPartialBytesByFuture(ByteBuffer fragment, boolean isLast);
/**
* Send a text message, blocking until all bytes of the message has been transmitted.
* <p>
@ -113,17 +87,6 @@ public interface RemoteEndpoint
*/
void sendString(String text, WriteCallback callback);
/**
* Initiates the asynchronous transmission of a text message. This method may return before the message is
* transmitted. Developers may use the returned
* Future object to track progress of the transmission.
*
* @param text the text being sent
* @return the Future object representing the send operation.
*/
@Deprecated
Future<Void> sendStringByFuture(String text);
/**
* Send a text message in pieces, blocking until all of the message has been transmitted. The runtime reads the
* message in order. Non-final pieces are sent
@ -148,20 +111,6 @@ public interface RemoteEndpoint
*/
void sendPartialString(String fragment, boolean isLast, WriteCallback callback) throws IOException;
/**
* Initiates the asynchronous transmission of a partial text message.
* This method may return before the message is transmitted.
* The runtime reads the message in order. Non-final pieces are sent with isLast
* set to false. The final piece must be sent with isLast set to true.
* Developers may use the returned Future object to track progress of the transmission.
*
* @param fragment the text being sent
* @param isLast true if this is the last piece of the partial bytes
* @return the Future object representing the send operation.
*/
@Deprecated
Future<Void> sendPartialStringByFuture(String fragment, boolean isLast) throws IOException;
/**
* Send a Ping message containing the given application data to the remote endpoint, blocking until all of the
* message has been transmitted.
@ -181,16 +130,6 @@ public interface RemoteEndpoint
*/
void sendPing(ByteBuffer applicationData, WriteCallback callback);
/**
* Asynchronously send a Ping message containing the given application data to the remote endpoint.
* The corresponding Pong message may be picked up using the MessageHandler.Pong handler.
*
* @param applicationData the data to be carried in the ping request
* @return the Future object representing the send operation.
*/
@Deprecated
Future<Void> sendPingByFuture(ByteBuffer applicationData);
/**
* Allows the developer to send an unsolicited Pong message containing the given application data
* in order to serve as a unidirectional heartbeat for the session, this will block until
@ -210,16 +149,6 @@ public interface RemoteEndpoint
*/
void sendPong(ByteBuffer applicationData, WriteCallback callback);
/**
* Allows the developer to asynchronously send an unsolicited Pong message containing the given application data
* in order to serve as a unidirectional heartbeat for the session.
*
* @param applicationData the application data to be carried in the pong response.
* @return the Future object representing the send operation.
*/
@Deprecated
Future<Void> sendPongByFuture(ByteBuffer applicationData);
/**
* @return the batch mode with which messages are sent.
* @see #flush()
@ -234,15 +163,6 @@ public interface RemoteEndpoint
*/
void setBatchMode(BatchMode mode);
/**
* Get the InetSocketAddress for the established connection.
*
* @return the InetSocketAddress for the established connection. (or null, if there is none)
* @deprecated use {@link #getRemoteAddress()} instead
*/
@Deprecated
InetSocketAddress getInetSocketAddress();
/**
* Get the SocketAddress for the established connection.
*

View File

@ -48,13 +48,6 @@ public @interface WebSocket
*/
int maxBinaryMessageSize() default -1;
/**
* The time in ms (milliseconds) that a websocket may be idle before closing.
* @deprecated use {@link #idleTimeout()} instead
*/
@Deprecated
int maxIdleTime() default -1;
/**
* The time in ms (milliseconds) that a websocket may be idle before closing.
*/

View File

@ -296,8 +296,6 @@ public class JettyWebSocketFrameHandlerFactory extends ContainerLifeCycle
if (max>=0)
metadata.setMaxTextMessageSize(max);
max = anno.idleTimeout();
if (max<0)
max = anno.maxIdleTime();
if (max>=0)
metadata.setIdleTimeout(Duration.ofMillis(max));
metadata.setBatchMode(anno.batchMode());

View File

@ -19,15 +19,12 @@
package org.eclipse.jetty.websocket.common;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.util.Objects;
import java.util.concurrent.Future;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.FutureCallback;
import org.eclipse.jetty.util.SharedBlockingCallback;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.WriteCallback;
@ -101,16 +98,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
isBatch());
}
@Override
public Future<Void> sendBytesByFuture(ByteBuffer data)
{
FutureCallback callback = new FutureCallback();
coreSession.sendFrame(new Frame(OpCode.BINARY).setPayload(data),
callback,
isBatch());
return callback;
}
@Override
public void sendPartialBytes(ByteBuffer fragment, boolean isLast) throws IOException
{
@ -127,14 +114,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
sendPartialBytes(fragment, isLast, Callback.from(callback::writeSuccess, callback::writeFailed));
}
@Override
public Future<Void> sendPartialBytesByFuture(ByteBuffer fragment, boolean isLast)
{
FutureCallback callback = new FutureCallback();
sendPartialBytes(fragment, isLast, callback);
return callback;
}
@Override
public void sendString(String text) throws IOException
{
@ -148,16 +127,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload(text), cb, isBatch());
}
@Override
public Future<Void> sendStringByFuture(String text)
{
FutureCallback callback = new FutureCallback();
coreSession.sendFrame(new Frame(OpCode.TEXT).setPayload(text),
callback,
isBatch());
return callback;
}
@Override
public void sendPartialString(String fragment, boolean isLast) throws IOException
{
@ -169,19 +138,11 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
}
@Override
public void sendPartialString(String fragment, boolean isLast, WriteCallback callback) throws IOException
public void sendPartialString(String fragment, boolean isLast, WriteCallback callback)
{
sendPartialText(fragment, isLast, Callback.from(callback::writeSuccess, callback::writeFailed));
}
@Override
public Future<Void> sendPartialStringByFuture(String fragment, boolean isLast) throws IOException
{
FutureCallback callback = new FutureCallback();
sendPartialText(fragment, isLast, callback);
return callback;
}
@Override
public void sendPing(ByteBuffer applicationData) throws IOException
{
@ -195,14 +156,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
Callback.from(callback::writeSuccess, callback::writeFailed), false);
}
@Override
public Future<Void> sendPingByFuture(ByteBuffer applicationData)
{
FutureCallback callback = new FutureCallback();
coreSession.sendFrame(new Frame(OpCode.PING).setPayload(applicationData), callback, false);
return callback;
}
@Override
public void sendPong(ByteBuffer applicationData) throws IOException
{
@ -216,14 +169,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
Callback.from(callback::writeSuccess, callback::writeFailed), false);
}
@Override
public Future<Void> sendPongByFuture(ByteBuffer applicationData)
{
FutureCallback callback = new FutureCallback();
coreSession.sendFrame(new Frame(OpCode.PONG).setPayload(applicationData), callback, false);
return callback;
}
private void sendPartialBytes(ByteBuffer fragment, boolean isLast, Callback callback)
{
Frame frame;
@ -311,16 +256,6 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket
return BatchMode.ON == batchMode;
}
@Override
public InetSocketAddress getInetSocketAddress()
{
SocketAddress remoteAddress = coreSession.getRemoteAddress();
if (remoteAddress instanceof InetSocketAddress)
return (InetSocketAddress)remoteAddress;
return null;
}
@Override
public SocketAddress getRemoteAddress()
{

View File

@ -54,6 +54,7 @@ import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
import org.eclipse.jetty.websocket.server.JettyWebSocketServletFactory;
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
import org.eclipse.jetty.websocket.tests.CloseTrackingEndpoint;
import org.eclipse.jetty.websocket.tests.util.FutureWriteCallback;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -84,7 +85,8 @@ public class ClientCloseTest
{
// Send message from client to server
final String echoMsg = "echo-test";
Future<Void> testFut = clientSocket.getRemote().sendStringByFuture(echoMsg);
FutureWriteCallback testFut = new FutureWriteCallback();
clientSocket.getRemote().sendString(echoMsg, testFut);
// Wait for send future
testFut.get(5, SECONDS);

View File

@ -18,7 +18,6 @@
package org.eclipse.jetty.websocket.tests.client;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@ -27,6 +26,7 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.tests.util.FutureWriteCallback;
public class ClientWriteThread extends Thread
{
@ -65,11 +65,12 @@ public class ClientWriteThread extends Thread
{
LOG.debug("Writing {} messages to connection {}",messageCount);
LOG.debug("Artificial Slowness {} ms",slowness);
Future<Void> lastMessage = null;
FutureWriteCallback lastMessage = null;
RemoteEndpoint remote = session.getRemote();
while (m.get() < messageCount)
{
lastMessage = remote.sendStringByFuture(message + "/" + m.get() + "/");
lastMessage = new FutureWriteCallback();
remote.sendString(message + "/" + m.get() + "/", lastMessage);
m.incrementAndGet();

View File

@ -22,6 +22,7 @@ import java.util.Collection;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.common.WebSocketContainer;
/**
@ -53,7 +54,7 @@ public class ContainerEndpoint extends AbstractCloseEndpoint
{
ret.append('[').append(idx++).append("] ").append(sess.toString()).append('\n');
}
session.getRemote().sendStringByFuture(ret.toString());
session.getRemote().sendString(ret.toString(), WriteCallback.NOOP);
}
session.close(StatusCode.NORMAL,"ContainerEndpoint");
}

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.core.client;
import java.net.URI;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.CompletableFuture;
@ -48,7 +49,6 @@ import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.QuotedStringTokenizer;
import org.eclipse.jetty.util.StringUtil;
@ -406,7 +406,7 @@ public abstract class ClientUpgradeRequest extends HttpRequest implements Respon
{
byte[] bytes = new byte[16];
ThreadLocalRandom.current().nextBytes(bytes);
return new String(B64Code.encode(bytes));
return Base64.getEncoder().encodeToString(bytes);
}
private void initWebSocketHeaders()

View File

@ -18,11 +18,11 @@
package org.eclipse.jetty.websocket.core.internal;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.websocket.core.WebSocketConstants;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Base64;
import org.eclipse.jetty.websocket.core.WebSocketConstants;
public final class WebSocketCore
{
@ -40,7 +40,7 @@ public final class WebSocketCore
MessageDigest md = MessageDigest.getInstance("SHA1");
md.update(key.getBytes(StandardCharsets.UTF_8));
md.update(WebSocketConstants.MAGIC);
return new String(B64Code.encode(md.digest()));
return Base64.getEncoder().encodeToString(md.digest());
}
catch (Exception e)
{

View File

@ -18,15 +18,15 @@
package org.eclipse.jetty.websocket.core;
import org.eclipse.jetty.util.B64Code;
import java.util.Base64;
import java.util.stream.Stream;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.websocket.core.internal.WebSocketCore;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@ -36,7 +36,7 @@ public class AcceptHashTest
{
byte key[] = TypeUtil.fromHexString(hex);
assertThat("Key size of hex:[" + hex + "]", key.length, is(16));
return String.valueOf(B64Code.encode(key));
return Base64.getEncoder().encodeToString(key);
}
public static Stream<Arguments> data()

View File

@ -25,12 +25,12 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.io.ArrayByteBufferPool;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.B64Code;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.core.internal.Parser;
@ -44,7 +44,7 @@ import static org.hamcrest.Matchers.startsWith;
public class WebSocketTester
{
private static String NON_RANDOM_KEY = new String(B64Code.encode("0123456701234567".getBytes()));
private static String NON_RANDOM_KEY = Base64.getEncoder().encodeToString("0123456701234567".getBytes());
private static SslContextFactory.Client sslContextFactory;
protected ByteBufferPool bufferPool;
protected Parser parser;