src/share/jaxws_classes/com/sun/tools/internal/xjc/Options.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -43,17 +43,17 @@
import java.util.Date;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import com.sun.codemodel.internal.CodeWriter;
import com.sun.codemodel.internal.JPackage;
+import com.sun.codemodel.internal.JResourceFile;
import com.sun.codemodel.internal.writer.FileCodeWriter;
import com.sun.codemodel.internal.writer.PrologCodeWriter;
+import com.sun.istack.internal.tools.DefaultAuthenticator;
import com.sun.org.apache.xml.internal.resolver.CatalogManager;
import com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver;
import com.sun.tools.internal.xjc.api.ClassNameAllocator;
import com.sun.tools.internal.xjc.api.SpecVersion;
import com.sun.tools.internal.xjc.generator.bean.field.FieldRendererFactory;
@@ -104,10 +104,19 @@
/** Encoding to be used by generated java sources, null for platform default. */
public String encoding;
/**
+ * If true XML security features when parsing XML documents will be disabled.
+ * The default value is false.
+ *
+ * Boolean
+ * @since 2.2.6
+ */
+ public boolean disableXmlSecurity;
+
+ /**
* Check the source schemas with extra scrutiny.
* The exact meaning depends on the schema language.
*/
public boolean strictCheck =true;
@@ -150,24 +159,16 @@
/**
* Generates output for the specified version of the runtime.
*/
public SpecVersion target = SpecVersion.LATEST;
- private boolean is2_2 = true;
public Options() {
- if (is2_2) {
try {
Class.forName("javax.xml.bind.JAXBPermission");
} catch (ClassNotFoundException cnfe) {
- is2_2 = false;
- }
- if (!is2_2) {
target = SpecVersion.V2_1;
- } else {
- target = SpecVersion.LATEST;
- }
}
}
/**
* Target directory when producing files.
@@ -211,12 +212,11 @@
private final List<InputSource> bindFiles = new ArrayList<InputSource>();
// Proxy setting.
private String proxyHost = null;
private String proxyPort = null;
- private String proxyUser = null;
- private String proxyPassword = null;
+ public String proxyAuth = null;
/**
* {@link Plugin}s that are enabled in this compilation.
*/
public final List<Plugin> activePlugins = new ArrayList<Plugin>();
@@ -457,11 +457,13 @@
public final List<URL> classpaths = new ArrayList<URL>();
/**
* Gets a classLoader that can load classes specified via the
* -classpath option.
*/
- public URLClassLoader getUserClassLoader( ClassLoader parent ) {
+ public ClassLoader getUserClassLoader( ClassLoader parent ) {
+ if (classpaths.isEmpty())
+ return parent;
return new URLClassLoader(
classpaths.toArray(new URL[classpaths.size()]),parent);
}
@@ -540,10 +542,14 @@
}
if (args[i].equals("-enableIntrospection")) {
enableIntrospection = true;
return 1;
}
+ if (args[i].equals("-disableXmlSecurity")) {
+ disableXmlSecurity = true;
+ return 1;
+ }
if (args[i].equals("-contentForWildcard")) {
contentForWildcard = true;
return 1;
}
if (args[i].equals("-XautoNameResolution")) {
@@ -637,20 +643,10 @@
throw new BadCommandLineException(
Messages.format(Messages.FAILED_TO_PARSE,catalogFile,e.getMessage()),e);
}
return 2;
}
- if (args[i].equals("-source")) {
- String version = requireArgument("-source",args,++i);
- //For source 1.0 the 1.0 Driver is loaded
- //Hence anything other than 2.0 is defaulted to
- //2.0
- if( !version.equals("2.0") && !version.equals("2.1") )
- throw new BadCommandLineException(
- Messages.format(Messages.DEFAULT_VERSION));
- return 2;
- }
if( args[i].equals("-Xtest-class-name-allocator") ) {
classNameAllocator = new ClassNameAllocator() {
public String assignClassName(String packageName, String className) {
System.out.printf("assignClassName(%s,%s)\n",packageName,className);
return className+"_Type";
@@ -701,22 +697,33 @@
return 0; // unrecognized
}
private void parseProxy(String text) throws BadCommandLineException {
- // syntax is [user[:password]@]proxyHost:proxyPort
- String token = "([^@:]+)";
- Pattern p = Pattern.compile("(?:"+token+"(?:\\:"+token+")?\\@)?"+token+"(?:\\:"+token+")");
-
- Matcher matcher = p.matcher(text);
- if(!matcher.matches())
- throw new BadCommandLineException(Messages.format(Messages.ILLEGAL_PROXY,text));
+ int i = text.lastIndexOf('@');
+ int j = text.lastIndexOf(':');
- proxyUser = matcher.group(1);
- proxyPassword = matcher.group(2);
- proxyHost = matcher.group(3);
- proxyPort = matcher.group(4);
+ if (i > 0) {
+ proxyAuth = text.substring(0, i);
+ if (j > i) {
+ proxyHost = text.substring(i + 1, j);
+ proxyPort = text.substring(j + 1);
+ } else {
+ proxyHost = text.substring(i + 1);
+ proxyPort = "80";
+ }
+ } else {
+ //no auth info
+ if (j < 0) {
+ //no port
+ proxyHost = text;
+ proxyPort = "80";
+ } else {
+ proxyHost = text.substring(0, j);
+ proxyPort = text.substring(j + 1);
+ }
+ }
try {
Integer.valueOf(proxyPort);
} catch (NumberFormatException e) {
throw new BadCommandLineException(Messages.format(Messages.ILLEGAL_PROXY,text));
}
@@ -809,15 +816,13 @@
Messages.format(Messages.MISSING_PROXYHOST));
} else {
throw new BadCommandLineException(
Messages.format(Messages.MISSING_PROXYPORT));
}
- if(proxyUser!=null)
- System.setProperty("http.proxyUser", proxyUser);
- if(proxyPassword!=null)
- System.setProperty("http.proxyPassword", proxyPassword);
-
+ if (proxyAuth != null) {
+ DefaultAuthenticator.getAuthenticator().setProxyAuth(proxyAuth);
+ }
}
if (grammars.isEmpty())
throw new BadCommandLineException(
Messages.format(Messages.MISSING_GRAMMAR));