You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2012/04/13 14:27:49 UTC
svn commit: r1325736 - in /axis/axis2/java/core/trunk/modules:
codegen/src/org/apache/axis2/wsdl/ codegen/src/org/apache/axis2/wsdl/i18n/
codegen/src/org/apache/axis2/wsdl/util/ kernel/src/org/apache/axis2/util/
Author: sagara
Date: Fri Apr 13 12:27:49 2012
New Revision: 1325736
URL: http://svn.apache.org/viewvc?rev=1325736&view=rev
Log:
Fixed AXIS2-4060.
Introduced two new command line parameters as http-proxy-user and http-proxy-password.
Modified:
axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/WSDL2Code.java
axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/CommandLineOptionConstants.java
Modified: axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/WSDL2Code.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/WSDL2Code.java?rev=1325736&r1=1325735&r2=1325736&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/WSDL2Code.java (original)
+++ axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/WSDL2Code.java Fri Apr 13 12:27:49 2012
@@ -19,6 +19,10 @@
package org.apache.axis2.wsdl;
+import java.net.Authenticator;
+import java.net.MalformedURLException;
+import java.net.PasswordAuthentication;
+import java.net.URL;
import java.util.Map;
import org.apache.axis2.util.CommandLineOption;
@@ -35,6 +39,7 @@ public class WSDL2Code {
public static void main(String[] args) throws Exception {
CommandLineOptionParser commandLineOptionParser = new CommandLineOptionParser(
args);
+ checkAuthentication(commandLineOptionParser);
//If it is a JAX-WS code generation request call WSimportTool.
if (isJwsOptionEnabled(commandLineOptionParser)){
new JAXWSCodeGenerationEngine(commandLineOptionParser, args).generate();
@@ -51,7 +56,7 @@ public class WSDL2Code {
System.out.println(CodegenMessages.getMessage("wsdl2code.arg"));
System.out.println(CodegenMessages.getMessage("wsdl2code.arg1"));
- for (int i = 2; i <= 50; i++) {
+ for (int i = 2; i <= 52; i++) {
System.out.println(" " + CodegenMessages.getMessage("wsdl2code.arg" + i));
}
}
@@ -78,4 +83,62 @@ public class WSDL2Code {
}
return true;
}
+
+ private static void checkAuthentication(CommandLineOptionParser commandLineOptionParser) {
+
+ String userName = null;
+ String password = null;
+
+ Map allOptions = commandLineOptionParser.getAllOptions();
+ CommandLineOption userOption = (CommandLineOption) allOptions
+ .get(CommandLineOptionConstants.WSDL2JavaConstants.HTTP_PROXY_USER_OPTION_LONG);
+ CommandLineOption passwordOption = (CommandLineOption) allOptions
+ .get(CommandLineOptionConstants.WSDL2JavaConstants.HTTP_PROXY_PASSWORD_OPTION_LONG);
+ CommandLineOption urlOption = (CommandLineOption) allOptions
+ .get(CommandLineOptionConstants.WSDL2JavaConstants.WSDL_LOCATION_URI_OPTION);
+
+ if(urlOption == null){
+ return;
+ }
+ if (userOption != null) {
+ userName = userOption.getOptionValue();
+ }
+ if (passwordOption != null) {
+ password = passwordOption.getOptionValue();
+
+ }
+ if (userName == null) {
+ // Try to collect user name and password from UserInfo part of the URL.
+ URL url = null;
+ try {
+ url = new URL(urlOption.getOptionValue());
+ } catch (MalformedURLException e) {
+ return;
+ }
+
+ String userInfo = url.getUserInfo();
+ if (userInfo != null) {
+ int i = userInfo.indexOf(':');
+
+ if (i >= 0) {
+ userName = userInfo.substring(0, i);
+ password = userInfo.substring(i + 1);
+ } else {
+ userName = userInfo;
+ }
+ }
+
+ }
+
+ if (userName != null) {
+ final String user = userName;
+ final String pass = password == null ? "" : password;
+ Authenticator.setDefault(new Authenticator() {
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(user, pass.toCharArray());
+ }
+ });
+ }
+ }
+
}
Modified: axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties?rev=1325736&r1=1325735&r2=1325736&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties (original)
+++ axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties Fri Apr 13 12:27:49 2012
@@ -79,12 +79,14 @@ wsdl2code.arg41= --noWSDL
wsdl2code.arg42= --noMessageReceiver Don't generate a MessageReceiver in the generated sources
wsdl2code.arg43= --http-proxy-host <host> Proxy host address if you are behind a firewall
wsdl2code.arg44= --http-proxy-port <port> Proxy port address if you are behind a firewall
-wsdl2code.arg45= -ep <package-name-list> Exclude packages - these packages are deleted after code generation
-wsdl2code.arg46= -sin <interface-name> Skeleton interface name - used to specify a name for skeleton interface other than the default one
-wsdl2code.arg47= -scn <class-name> Skeleton class name - used to specify a name for skeleton class other than the default one
-wsdl2code.arg48= -oaa <override-absolute-address> -change the absolute http addresses to local file addresses generated by wsdl2java tool
-wsdl2code.arg49= -ebc <exception-base-class> -generated Exceptions are inherited from this exception rather than the java.lang.Exception class
-wsdl2code.arg50= -uon <use-operation-name> -by default the first letter of the generated method name changeed to lowercase. This option stops that and make it same as operation name
+wsdl2code.arg45= -http-proxy-user <user name> Proxy user name for basic authentication if you are behind a firewall
+wsdl2code.arg46= -http-proxy-password <password> Proxy password for basic authentication if you are behind a firewall
+wsdl2code.arg47= -ep <package-name-list> Exclude packages - these packages are deleted after code generation
+wsdl2code.arg48= -sin <interface-name> Skeleton interface name - used to specify a name for skeleton interface other than the default one
+wsdl2code.arg49= -scn <class-name> Skeleton class name - used to specify a name for skeleton class other than the default one
+wsdl2code.arg50= -oaa <override-absolute-address> -change the absolute http addresses to local file addresses generated by wsdl2java tool
+wsdl2code.arg51= -ebc <exception-base-class> -generated Exceptions are inherited from this exception rather than the java.lang.Exception class
+wsdl2code.arg52= -uon <use-operation-name> -by default the first letter of the generated method name changeed to lowercase. This option stops that and make it same as operation name
################## prop file loader #################################
propfileload.frameworkMismatch=Number of frameworks and extension names do not match!
Modified: axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java?rev=1325736&r1=1325735&r2=1325736&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java (original)
+++ axis/axis2/java/core/trunk/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java Fri Apr 13 12:27:49 2012
@@ -107,7 +107,10 @@ public class WSDL2JavaOptionsValidator i
XMLBeansExtension.XSDCONFIG_OPTION.equalsIgnoreCase(optionType) ||
XMLBeansExtension.XSDCONFIG_OPTION_LONG.equalsIgnoreCase(optionType) ||
WSDL2JavaConstants.JAX_WS_SERVICE_OPTION.equalsIgnoreCase(optionType) ||
- WSDL2JavaConstants.JAX_WS_SERVICE_OPTION_LONG.equalsIgnoreCase(optionType)
+ WSDL2JavaConstants.JAX_WS_SERVICE_OPTION_LONG.equalsIgnoreCase(optionType) ||
+ WSDL2JavaConstants.HTTP_PROXY_USER_OPTION_LONG.equalsIgnoreCase(optionType) ||
+ WSDL2JavaConstants.HTTP_PROXY_PASSWORD_OPTION_LONG.equalsIgnoreCase(optionType)
+
);
}
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/CommandLineOptionConstants.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/CommandLineOptionConstants.java?rev=1325736&r1=1325735&r2=1325736&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/CommandLineOptionConstants.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/util/CommandLineOptionConstants.java Fri Apr 13 12:27:49 2012
@@ -84,6 +84,8 @@ public interface CommandLineOptionConsta
String WSDL_VERSION_OPTION_LONG = "wsdl-version";
String HTTP_PROXY_HOST_OPTION_LONG = "http-proxy-host";
String HTTP_PROXY_PORT_OPTION_LONG = "http-proxy-port";
+ String HTTP_PROXY_USER_OPTION_LONG = "http-proxy-user";
+ String HTTP_PROXY_PASSWORD_OPTION_LONG = "http-proxy-password";
String EXCLUDE_PAKAGES_OPTION = "ep";
String EXCLUDE_PAKAGES_OPTION_LONG = "exclude-packages";
String SKELTON_INTERFACE_NAME_OPTION = "sin";