Author: bfitzpat
Date: 2010-08-05 13:19:10 -0400 (Thu, 05 Aug 2010)
New Revision: 23949
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/UidPwdDialog.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXRSTester.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester2.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java
Log:
OPEN - issue JBIDE-6660: [tester] does not handle password protected services
https://jira.jboss.org/browse/JBIDE-6660
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2010-08-05 17:13:27 UTC
(rev 23948)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2010-08-05 17:19:10 UTC
(rev 23949)
@@ -34,7 +34,8 @@
org.eclipse.ui.forms,
org.eclipse.emf.common,
org.eclipse.jdt.ui,
- org.eclipse.osgi
+ org.eclipse.osgi,
+ org.apache.commons.codec
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.ui,
org.jboss.tools.ws.ui.messages,
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-08-05
17:13:27 UTC (rev 23948)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2010-08-05
17:19:10 UTC (rev 23949)
@@ -156,3 +156,7 @@
DelimitedStringList_Msg_Yes_Btn=Yes
DelimitedStringList_NO_COMMAS_WARNING=There are no commas delimiting the name and value
for this key/value pair.
DelimitedStringList_NO_EQUALS_DELIMITER_WARNING=Parameters should be in
'name=value' format.
+UidPwdDialog_Description=Specify the user name and password to access this web service
via basic authentication.
+UidPwdDialog_PWD_Label=Password:
+UidPwdDialog_Title=User Name/ Password
+UidPwdDialog_UID_Label=User Name:
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-08-05
17:13:27 UTC (rev 23948)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2010-08-05
17:19:10 UTC (rev 23949)
@@ -156,6 +156,10 @@
public static String JAXRSWSTestView2_Title_Msg_May_Be_Out_of_Date;
public static String ResultsXMLStorageInput_WS_Invocation_Results_Prefix;
+ public static String UidPwdDialog_Description;
+ public static String UidPwdDialog_PWD_Label;
+ public static String UidPwdDialog_Title;
+ public static String UidPwdDialog_UID_Label;
public static String WSDLBrowseDialog_Dialog_Title;
public static String WSDLBrowseDialog_Error_Msg_Invalid_URL;
public static String WSDLBrowseDialog_Error_Msg_Parse_Error;
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXRSTester.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXRSTester.java 2010-08-05
17:13:27 UTC (rev 23948)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXRSTester.java 2010-08-05
17:19:10 UTC (rev 23949)
@@ -24,6 +24,8 @@
import java.util.Map;
import java.util.Map.Entry;
+import org.apache.commons.codec.binary.Base64;
+
/**
* Tester class for JAX-RS services
* @author bfitzpat
@@ -96,7 +98,7 @@
* @throws Exception
*/
public void doTest (String address, Map<String, String> parameters,
Map<String, String> headers) throws Exception {
- doTest(address, parameters, headers, "GET", null, null, 0);
//$NON-NLS-1$
+ doTest(address, parameters, headers, "GET", null, null, 0, null, null);
//$NON-NLS-1$
}
/**
@@ -109,7 +111,7 @@
* @throws Exception
*/
public void doTest (String address, Map<String, String> parameters,
Map<String, String> headers, String methodType, String requestBody) throws Exception
{
- doTest (address, parameters, headers, methodType, requestBody, null, 0);
+ doTest (address, parameters, headers, methodType, requestBody, null, 0, null,
null);
}
/**
@@ -124,7 +126,7 @@
* @throws Exception
*/
public void doTest(String address, Map<String, String> parameters,
Map<String, String> headers, String methodType, String requestBody, String proxy,
String port) throws Exception {
- doTest(address, parameters, headers, methodType, requestBody, proxy,
Integer.parseInt(port));
+ doTest(address, parameters, headers, methodType, requestBody, proxy,
Integer.parseInt(port), null, null);
}
/**
@@ -138,7 +140,7 @@
* @param port
* @throws Exception
*/
- public void doTest(String address, Map<String, String> parameters,
Map<String, String> headers, String methodType, String requestBody, String proxy,
int port) throws Exception {
+ public void doTest(String address, Map<String, String> parameters,
Map<String, String> headers, String methodType, String requestBody, String proxy,
int port, String uid, String pwd) throws Exception {
// handle the proxy
Proxy proxyObject = null;
@@ -210,6 +212,14 @@
}
}
+ // if we have basic authentication to add, add it!
+ if (uid != null && pwd != null) {
+ String authStr = uid + ':' + pwd;
+ byte[] authEncByte = Base64.encodeBase64(authStr.getBytes());
+ String authStringEnc = new String(authEncByte);
+ httpurlc.addRequestProperty("Authorization", "Basic " +
authStringEnc); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
requestHeaders = httpurlc.getRequestProperties();
// Check if task has been interrupted
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester2.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester2.java 2010-08-05
17:13:27 UTC (rev 23948)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/utils/JAXWSTester2.java 2010-08-05
17:19:10 UTC (rev 23949)
@@ -76,6 +76,10 @@
return this.resultSOAP;
}
+ public void doTest( IProgressMonitor monitor, String endpointurl, String actionurl,
String ns,
+ String serviceName, String messageName, String body ) throws Exception {
+ doTest(monitor, endpointurl, actionurl, ns, serviceName, messageName, body, null,
null);
+ }
/**
* Invoke the JAX-WS service
* @param endpointurl
@@ -85,7 +89,7 @@
*/
@SuppressWarnings("unchecked")
public void doTest( IProgressMonitor monitor, String endpointurl, String actionurl,
String ns,
- String serviceName, String messageName, String body ) throws Exception {
+ String serviceName, String messageName, String body, String uid, String pwd ) throws
Exception {
this.resultBody = EMPTY_STRING;
@@ -105,7 +109,13 @@
d.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
d.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, actionurl);
//"http://www.ecubicle.net/webservices/GetSearchResults");
}
-
+
+ if (uid != null && pwd != null) {
+ Map<String, Object> requestContext = d.getRequestContext();
+ requestContext.put(BindingProvider.USERNAME_PROPERTY, uid);
+ requestContext.put(BindingProvider.PASSWORD_PROPERTY, pwd);
+ }
+
SOAPMessage m = mf.createMessage( null, new ByteArrayInputStream(body.getBytes()));
m.saveChanges();
Modified:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java 2010-08-05
17:13:27 UTC (rev 23948)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java 2010-08-05
17:19:10 UTC (rev 23949)
@@ -533,6 +533,14 @@
urlCombo.setLayoutData(gdURL);
toolkit.adapt(urlCombo);
+ urlCombo.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ setControlsForSelectedURL();
+ getCurrentHistoryEntry().setUrl(urlCombo.getText());
+ getCurrentHistoryEntry().setAction(null);
+ }
+ });
urlCombo.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
}
@@ -1153,23 +1161,30 @@
final String method = getCurrentHistoryEntry().getMethod();
final String headers = getCurrentHistoryEntry().getHeaders();
final String parms = getCurrentHistoryEntry().getParms();
+
+ String tempUID = null;
+ String tempPwd = null;
+ // temp workaround to handle JAX-RS authenticated services
+ if (wsTech.contentEquals(JAX_RS) && url.startsWith("https")) {
//$NON-NLS-1$
+ UidPwdDialog authDialog = new UidPwdDialog(getSite().getShell());
+ int rtnCode = authDialog.open();
+ if (rtnCode == Window.OK) {
+ tempUID = authDialog.getUID();
+ tempPwd = authDialog.getPwd();
+ }
+ }
+ final String uid = tempUID;
+ final String pwd = tempPwd;
-// final String url = urlCombo.getText();
-// final String action = actionText;
-// final String body = bodyText.getText();
-// final String method = methodCombo.getText();
-// final String headers = dlsList.getSelection();
-// final String parms = parmsList.getSelection();
-
Job aJob = new Job(JBossWSUIMessages.JAXRSWSTestView_Invoking_WS_Status) {
protected IStatus run(IProgressMonitor monitor) {
IStatus status = Status.OK_STATUS;
// execute the task ...
if (wsTech.equalsIgnoreCase(JAX_RS)) {
- status = handleRSTest(monitor, url, method, body, parms, headers);
+ status = handleRSTest(monitor, url, method, body, parms, headers, uid, pwd);
}
else if (wsTech.equalsIgnoreCase(JAX_WS)) {
- status = handleWSTest(monitor, url, action, body);
+ status = handleWSTest(monitor, url, action, body, uid, pwd);
}
monitor.done();
return status;
@@ -1225,7 +1240,7 @@
/*
* Actually call the WS and displays the result
*/
- private IStatus handleWSTest(final IProgressMonitor monitor, String url, String action,
String body) {
+ private IStatus handleWSTest(final IProgressMonitor monitor, String url, String action,
String body, String uid, String pwd) {
try {
envelope = null;
@@ -1239,7 +1254,7 @@
if (!itRan && serviceNSMessage != null && serviceNSMessage.length ==
3) {
itRan = true;
// call the service
- tester.doTest(monitor, url, action, serviceNSMessage[0], serviceNSMessage[1],
serviceNSMessage[2], body);
+ tester.doTest(monitor, url, action, serviceNSMessage[0], serviceNSMessage[1],
serviceNSMessage[2], body, uid, pwd);
} else {
break;
}
@@ -1303,7 +1318,7 @@
/*
* Actually call the RESTful WS to test it
*/
- private IStatus handleRSTest(final IProgressMonitor monitor, String address, String
method, String body, String parms, String headersStr) {
+ private IStatus handleRSTest(final IProgressMonitor monitor, String address, String
method, String body, String parms, String headersStr, String uid, String pwd) {
if (method.equalsIgnoreCase(GET))
body = EMPTY_STRING;
@@ -1350,7 +1365,7 @@
try {
// call the service
- tester.doTest(address, parameters, headers, method, body);
+ tester.doTest(address, parameters, headers, method, body, null, -1, uid, pwd);
String result = tester.getResultBody();
Added:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/UidPwdDialog.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/UidPwdDialog.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/UidPwdDialog.java 2010-08-05
17:19:10 UTC (rev 23949)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.views;
+
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+/**
+ * Simple UID/PWD dialog for authentication
+ * @author bfitzpat
+ *
+ */
+public class UidPwdDialog extends TitleAreaDialog {
+ private Text uidText;
+ private Text pwdText;
+
+ private static String uid;
+ private static String pwd;
+
+ public UidPwdDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ setTitle(JBossWSUIMessages.UidPwdDialog_Title);
+ setMessage(JBossWSUIMessages.UidPwdDialog_Description);
+
+ Composite comp = new Composite (parent,SWT.NONE);
+
+ GridLayout layout = new GridLayout(2, false);
+ GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gridData.horizontalSpan = 2;
+ comp.setLayoutData(gridData);
+ comp.setLayout(layout);
+
+ Label usernameLabel = new Label(comp, SWT.RIGHT);
+ usernameLabel.setText(JBossWSUIMessages.UidPwdDialog_UID_Label);
+
+ uidText = new Text(comp, SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ uidText.setLayoutData(data);
+ if (uid != null && uid.trim().length() > 0) {
+ uidText.setText(uid);
+ }
+ uidText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ uid = uidText.getText();
+ }
+ });
+
+ Label passwordLabel = new Label(comp, SWT.RIGHT);
+ passwordLabel.setText(JBossWSUIMessages.UidPwdDialog_PWD_Label);
+
+ pwdText = new Text(comp, SWT.SINGLE | SWT.PASSWORD | SWT.BORDER);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ pwdText.setLayoutData(data);
+ if (pwd != null && pwd.trim().length() > 0) {
+ pwdText.setText(pwd);
+ }
+ pwdText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ pwd = pwdText.getText();
+ }
+ });
+
+ return comp;
+ }
+
+ public String getUID() {
+ return uid;
+ }
+
+ public String getPwd() {
+ return pwd;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/views/UidPwdDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain