You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-dev@ws.apache.org by ow...@apache.org on 2003/03/06 17:29:03 UTC
cvs commit: xml-axis-wsif/java/src/org/apache/wsif/wsdl AuthenticatingProxyWSDLLocatorImpl.java
owenb 2003/03/06 08:29:03
Modified: java/src/org/apache/wsif/wsdl
AuthenticatingProxyWSDLLocatorImpl.java
Log:
Add new constructor that takes a java.net.PasswordAuthentication object encapsulating the username and password
Revision Changes Path
1.8 +27 -6 xml-axis-wsif/java/src/org/apache/wsif/wsdl/AuthenticatingProxyWSDLLocatorImpl.java
Index: AuthenticatingProxyWSDLLocatorImpl.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/wsdl/AuthenticatingProxyWSDLLocatorImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AuthenticatingProxyWSDLLocatorImpl.java 26 Feb 2003 15:55:21 -0000 1.7
+++ AuthenticatingProxyWSDLLocatorImpl.java 6 Mar 2003 16:29:03 -0000 1.8
@@ -62,6 +62,7 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
+import java.net.PasswordAuthentication;
import java.net.URL;
import java.net.URLConnection;
@@ -95,8 +96,7 @@
String documentBase = "";
String importBase = "";
String wsdlLocation = "";
- String username = null;
- String password = null;
+ PasswordAuthentication passwdAuth = null;
String authString = null;
/**
@@ -117,8 +117,27 @@
+ "only supports http and ftp urls for base wsdl locations");
}
this.wsdlLocation = wsdlLoc;
- this.username = un;
- this.password = passwd;
+ passwdAuth = new PasswordAuthentication(un, passwd.toCharArray());
+ }
+
+ /**
+ * Create an instance of AuthenticatingProxyWSDLLocatorImpl.
+ * @param wsdlLoc The uri for the base wsdl document
+ * @param pa Username and password encapsulated in a java.net.PasswordAuthentication
+ */
+ public AuthenticatingProxyWSDLLocatorImpl(String wsdlLoc, PasswordAuthentication pa)
+ throws WSDLException {
+
+ if (wsdlLoc == null
+ || (wsdlLoc.indexOf("http://") == -1
+ && wsdlLoc.indexOf("ftp://") == -1)) {
+ throw new WSDLException(
+ WSDLException.OTHER_ERROR,
+ "Base wsdl location type not supported. The AuthenticatingProxyWSDLLocatorImpl class "
+ + "only supports http and ftp urls for base wsdl locations");
+ }
+ this.wsdlLocation = wsdlLoc;
+ passwdAuth = pa;
}
/**
@@ -206,12 +225,14 @@
if (authString != null)
return;
// Unless all information is provided we can't create the String
- if (username == null || password == null)
+ String username = passwdAuth.getUserName();
+ char[] passwd = passwdAuth.getPassword();
+ if (username == null || passwd == null)
return;
byte[] data = null;
try {
- data = (username + ":" + password).getBytes("8859_1");
+ data = (username + ":" + passwd.toString()).getBytes("8859_1");
} catch (UnsupportedEncodingException uee) {
return;
}