View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2008 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 com.eviware.soapui.impl.support.AbstractHttpRequest;
16  import com.eviware.soapui.impl.wsdl.WsdlRequest;
17  import com.eviware.soapui.support.components.SimpleBindingForm;
18  import com.eviware.soapui.support.editor.EditorView;
19  import com.eviware.soapui.support.editor.inspectors.AbstractXmlInspector;
20  import com.eviware.soapui.support.editor.views.xml.raw.RawXmlEditorFactory;
21  import com.eviware.soapui.support.editor.xml.XmlDocument;
22  import com.eviware.soapui.support.types.StringList;
23  import com.jgoodies.binding.PresentationModel;
24  
25  import javax.swing.*;
26  import java.awt.*;
27  
28  public class RequestAutInspector extends AbstractXmlInspector
29  {
30  	private JPanel mainPanel;
31  	private final AbstractHttpRequest<?> request;
32  	private SimpleBindingForm form;
33  
34  	protected RequestAutInspector( AbstractHttpRequest<?> request )
35  	{
36  		super( "Aut", "Authentication and Security-related settings", true, AutInspectorFactory.INSPECTOR_ID );
37  		this.request = request;
38  	}
39  
40  	public JComponent getComponent()
41  	{
42  		if( mainPanel == null )
43  		{
44  			mainPanel = new JPanel( new BorderLayout() );
45  
46  			form = new SimpleBindingForm( new PresentationModel<AbstractHttpRequest<?>>( request ) );
47  			form.addSpace( 5 );
48  			form.appendTextField( "username", "Username", "The username to use for HTTP Authentication" );
49  			form.appendTextField( "password", "Password", "The password to use for HTTP Authentication" );
50  			form.appendTextField( "domain", "Domain", "The domain to use for HTTP Authentication" );
51  
52  			if( request instanceof WsdlRequest )
53  			{
54              StringList outgoingNames = new StringList( request.getOperation().getInterface().getProject()
55  						.getWssContainer().getOutgoingWssNames() );
56              outgoingNames.add( "" );
57              StringList incomingNames = new StringList( request.getOperation().getInterface().getProject()
58                       .getWssContainer().getIncomingWssNames() );
59              incomingNames.add( "" );
60  
61              form.addSpace( 5 );
62  				form.appendComboBox( "outgoingWss", "Outgoing WSS", outgoingNames.toStringArray(),
63  							"The outgoing WS-Security configuration to use" );
64  				form.appendComboBox( "incomingWss", "Incoming WSS", incomingNames.toStringArray(),
65  							"The incoming WS-Security configuration to use" );
66  			}
67  			
68  			form.addSpace( 5 );
69  			
70  			mainPanel.add( new JScrollPane( form.getPanel() ), BorderLayout.CENTER );
71  		}
72  
73  		return mainPanel;
74  	}
75  	
76  	@Override
77  	public boolean isEnabledFor( EditorView<XmlDocument> view )
78  	{
79  		return !view.getViewId().equals( RawXmlEditorFactory.VIEW_ID );
80  	}
81  }