remove unsupported and deprecated --secure option, use jetty-policy.xml configuration instead with the policy OPTION

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3116 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Jesse McConnell 2011-05-10 21:51:21 +00:00
parent 1aeb9fb761
commit 412db03d50
3 changed files with 1 additions and 117 deletions

View File

@ -824,19 +824,6 @@ public class Config
continue;
}
// Add Security Policy file reference
if (subject.toLowerCase().endsWith(".policy"))
{
//policy file to parse
String cn = expand(subject.substring(0,subject.length()));
if (cn != null && cn.length() > 0)
{
debug(" POLICY=" + cn);
_policyDirectory = new File(fixPath(cn)).getParentFile().toURI().getPath();
}
continue;
}
// single JAR file
File f = new File(fixPath(file));
if (f.exists())
@ -970,24 +957,6 @@ public class Config
__properties.put(name,value);
}
public Policy getPolicyInstance(ClassLoader cl) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException,
InstantiationException, IllegalAccessException, InvocationTargetException
{
Class<?> jettyPolicy = cl.loadClass("org.eclipse.jetty.policy.JettyPolicy");
Constructor<?> c = jettyPolicy.getConstructor(new Class[]
{ Set.class, Map.class });
Object policyClass = c.newInstance(_policyDirectory, __properties);
if (policyClass instanceof Policy)
{
Policy p = (Policy)policyClass;
p.refresh();
return (Policy)policyClass;
}
throw new ClassCastException("Unable to cast to " + Policy.class.getName() + " : " + policyClass.getClass().getName());
}
public void addActiveOption(String option)
{
_activeOptions.add(option);

View File

@ -58,7 +58,6 @@ public class Main
private static final int EXIT_USAGE = 1;
private static final int ERR_LOGGING = -1;
private static final int ERR_INVOKE_MAIN = -2;
private static final int ERR_SECURITY = -3;
private static final int ERR_NOT_STOPPED = -4;
private static final int ERR_UNKNOWN = -5;
private boolean _showUsage = false;
@ -67,7 +66,6 @@ public class Main
private boolean _listOptions = false;
private boolean _dryRun = false;
private boolean _exec = false;
private boolean _secure = false;
private final Config _config = new Config();
private Set<String> _sysProps = new HashSet<String>();
private List<String> _jvmArgs = new ArrayList<String>();
@ -195,13 +193,7 @@ public class Main
System.out.println("Establishing start.log on " + new Date());
continue;
}
if ("--secure".equals(arg))
{
_secure = true;
continue;
}
if (arg.startsWith("--pre="))
{
xmls.add(startup++,arg.substring(6));
@ -512,13 +504,6 @@ public class Main
throw new FileNotFoundException("No XML configuration files specified in start.config or command line.");
}
// Add mandatory options for secure mode
if (_secure)
{
_config.addActiveOption("policy");
_config.addActiveOption("security");
}
// Normalize the XML config options passed on the command line.
configuredXmls = resolveXmlConfigs(configuredXmls);
@ -550,7 +535,6 @@ public class Main
if (_dumpVersions)
{
showClasspathWithVersions(classpath);
showActiveSecurityPolicies(cl);
return;
}
@ -595,9 +579,6 @@ public class Main
// Set current context class loader to what is selected.
Thread.currentThread().setContextClassLoader(cl);
// Initialize the Security
initSecurity(cl);
// Invoke the Main Class
try
{
@ -855,46 +836,6 @@ public class Main
}
}
private void showActiveSecurityPolicies(ClassLoader cl)
{
initSecurity(cl);
Policy policy = Policy.getPolicy();
if (policy != null && policy.getClass().getName().contains("JettyPolicy"))
{
System.out.println("Active Security Policies: ");
try
{
Method m = policy.getClass().getMethod("dump",new Class[]{ PrintStream.class });
m.invoke(policy,new Object[]
{ System.out });
}
catch (SecurityException e)
{
e.printStackTrace(System.err);
}
catch (NoSuchMethodException e)
{
e.printStackTrace(System.err);
}
catch (IllegalArgumentException e)
{
e.printStackTrace(System.err);
}
catch (IllegalAccessException e)
{
e.printStackTrace(System.err);
}
catch (InvocationTargetException e)
{
e.printStackTrace(System.err);
}
}
}
private String fixPath(String path)
{
return path.replace('/',File.separatorChar);
@ -930,31 +871,6 @@ public class Main
return "";
}
private void initSecurity(ClassLoader cl)
{
// Init the Security Policies
try
{
if (_secure)
{
Policy.setPolicy(_config.getPolicyInstance(cl));
System.setSecurityManager(new SecurityManager());
// Policy.getPolicy().refresh();
}
else
{
Policy policy = Policy.getPolicy();
if (policy != null)
{
policy.refresh();
}
}
}
catch (Exception e)
{
usageExit(e,ERR_SECURITY);
}
}
private List<String> resolveXmlConfigs(List<String> xmls) throws FileNotFoundException
{

View File

@ -137,7 +137,6 @@ $(jetty.home)/lib/setuid/**
[All,policy]
$(jetty.home)/lib/jetty-policy-$(version).jar ! available org.eclipse.jetty.policy.JettyPolicy
$(jetty.home)/lib/policy/jetty.policy
[All,Client,client]
$(jetty.home)/lib/jetty-http-$(version).jar ! available org.eclipse.jetty.http.HttpParser