Merge branch 'master' into performance

This commit is contained in:
Greg Wilkins 2011-07-18 09:16:51 +10:00
commit f4255bdeef
36 changed files with 402 additions and 130 deletions

View File

@ -1,6 +1,9 @@
jetty-7.5.0-SNAPSHOT
+ 298502 Handle 200 Connect responses with no content-length
+ 351516 Refactored sessions to better support nosql session managers
+ 351576 Do not use deprecated method File.toURL()
+ 352046 Need try/catch around features set in XmlParser
+ 352176 xml parsing on startElement should be more flexible on using qName or localName
jetty-7.4.4.v20110707 July 7th 2011
+ 308851 Converted all jetty-client module tests to JUnit 4

View File

@ -571,9 +571,14 @@ public class HttpConnection extends AbstractConnection implements Dumpable
@Override
public void startResponse(Buffer version, int status, Buffer reason) throws IOException
{
HttpExchange exchange = _exchange;
if (exchange!=null)
{
// handle special case for CONNECT 200 responses
if (status==HttpStatus.OK_200 && HttpMethods.CONNECT.equalsIgnoreCase(exchange.getMethod()))
_parser.setHeadResponse(true);
_http11 = HttpVersions.HTTP_1_1_BUFFER.equals(version);
_status=status;
exchange.getEventListener().onResponseStatus(version,status,reason);

View File

@ -673,6 +673,7 @@ public class HttpDestination implements Dumpable
this.proxyEndPoint = proxyEndPoint;
this.exchange = exchange;
setMethod(HttpMethods.CONNECT);
setVersion(exchange.getVersion());
String serverHostAndPort = serverAddress.toString();
setURI(serverHostAndPort);
addRequestHeader(HttpHeaders.HOST, serverHostAndPort);

View File

@ -0,0 +1,209 @@
package org.eclipse.jetty.client;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import org.eclipse.jetty.toolchain.test.IO;
public class ProxyFakeTunnelTest extends ProxyTunnellingTest
{
ServerSocket _proxySocket;
Thread _proxyThread;
protected int proxyPort()
{
return _proxySocket.getLocalPort();
}
protected void startProxy() throws Exception
{
_proxySocket = new ServerSocket(0);
_proxyThread = new Thread()
{
@Override
public void run()
{
while (!_proxySocket.isClosed())
{
try
{
Socket socket=_proxySocket.accept();
System.err.println("accepted "+socket);
new FakeProxy(socket).start();
}
catch (IOException e)
{
}
}
}
};
_proxyThread.setDaemon(true);
_proxyThread.start();
}
protected void stopProxy() throws Exception
{
_proxySocket.close();
_proxyThread.interrupt();
}
static class FakeProxy extends Thread
{
Socket _socket;
public FakeProxy(Socket socket)
{
_socket=socket;
}
public void run()
{
Socket toserver=null;
final InputStream in;
final OutputStream out;
try
{
in = _socket.getInputStream();
out = _socket.getOutputStream();
String address="";
int state=0;
for (int b=in.read();b>=0;b=in.read())
{
switch(state)
{
case 0:
if (' '==b)
state=1;
break;
case 1:
if (' '==b)
state=2;
else
address+=(char)b;
break;
case 2:
if ('\r'==b)
state=3;
break;
case 3:
if ('\n'==b)
state=4;
else
state=2;
break;
case 4:
if ('\r'==b)
state=5;
else
state=2;
break;
case 5:
if ('\n'==b)
{
state=6;
System.err.println("address="+address);
String[] parts=address.split(":");
try
{
toserver = new Socket(parts[0],Integer.parseInt(parts[1]));
out.write((
"HTTP/1.1 200 OK\r\n"+
"Server: fake\r\n"+
// "Content-Length: 0\r\n"+
"\r\n"
).getBytes());
}
catch(IOException e)
{
out.write((
"HTTP/1.1 503 Unavailable\r\n"+
"Server: fake\r\n"+
"Content-Length: 0\r\n"+
"\r\n"
).getBytes());
}
out.flush();
System.err.println(toserver);
final InputStream from = toserver.getInputStream();
Thread copy = new Thread()
{
public void run()
{
try
{
IO.copy(from,out);
out.close();
}
catch (IOException e)
{
}
finally
{
try
{
out.close();
}
catch (IOException e)
{
}
}
}
};
copy.setDaemon(true);
copy.start();
}
else
state=2;
break;
case 6:
toserver.getOutputStream().write((byte)b);
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (toserver!=null)
{
try
{
toserver.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}
}
}

View File

@ -37,7 +37,12 @@ public class ProxyTunnellingTest
private Connector proxyConnector;
private int serverConnectTimeout = 1000;
private void startSSLServer(Handler handler) throws Exception
protected int proxyPort()
{
return proxyConnector.getLocalPort();
}
protected void startSSLServer(Handler handler) throws Exception
{
SslSelectChannelConnector connector = new SslSelectChannelConnector();
String keyStorePath = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath();
@ -48,7 +53,7 @@ public class ProxyTunnellingTest
startServer(connector, handler);
}
private void startServer(Connector connector, Handler handler) throws Exception
protected void startServer(Connector connector, Handler handler) throws Exception
{
server = new Server();
serverConnector = connector;
@ -57,7 +62,7 @@ public class ProxyTunnellingTest
server.start();
}
private void startProxy() throws Exception
protected void startProxy() throws Exception
{
proxy = new Server();
proxyConnector = new SelectChannelConnector();
@ -77,13 +82,13 @@ public class ProxyTunnellingTest
stopServer();
}
private void stopServer() throws Exception
protected void stopServer() throws Exception
{
server.stop();
server.join();
}
private void stopProxy() throws Exception
protected void stopProxy() throws Exception
{
proxy.stop();
proxy.join();
@ -96,7 +101,7 @@ public class ProxyTunnellingTest
startProxy();
HttpClient httpClient = new HttpClient();
httpClient.setProxy(new Address("localhost", proxyConnector.getLocalPort()));
httpClient.setProxy(new Address("localhost", proxyPort()));
httpClient.start();
try
@ -124,7 +129,7 @@ public class ProxyTunnellingTest
startProxy();
HttpClient httpClient = new HttpClient();
httpClient.setProxy(new Address("localhost", proxyConnector.getLocalPort()));
httpClient.setProxy(new Address("localhost", proxyPort()));
httpClient.start();
try
@ -163,7 +168,7 @@ public class ProxyTunnellingTest
{
startSSLServer(new ServerHandler());
startProxy();
int proxyPort = proxyConnector.getLocalPort();
int proxyPort = proxyPort();
stopProxy();
HttpClient httpClient = new HttpClient();
@ -203,7 +208,7 @@ public class ProxyTunnellingTest
startProxy();
HttpClient httpClient = new HttpClient();
httpClient.setProxy(new Address("localhost", proxyConnector.getLocalPort()));
httpClient.setProxy(new Address("localhost", proxyPort()));
httpClient.start();
try

View File

@ -16,6 +16,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import org.eclipse.jetty.osgi.boot.utils.BundleClassLoaderHelper;
import org.osgi.framework.Bundle;
@ -145,8 +146,21 @@ public class DefaultBundleClassLoaderHelper implements BundleClassLoaderHelper
"m_modules");
Felix_BundleImpl_m_modules_field.setAccessible(true);
}
Object[] moduleArray = (Object[])Felix_BundleImpl_m_modules_field.get(bundle);
Object currentModuleImpl = moduleArray[moduleArray.length - 1];
// Figure out which version of the modules is exported
Object currentModuleImpl;
try
{
Object[] moduleArray = (Object[])Felix_BundleImpl_m_modules_field.get(bundle);
currentModuleImpl = moduleArray[moduleArray.length - 1];
}
catch (Throwable t2)
{
@SuppressWarnings("unchecked")
List<Object> moduleArray = (List<Object>)Felix_BundleImpl_m_modules_field.get(bundle);
currentModuleImpl = moduleArray.get(moduleArray.size() - 1);
}
if (Felix_ModuleImpl_m_classLoader_field == null && currentModuleImpl != null)
{
Felix_ModuleImpl_m_classLoader_field = bundle.getClass().getClassLoader().loadClass("org.apache.felix.framework.ModuleImpl").getDeclaredField(

View File

@ -21,8 +21,6 @@ import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.eclipse.jetty.util.IntrospectionUtil;
import org.eclipse.jetty.util.Loader;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.Log;
/**

View File

@ -63,7 +63,7 @@ public class InjectionCollection
public Injection getInjection (String jndiName, Class clazz, Field field)
public Injection getInjection (String jndiName, Class<?> clazz, Field field)
{
if (field == null || clazz == null)
return null;
@ -83,7 +83,7 @@ public class InjectionCollection
return injection;
}
public Injection getInjection (String jndiName, Class clazz, Method method, Class paramClass)
public Injection getInjection (String jndiName, Class<?> clazz, Method method, Class<?> paramClass)
{
if (clazz == null || method == null || paramClass == null)
return null;

View File

@ -31,7 +31,7 @@ public abstract class LifeCycleCallback
{
public static final Object[] __EMPTY_ARGS = new Object[] {};
private Method _target;
private Class _targetClass;
private Class<?> _targetClass;
private String _className;
private String _methodName;
@ -44,7 +44,7 @@ public abstract class LifeCycleCallback
/**
* @return the _targetClass
*/
public Class getTargetClass()
public Class<?> getTargetClass()
{
return _targetClass;
}
@ -74,7 +74,7 @@ public abstract class LifeCycleCallback
_methodName = methodName;
}
public void setTarget (Class clazz, String methodName)
public void setTarget (Class<?> clazz, String methodName)
{
try
{
@ -125,7 +125,7 @@ public abstract class LifeCycleCallback
* @param checkInheritance false on first entry, true if a superclass is being introspected
* @return the method
*/
public Method findMethod (Package pack, Class clazz, String methodName, boolean checkInheritance)
public Method findMethod (Package pack, Class<?> clazz, String methodName, boolean checkInheritance)
{
if (clazz == null)
return null;
@ -175,5 +175,5 @@ public abstract class LifeCycleCallback
return true;
}
public abstract void validate (Class clazz, Method m);
public abstract void validate (Class<?> clazz, Method m);
}

View File

@ -71,7 +71,7 @@ public class LifeCycleCallbackCollection
if (o == null)
return null;
Class clazz = o.getClass();
Class<? extends Object> clazz = o.getClass();
return preDestroyCallbacksMap.get(clazz.getName());
}
@ -80,7 +80,7 @@ public class LifeCycleCallbackCollection
if (o == null)
return null;
Class clazz = o.getClass();
Class<? extends Object> clazz = o.getClass();
return postConstructCallbacksMap.get(clazz.getName());
}
@ -96,7 +96,7 @@ public class LifeCycleCallbackCollection
if (o == null)
return;
Class clazz = o.getClass();
Class<? extends Object> clazz = o.getClass();
List<LifeCycleCallback> callbacks = postConstructCallbacksMap.get(clazz.getName());
if (callbacks == null)
@ -120,7 +120,7 @@ public class LifeCycleCallbackCollection
if (o == null)
return;
Class clazz = o.getClass();
Class<? extends Object> clazz = o.getClass();
List<LifeCycleCallback> callbacks = preDestroyCallbacksMap.get(clazz.getName());
if (callbacks == null)
return;

View File

@ -33,7 +33,7 @@ public class PostConstructCallback extends LifeCycleCallback
* - cannot be static
* @see org.eclipse.jetty.plus.annotation.LifeCycleCallback#validate(java.lang.Class, java.lang.reflect.Method)
*/
public void validate(Class clazz, Method method)
public void validate(Class<?> clazz, Method method)
{
if (method.getExceptionTypes().length > 0)
throw new IllegalArgumentException(clazz.getName()+"."+method.getName()+ " cannot not throw a checked exception");

View File

@ -34,7 +34,7 @@ public class PreDestroyCallback extends LifeCycleCallback
* - not static
* @see org.eclipse.jetty.plus.annotation.LifeCycleCallback#validate(java.lang.Class, java.lang.reflect.Method)
*/
public void validate(Class clazz, Method method)
public void validate(Class<?> clazz, Method method)
{
if (method.getExceptionTypes().length > 0)

View File

@ -15,7 +15,6 @@ package org.eclipse.jetty.plus.annotation;
import javax.servlet.ServletException;
import org.eclipse.jetty.security.SecurityHandler;
import org.eclipse.jetty.servlet.ServletHolder;
/**

View File

@ -17,10 +17,8 @@ import java.util.HashMap;
import javax.servlet.ServletException;
import org.eclipse.jetty.security.SecurityHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.webapp.WebAppContext;
/**
@ -31,7 +29,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
public class RunAsCollection
{
public static final String RUNAS_COLLECTION = "org.eclipse.jetty.runAsCollection";
private HashMap _runAsMap = new HashMap();//map of classname to run-as
private HashMap<String, RunAs> _runAsMap = new HashMap<String, RunAs>();//map of classname to run-as

View File

@ -25,14 +25,14 @@ public class JAASGroup implements Group
public static final String ROLES = "__roles__";
private String _name = null;
private HashSet _members = null;
private HashSet<Principal> _members = null;
public JAASGroup(String n)
{
this._name = n;
this._members = new HashSet();
this._members = new HashSet<Principal>();
}
/* ------------------------------------------------------------ */
@ -72,14 +72,14 @@ public class JAASGroup implements Group
*
* @return <description>
*/
public Enumeration members()
public Enumeration<? extends Principal> members()
{
class MembersEnumeration implements Enumeration
class MembersEnumeration implements Enumeration<Principal>
{
private Iterator itor;
private Iterator<? extends Principal> itor;
public MembersEnumeration (Iterator itor)
public MembersEnumeration (Iterator<? extends Principal> itor)
{
this.itor = itor;
}
@ -90,7 +90,7 @@ public class JAASGroup implements Group
}
public Object nextElement ()
public Principal nextElement ()
{
return this.itor.next();
}

View File

@ -255,6 +255,7 @@ public class JAASLoginService extends AbstractLifeCycle implements LoginService
/* ------------------------------------------------------------ */
@SuppressWarnings({ "unchecked", "rawtypes" })
private String[] getGroups (Subject subject)
{
//get all the roles of the various types

View File

@ -37,6 +37,11 @@ import java.security.Principal;
*/
public class JAASPrincipal implements Principal, Serializable
{
/**
*
*/
private static final long serialVersionUID = -5538962177019315479L;
private String _name = null;

View File

@ -17,6 +17,11 @@ package org.eclipse.jetty.plus.jaas;
public class JAASRole extends JAASPrincipal
{
/**
*
*/
private static final long serialVersionUID = 3465114254970134526L;
public JAASRole(String name)
{
super (name);

View File

@ -43,7 +43,7 @@ public class StrictRoleCheckPolicy implements RoleCheckPolicy
{
if (roles == null)
return false;
Enumeration rolesEnum = roles.members();
Enumeration<? extends Principal> rolesEnum = roles.members();
boolean found = false;
while (rolesEnum.hasMoreElements() && !found)
{

View File

@ -33,7 +33,7 @@ import javax.security.auth.callback.Callback;
public class RequestParameterCallback implements Callback
{
private String _paramName;
private List _paramValues;
private List<?> _paramValues;
public void setParameterName (String name)
{
@ -44,12 +44,12 @@ public class RequestParameterCallback implements Callback
return _paramName;
}
public void setParameterValues (List values)
public void setParameterValues (List<?> values)
{
_paramValues = values;
}
public List getParameterValues ()
public List<?> getParameterValues ()
{
return _paramValues;
}

View File

@ -87,7 +87,7 @@ public abstract class AbstractDatabaseLoginModule extends AbstractLoginModule
statement = connection.prepareStatement (rolesQuery);
statement.setString (1, userName);
results = statement.executeQuery();
List roles = new ArrayList();
List<String> roles = new ArrayList<String>();
while (results.next())
{
@ -110,8 +110,8 @@ public abstract class AbstractDatabaseLoginModule extends AbstractLoginModule
public void initialize(Subject subject,
CallbackHandler callbackHandler,
Map sharedState,
Map options)
Map<String,?> sharedState,
Map<String,?> options)
{
super.initialize(subject, callbackHandler, sharedState, options);

View File

@ -52,7 +52,7 @@ public abstract class AbstractLoginModule implements LoginModule
{
private UserInfo user;
private Principal principal;
private List roles;
private List<JAASRole> roles;
public JAASUserInfo (UserInfo u)
{
@ -73,10 +73,10 @@ public abstract class AbstractLoginModule implements LoginModule
{
this.user = u;
this.principal = new JAASPrincipal(u.getUserName());
this.roles = new ArrayList();
this.roles = new ArrayList<JAASRole>();
if (u.getRoleNames() != null)
{
Iterator itor = u.getRoleNames().iterator();
Iterator<String> itor = u.getRoleNames().iterator();
while (itor.hasNext())
this.roles.add(new JAASRole((String)itor.next()));
}
@ -269,7 +269,7 @@ public abstract class AbstractLoginModule implements LoginModule
* @param options
*/
public void initialize(Subject subject, CallbackHandler callbackHandler,
Map sharedState, Map options)
Map<String,?> sharedState, Map<String,?> options)
{
this.callbackHandler = callbackHandler;
this.subject = subject;

View File

@ -45,8 +45,8 @@ public class DataSourceLoginModule extends AbstractDatabaseLoginModule
*/
public void initialize(Subject subject,
CallbackHandler callbackHandler,
Map sharedState,
Map options)
Map<String,?> sharedState,
Map<String,?> options)
{
try
{

View File

@ -81,8 +81,8 @@ public class JDBCLoginModule extends AbstractDatabaseLoginModule
*/
public void initialize(Subject subject,
CallbackHandler callbackHandler,
Map sharedState,
Map options)
Map<String,?> sharedState,
Map<String,?> options)
{
try
{

View File

@ -196,7 +196,7 @@ public class LdapLoginModule extends AbstractLoginModule
pwdCredential = convertCredentialLdapToJetty(pwdCredential);
Credential credential = Credential.getCredential(pwdCredential);
List roles = getUserRoles(_rootContext, username);
List<String> roles = getUserRoles(_rootContext, username);
return new UserInfo(username, credential, roles);
}
@ -257,7 +257,7 @@ public class LdapLoginModule extends AbstractLoginModule
try
{
Object[] filterArguments = {_userObjectClass, _userIdAttribute, username};
NamingEnumeration results = _rootContext.search(_userBaseDn, filter, filterArguments, ctls);
NamingEnumeration<SearchResult> results = _rootContext.search(_userBaseDn, filter, filterArguments, ctls);
Log.debug("Found user?: " + results.hasMoreElements());
@ -305,16 +305,16 @@ public class LdapLoginModule extends AbstractLoginModule
* @return
* @throws LoginException
*/
private List getUserRoles(DirContext dirContext, String username) throws LoginException, NamingException
private List<String> getUserRoles(DirContext dirContext, String username) throws LoginException, NamingException
{
String userDn = _userRdnAttribute + "=" + username + "," + _userBaseDn;
return getUserRolesByDn(dirContext, userDn);
}
private List getUserRolesByDn(DirContext dirContext, String userDn) throws LoginException, NamingException
private List<String> getUserRolesByDn(DirContext dirContext, String userDn) throws LoginException, NamingException
{
ArrayList roleList = new ArrayList();
List<String> roleList = new ArrayList<String>();
if (dirContext == null || _roleBaseDn == null || _roleMemberAttribute == null || _roleObjectClass == null)
{
@ -327,7 +327,7 @@ public class LdapLoginModule extends AbstractLoginModule
String filter = "(&(objectClass={0})({1}={2}))";
Object[] filterArguments = {_roleObjectClass, _roleMemberAttribute, userDn};
NamingEnumeration results = dirContext.search(_roleBaseDn, filter, filterArguments, ctls);
NamingEnumeration<SearchResult> results = dirContext.search(_roleBaseDn, filter, filterArguments, ctls);
Log.debug("Found user roles?: " + results.hasMoreElements());
@ -349,10 +349,10 @@ public class LdapLoginModule extends AbstractLoginModule
continue;
}
NamingEnumeration roles = roleAttribute.getAll();
NamingEnumeration<?> roles = roleAttribute.getAll();
while (roles.hasMore())
{
roleList.add(roles.next());
roleList.add(roles.next().toString());
}
}
@ -468,12 +468,12 @@ public class LdapLoginModule extends AbstractLoginModule
Log.info("Attempting authentication: " + userDn);
Hashtable environment = getEnvironment();
Hashtable<Object,Object> environment = getEnvironment();
environment.put(Context.SECURITY_PRINCIPAL, userDn);
environment.put(Context.SECURITY_CREDENTIALS, password);
DirContext dirContext = new InitialDirContext(environment);
List roles = getUserRolesByDn(dirContext, userDn);
List<String> roles = getUserRolesByDn(dirContext, userDn);
UserInfo userInfo = new UserInfo(username, null, roles);
setCurrentUser(new JAASUserInfo(userInfo));
@ -498,7 +498,7 @@ public class LdapLoginModule extends AbstractLoginModule
_userIdAttribute,
username
};
NamingEnumeration results = _rootContext.search(_userBaseDn, filter, filterArguments, ctls);
NamingEnumeration<SearchResult> results = _rootContext.search(_userBaseDn, filter, filterArguments, ctls);
Log.info("Found user?: " + results.hasMoreElements());
@ -522,8 +522,8 @@ public class LdapLoginModule extends AbstractLoginModule
*/
public void initialize(Subject subject,
CallbackHandler callbackHandler,
Map sharedState,
Map options)
Map<String,?> sharedState,
Map<String,?> options)
{
super.initialize(subject, callbackHandler, sharedState, options);
@ -595,7 +595,7 @@ public class LdapLoginModule extends AbstractLoginModule
return super.abort();
}
private String getOption(Map options, String key, String defaultValue)
private String getOption(Map<String,?> options, String key, String defaultValue)
{
Object value = options.get(key);

View File

@ -36,7 +36,7 @@ import org.eclipse.jetty.util.log.Log;
public class PropertyFileLoginModule extends AbstractLoginModule
{
public static final String DEFAULT_FILENAME = "realm.properties";
public static final Map fileMap = new HashMap();
public static final Map<String, Map<String, UserInfo>> fileMap = new HashMap<String, Map<String, UserInfo>>();
private String propertyFileName;
@ -52,7 +52,7 @@ public class PropertyFileLoginModule extends AbstractLoginModule
* @param options
*/
public void initialize(Subject subject, CallbackHandler callbackHandler,
Map sharedState, Map options)
Map<String,?> sharedState, Map<String,?> options)
{
super.initialize(subject, callbackHandler, sharedState, options);
loadProperties((String)options.get("file"));
@ -95,14 +95,14 @@ public class PropertyFileLoginModule extends AbstractLoginModule
return;
}
Map userInfoMap = new HashMap();
Map<String, UserInfo> userInfoMap = new HashMap<String, UserInfo>();
Properties props = new Properties();
props.load(new FileInputStream(propsFile));
Iterator iter = props.entrySet().iterator();
Iterator<Map.Entry<Object,Object>> iter = props.entrySet().iterator();
while(iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
Map.Entry<Object,Object> entry = iter.next();
String username=entry.getKey().toString().trim();
String credentials=entry.getValue().toString().trim();
String roles=null;
@ -116,7 +116,7 @@ public class PropertyFileLoginModule extends AbstractLoginModule
if (username!=null && username.length()>0 &&
credentials!=null && credentials.length()>0)
{
ArrayList roleList = new ArrayList();
ArrayList<String> roleList = new ArrayList<String>();
if(roles!=null && roles.length()>0)
{
StringTokenizer tok = new StringTokenizer(roles,", ");
@ -146,7 +146,7 @@ public class PropertyFileLoginModule extends AbstractLoginModule
*/
public UserInfo getUserInfo (String username) throws Exception
{
Map userInfoMap = (Map)fileMap.get(propertyFileName);
Map<?, ?> userInfoMap = (Map<?, ?>)fileMap.get(propertyFileName);
if (userInfoMap == null)
return null;
return (UserInfo)userInfoMap.get(username);

View File

@ -29,38 +29,40 @@ import org.eclipse.jetty.http.security.Credential;
public class UserInfo
{
private String userName;
private Credential credential;
private List roleNames;
private String _userName;
private Credential _credential;
private List<String> _roleNames;
public UserInfo (String userName, Credential credential, List roleNames)
public UserInfo (String userName, Credential credential, List<String> roleNames)
{
this.userName = userName;
this.credential = credential;
this.roleNames = new ArrayList();
_userName = userName;
_credential = credential;
_roleNames = new ArrayList<String>();
if (roleNames != null)
this.roleNames.addAll(roleNames);
{
_roleNames.addAll(roleNames);
}
}
public String getUserName()
{
return this.userName;
return this._userName;
}
public List getRoleNames ()
public List<String> getRoleNames ()
{
return new ArrayList(this.roleNames);
return new ArrayList<String>(_roleNames);
}
public boolean checkCredential (Object suppliedCredential)
{
return this.credential.check(suppliedCredential);
return _credential.check(suppliedCredential);
}
protected Credential getCredential ()
{
return this.credential;
return _credential;
}
}

View File

@ -96,20 +96,15 @@ public class NamingEntryUtil
return entry;
}
public static Object lookup (Object scope, String jndiName)
throws NamingException
public static Object lookup(Object scope, String jndiName) throws NamingException
{
Object o = null;
Name scopeName = getNameForScope(scope);
InitialContext ic = new InitialContext();
NameParser parser = ic.getNameParser("");
scopeName.addAll(parser.parse(jndiName));
return ic.lookup(scopeName);
Name scopeName = getNameForScope(scope);
InitialContext ic = new InitialContext();
NameParser parser = ic.getNameParser("");
scopeName.addAll(parser.parse(jndiName));
return ic.lookup(scopeName);
}
/**
* Get all NameEntries of a certain type in the given naming
* environment scope (server-wide names or context-specific names)
@ -119,20 +114,20 @@ public class NamingEntryUtil
* @return all NameEntries of a certain type in the given naming environment scope (server-wide names or context-specific names)
* @throws NamingException
*/
public static List lookupNamingEntries (Object scope, Class clazz)
public static List<Object> lookupNamingEntries (Object scope, Class<?> clazz)
throws NamingException
{
try
{
Context scopeContext = getContextForScope(scope);
Context namingEntriesContext = (Context)scopeContext.lookup(NamingEntry.__contextName);
ArrayList list = new ArrayList();
ArrayList<Object> list = new ArrayList<Object>();
lookupNamingEntries(list, namingEntriesContext, clazz);
return list;
}
catch (NameNotFoundException e)
{
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
}
@ -211,15 +206,15 @@ public class NamingEntryUtil
* @return
* @throws NamingException
*/
private static List lookupNamingEntries (List list, Context context, Class clazz)
private static List<Object> lookupNamingEntries (List<Object> list, Context context, Class<?> clazz)
throws NamingException
{
try
{
NamingEnumeration nenum = context.listBindings("");
NamingEnumeration<Binding> nenum = context.listBindings("");
while (nenum.hasMoreElements())
{
Binding binding = (Binding)nenum.next();
Binding binding = nenum.next();
if (binding.getObject() instanceof Context)
lookupNamingEntries (list, (Context)binding.getObject(), clazz);
else if (clazz.isInstance(binding.getObject()))

View File

@ -60,7 +60,6 @@ public class DataSourceLoginService extends MappedLoginService
private String _userRoleTableUserKey = "user_id";
private String _userRoleTableRoleKey = "role_id";
private int _cacheMs = 30000;
private long _lastHashPurge = 0;
private String _userSql;
private String _roleSql;
private boolean _createTables = false;
@ -350,6 +349,7 @@ public class DataSourceLoginService extends MappedLoginService
if (_datasource != null)
return;
@SuppressWarnings("unused")
InitialContext ic = new InitialContext();
//TODO webapp scope?

View File

@ -28,10 +28,8 @@ import javax.naming.NamingException;
import org.eclipse.jetty.jndi.NamingContext;
import org.eclipse.jetty.jndi.NamingUtil;
import org.eclipse.jetty.jndi.java.javaRootURLContext;
import org.eclipse.jetty.jndi.local.localContextRoot;
import org.eclipse.jetty.plus.jndi.EnvEntry;
import org.eclipse.jetty.plus.jndi.NamingEntry;
import org.eclipse.jetty.plus.jndi.NamingEntryUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.webapp.AbstractConfiguration;
@ -148,6 +146,7 @@ public class EnvConfiguration extends AbstractConfiguration
compCtx.destroySubcontext("env");
//unbind any NamingEntries that were configured in this webapp's name space
@SuppressWarnings("unchecked")
List<Bound> bindings = (List<Bound>)context.getAttribute(JETTY_ENV_BINDINGS);
context.setAttribute(JETTY_ENV_BINDINGS,null);
if (bindings!=null)
@ -203,8 +202,8 @@ public class EnvConfiguration extends AbstractConfiguration
InitialContext ic = new InitialContext();
Context envCtx = (Context)ic.lookup("java:comp/env");
Object scope = null;
List list = NamingEntryUtil.lookupNamingEntries(scope, EnvEntry.class);
Iterator itor = list.iterator();
List<Object> list = NamingEntryUtil.lookupNamingEntries(scope, EnvEntry.class);
Iterator<Object> itor = list.iterator();
while (itor.hasNext())
{
EnvEntry ee = (EnvEntry)itor.next();

View File

@ -21,7 +21,6 @@ import javax.naming.NameNotFoundException;
import org.eclipse.jetty.plus.annotation.InjectionCollection;
import org.eclipse.jetty.plus.annotation.LifeCycleCallbackCollection;
import org.eclipse.jetty.plus.annotation.RunAsCollection;
import org.eclipse.jetty.plus.jndi.Transaction;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.webapp.AbstractConfiguration;

View File

@ -22,10 +22,9 @@ import javax.servlet.ServletException;
import org.eclipse.jetty.plus.annotation.InjectionCollection;
import org.eclipse.jetty.plus.annotation.LifeCycleCallbackCollection;
import org.eclipse.jetty.plus.annotation.RunAsCollection;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlet.ServletContextHandler.Decorator;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.webapp.WebAppContext;

View File

@ -286,7 +286,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{
Descriptor otherFragment = context.getMetaData().getOriginDescriptor("resource-ref."+jndiName);
XmlParser.Node otherFragmentRoot = otherFragment.getRoot();
Iterator iter = otherFragmentRoot.iterator();
Iterator<Object> iter = otherFragmentRoot.iterator();
XmlParser.Node otherNode = null;
while (iter.hasNext() && otherNode == null)
{
@ -395,7 +395,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{
Descriptor otherFragment = context.getMetaData().getOriginDescriptor("resource-env-ref."+jndiName);
XmlParser.Node otherFragmentRoot = otherFragment.getRoot();
Iterator iter = otherFragmentRoot.iterator();
Iterator<Object> iter = otherFragmentRoot.iterator();
XmlParser.Node otherNode = null;
while (iter.hasNext() && otherNode == null)
{
@ -491,7 +491,7 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{
Descriptor otherFragment = context.getMetaData().getOriginDescriptor("message-destination-ref."+jndiName);
XmlParser.Node otherFragmentRoot = otherFragment.getRoot();
Iterator iter = otherFragmentRoot.iterator();
Iterator<Object> iter = otherFragmentRoot.iterator();
XmlParser.Node otherNode = null;
while (iter.hasNext() && otherNode == null)
{
@ -706,11 +706,11 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
*/
public void addInjections (WebAppContext context, Descriptor descriptor, XmlParser.Node node, String jndiName, Class<?> valueClass)
{
Iterator itor = node.iterator("injection-target");
Iterator<XmlParser.Node> itor = node.iterator("injection-target");
while(itor.hasNext())
{
XmlParser.Node injectionNode = (XmlParser.Node)itor.next();
XmlParser.Node injectionNode = itor.next();
String targetClassName = injectionNode.getString("injection-target-class", false, true);
String targetName = injectionNode.getString("injection-target-name", false, true);
if ((targetClassName==null) || targetClassName.equals(""))
@ -852,7 +852,6 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{
//if we found a mapping, get out name it is mapped to in the environment
nameInEnvironment = ((Link)ne).getLink();
Link l = (Link)ne;
}
//try finding that mapped name in the webapp's environment first

View File

@ -190,7 +190,6 @@ public abstract class ConnectorCloseTestBase extends HttpServerTestFixture
/* ------------------------------------------------------------ */
public class ResponseReader implements Runnable
{
private int _last = 0;
private boolean _done = false;
protected char[] _buffer;
@ -225,7 +224,7 @@ public abstract class ConnectorCloseTestBase extends HttpServerTestFixture
try
{
int count = 0;
while (!_done || _last > 0 || count > 0)
while (!_done || count > 0)
{
count = doRead();
}
@ -245,10 +244,8 @@ public abstract class ConnectorCloseTestBase extends HttpServerTestFixture
/* ------------------------------------------------------------ */
protected int doRead() throws IOException, InterruptedException
{
if (_last > 0)
if (!_reader.ready())
{
_last = 0;
Thread.sleep(25);
}
@ -258,7 +255,6 @@ public abstract class ConnectorCloseTestBase extends HttpServerTestFixture
count = _reader.read(_buffer);
if (count > 0)
{
_last = count;
_response.append(_buffer, 0, count);
}
}

View File

@ -70,7 +70,6 @@ public class XmlParser
boolean validating_dft = factory.getClass().toString().startsWith("org.apache.xerces.");
String validating_prop = System.getProperty("org.eclipse.jetty.xml.XmlParser.Validating", validating_dft ? "true" : "false");
boolean validating = Boolean.valueOf(validating_prop).booleanValue();
setValidating(validating);
}
@ -108,7 +107,15 @@ public class XmlParser
_parser.getXMLReader().setFeature("http://xml.org/sax/features/validation", validating);
_parser.getXMLReader().setFeature("http://xml.org/sax/features/namespaces", true);
_parser.getXMLReader().setFeature("http://xml.org/sax/features/namespace-prefixes", false);
_parser.getXMLReader().setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", validating);
try
{
if (validating)
_parser.getXMLReader().setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", validating);
}
catch (Exception e)
{
Log.warn(e.getMessage());
}
}
catch (Exception e)
{
@ -289,7 +296,13 @@ public class XmlParser
/* ------------------------------------------------------------ */
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException
{
String name = (uri == null || uri.equals("")) ? qName : localName;
String name = null;
if (_parser.isNamespaceAware())
name = localName;
if (name == null || "".equals(name))
name = qName;
Node node = new Node(_context, name, attrs);
@ -467,10 +480,10 @@ public class XmlParser
/**
* XML Node. Represents an XML element with optional attributes and ordered content.
*/
public static class Node extends AbstractList
public static class Node extends AbstractList<Object>
{
Node _parent;
private ArrayList _list;
private ArrayList<Object> _list;
private String _tag;
private Attribute[] _attrs;
private boolean _lastString = false;
@ -610,7 +623,7 @@ public class XmlParser
public void add(int i, Object o)
{
if (_list == null)
_list = new ArrayList();
_list = new ArrayList<Object>();
if (o instanceof String)
{
if (_lastString)

View File

@ -13,6 +13,7 @@
package org.eclipse.jetty.server.session;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;
import javax.servlet.ServletException;
@ -67,6 +68,7 @@ public abstract class AbstractLastAccessTimeTest
client.send(exchange1);
exchange1.waitForDone();
assertEquals(HttpServletResponse.SC_OK, exchange1.getResponseStatus());
assertEquals("test", exchange1.getResponseContent());
String sessionCookie = exchange1.getResponseFields().getStringField("Set-Cookie");
assertTrue( sessionCookie != null );
// Mangle the cookie, replacing Path with $Path, etc.
@ -87,6 +89,8 @@ public abstract class AbstractLastAccessTimeTest
client.send(exchange2);
exchange2.waitForDone();
assertEquals(HttpServletResponse.SC_OK , exchange2.getResponseStatus());
assertEquals("test", exchange2.getResponseContent());
String setCookie = exchange1.getResponseFields().getStringField("Set-Cookie");
if (setCookie!=null)
sessionCookie = setCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
@ -136,13 +140,36 @@ public abstract class AbstractLastAccessTimeTest
{
HttpSession session = request.getSession(true);
session.setAttribute("test", "test");
sendResult(session, httpServletResponse.getWriter());
}
else
{
HttpSession session = request.getSession(false);
// if we node hopped we should get the session and test should already be present
sendResult(session, httpServletResponse.getWriter());
if (session!=null)
{
session.setAttribute("test", "test");
}
}
}
private void sendResult(HttpSession session, PrintWriter writer)
{
if (session != null)
{
writer.print(session.getAttribute("test"));
}
else
{
writer.print("null");
}
}
}
}