src/share/jaxws_classes/com/sun/tools/internal/ws/wscompile/WsimportOptions.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2012, 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

@@ -60,10 +60,12 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.HashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * @author Vivek Pandey
  */
 public class WsimportOptions extends Options {

@@ -137,18 +139,27 @@
     private SchemaCompiler schemaCompiler = XJC.createSchemaCompiler();
 
     /**
      * Authentication file
      */
-    public File authFile;
+    public File authFile = null;
+
+    //can user.home value be null?
+    public static final String defaultAuthfile
+            = System.getProperty("user.home") + System.getProperty("file.separator")
+            + ".metro" + System.getProperty("file.separator") + "auth";
 
     /**
      * Setting disableAuthenticator to true disables the DefaultAuthenticator.
      * -XdisableAuthenticator
      */
     public boolean disableAuthenticator;
 
+    public String proxyAuth = null;
+    private String proxyHost = null;
+    private String proxyPort = null;
+
     /**
      * Additional arguments
      */
     public HashMap<String, String> extensionOptions = new HashMap<String, String>();
 

@@ -238,10 +249,20 @@
                 } else{
                     addFile(args[i]);
                 }
             }
         }
+
+        if (encoding != null && schemaCompiler.getOptions().encoding == null) {
+            try {
+                schemaCompiler.getOptions().parseArgument(
+                        new String[] {"-encoding", encoding}, 0);
+            } catch (com.sun.tools.internal.xjc.BadCommandLineException ex) {
+                Logger.getLogger(WsimportOptions.class.getName()).log(Level.SEVERE, null, ex);
+            }
+        }
+
         if(destDir == null)
             destDir = new File(".");
         if(sourceDir == null)
             sourceDir = destDir;
     }

@@ -290,19 +311,19 @@
         } else if (args[i].startsWith("-httpproxy:")) {
             String value = args[i].substring(11);
             if (value.length() == 0) {
                 throw new BadCommandLineException(WscompileMessages.WSCOMPILE_INVALID_OPTION(args[i]));
             }
-            int index = value.indexOf(':');
-            if (index == -1) {
-                System.setProperty("proxySet", "true");
-                System.setProperty("proxyHost", value);
-                System.setProperty("proxyPort", "8080");
-            } else {
+            parseProxy(value);
+            if (proxyHost != null || proxyPort != null) {
                 System.setProperty("proxySet", "true");
-                System.setProperty("proxyHost", value.substring(0, index));
-                System.setProperty("proxyPort", value.substring(index + 1));
+            }
+            if (proxyHost != null) {
+                System.setProperty("proxyHost", proxyHost);
+            }
+            if (proxyPort != null) {
+                System.setProperty("proxyPort", proxyPort);
             }
             return 1;
         } else if (args[i].equals("-Xno-addressing-databinding")) {
             noAddressingBbinding = true;
             return 1;

@@ -574,10 +595,41 @@
      */
     public String getExtensionOption(String argument) {
         return extensionOptions.get(argument);
     }
 
+    private void parseProxy(String text) throws BadCommandLineException {
+        int i = text.lastIndexOf('@');
+        int j = text.lastIndexOf(':');
+
+        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 = "8080";
+            }
+        } else {
+            //no auth info
+            if (j < 0) {
+                //no port
+                proxyHost = text;
+                proxyPort = "8080";
+            } else {
+                proxyHost = text.substring(0, j);
+                proxyPort = text.substring(j + 1);
+            }
+        }
+        try {
+            Integer.valueOf(proxyPort);
+        } catch (NumberFormatException e) {
+            throw new BadCommandLineException(WscompileMessages.WSIMPORT_ILLEGAL_PROXY(text));
+        }
+    }
+
     /**
      * Looks for all "META-INF/services/[className]" files and
      * create one instance for each class name found inside this file.
      */
     private static <T> T[] findServices(Class<T> clazz, ClassLoader classLoader) {