View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.support.editor.inspectors.aut;
14  
15  import java.awt.BorderLayout;
16  
17  import javax.swing.JComponent;
18  import javax.swing.JPanel;
19  import javax.swing.JScrollPane;
20  
21  import com.eviware.soapui.impl.support.AbstractHttpRequest;
22  import com.eviware.soapui.impl.wsdl.WsdlRequest;
23  import com.eviware.soapui.support.components.SimpleBindingForm;
24  import com.eviware.soapui.support.editor.EditorView;
25  import com.eviware.soapui.support.editor.inspectors.AbstractXmlInspector;
26  import com.eviware.soapui.support.editor.views.xml.raw.RawXmlEditorFactory;
27  import com.eviware.soapui.support.editor.xml.XmlDocument;
28  import com.eviware.soapui.support.types.StringList;
29  import com.jgoodies.binding.PresentationModel;
30  
31  public class RequestAutInspector extends AbstractXmlInspector
32  {
33  	private JPanel mainPanel;
34  	private final AbstractHttpRequest<?> request;
35  	private SimpleBindingForm form;
36  
37  	protected RequestAutInspector( AbstractHttpRequest<?> request )
38  	{
39  		super( "Aut", "Authentication and Security-related settings", true, AutInspectorFactory.INSPECTOR_ID );
40  		this.request = request;
41  	}
42  
43  	public JComponent getComponent()
44  	{
45  		if( mainPanel == null )
46  		{
47  			mainPanel = new JPanel( new BorderLayout() );
48  
49  			form = new SimpleBindingForm( new PresentationModel<AbstractHttpRequest<?>>( request ) );
50  			form.addSpace( 5 );
51  			form.appendTextField( "username", "Username", "The username to use for HTTP Authentication" );
52  			form.appendTextField( "password", "Password", "The password to use for HTTP Authentication" );
53  			form.appendTextField( "domain", "Domain", "The domain to use for HTTP Authentication" );
54  
55  			if( request instanceof WsdlRequest )
56  			{
57  				StringList outgoingNames = new StringList( request.getOperation().getInterface().getProject()
58  						.getWssContainer().getOutgoingWssNames() );
59  				outgoingNames.add( "" );
60  				StringList incomingNames = new StringList( request.getOperation().getInterface().getProject()
61  						.getWssContainer().getIncomingWssNames() );
62  				incomingNames.add( "" );
63  
64  				form.addSpace( 5 );
65  				form.appendComboBox( "outgoingWss", "Outgoing WSS", outgoingNames.toStringArray(),
66  						"The outgoing WS-Security configuration to use" );
67  				form.appendComboBox( "incomingWss", "Incoming WSS", incomingNames.toStringArray(),
68  						"The incoming WS-Security configuration to use" );
69  			}
70  
71  			form.addSpace( 5 );
72  
73  			mainPanel.add( new JScrollPane( form.getPanel() ), BorderLayout.CENTER );
74  		}
75  
76  		return mainPanel;
77  	}
78  
79  	@Override
80  	public boolean isEnabledFor( EditorView<XmlDocument> view )
81  	{
82  		return !view.getViewId().equals( RawXmlEditorFactory.VIEW_ID );
83  	}
84  }