1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.panels.project;
14
15 import com.eviware.soapui.SoapUI;
16 import com.eviware.soapui.impl.WorkspaceImpl;
17 import com.eviware.soapui.impl.support.actions.ShowOnlineHelpAction;
18 import com.eviware.soapui.impl.wsdl.WsdlProject;
19 import com.eviware.soapui.impl.wsdl.support.HelpUrls;
20 import com.eviware.soapui.impl.wsdl.support.wss.*;
21 import com.eviware.soapui.impl.wsdl.support.wss.crypto.KeyMaterialWssCrypto;
22 import com.eviware.soapui.impl.wsdl.support.wss.support.KeystoresComboBoxModel;
23 import com.eviware.soapui.model.support.ModelSupport;
24 import com.eviware.soapui.support.StringUtils;
25 import com.eviware.soapui.support.UISupport;
26 import com.eviware.soapui.support.components.JXToolBar;
27
28 import javax.swing.*;
29 import javax.swing.event.ChangeEvent;
30 import javax.swing.event.ChangeListener;
31 import javax.swing.event.ListSelectionEvent;
32 import javax.swing.event.ListSelectionListener;
33 import javax.swing.table.AbstractTableModel;
34 import javax.swing.table.TableCellRenderer;
35 import java.awt.*;
36 import java.awt.event.ActionEvent;
37 import java.io.File;
38 import java.util.List;
39
40 public class WSSTabPanel extends JPanel
41 {
42 private JTable cryptosTable;
43 private RemoveCryptoAction removeCryptoAction;
44 private RemoveIncomingWssAction removeIncomingWssAction;
45 private JTable incomingWssTable;
46 private JComboBox incomingWssDecryptionCryptoComboBox;
47 private JComboBox incomingWssSignatureCryptoComboBox;
48 private JTable outgoingWssTable;
49 private RemoveOutgoingWssAction removeOutgoingWssAction;
50
51 private JButton removeOutgoingEntryButton;
52
53
54 private WssEntry selectedEntry;
55 private OutgoingWss selectedOutgoing;
56 private JButton addOutgoingEntryButton;
57 private final WssContainer wssContainer;
58 private InternalWssContainerListener wssContainerListener;
59 private JTabbedPane entriesTabs;
60
61 public WSSTabPanel( WssContainer wssContainer )
62 {
63 super( new BorderLayout() );
64 this.wssContainer = wssContainer;
65
66 wssContainerListener = new InternalWssContainerListener();
67 wssContainer.addWssContainerListener( wssContainerListener );
68
69 buildUI();
70 }
71
72 private void buildUI()
73 {
74 add( buildMainToolbar(), BorderLayout.NORTH );
75 add( buildContent(), BorderLayout.CENTER );
76 }
77
78 private JComponent buildContent()
79 {
80 JTabbedPane tabs = new JTabbedPane();
81 tabs.addTab( "Outgoing WS-Security Configurations", buildOutgoingConfigurationsTab() );
82 tabs.addTab( "Incoming WS-Security Configurations", buildIncomingConfigurationsTab() );
83 tabs.addTab( "Keystores / Certificates", buildCryptosTable() );
84
85 tabs.setMinimumSize( new Dimension( 10, 10 ) );
86
87 return UISupport.createTabPanel( tabs, true );
88 }
89
90 private JPanel buildIncomingConfigurationsTab()
91 {
92 JPanel panel = new JPanel( new BorderLayout() );
93
94 JPanel p = new JPanel( new BorderLayout() );
95 p.add( buildIncomingWssToolbar(), BorderLayout.NORTH );
96
97 incomingWssTable = new JTable( new IncomingWssTableModel() );
98 incomingWssTable.getSelectionModel().addListSelectionListener( new ListSelectionListener()
99 {
100
101 public void valueChanged( ListSelectionEvent e )
102 {
103 removeIncomingWssAction.setEnabled( incomingWssTable.getSelectedRow() != -1 );
104 }
105 } );
106
107 incomingWssDecryptionCryptoComboBox = new JComboBox( new KeystoresComboBoxModel( wssContainer, null ) );
108 incomingWssTable.getColumnModel().getColumn( 1 ).setCellEditor( new DefaultCellEditor( incomingWssDecryptionCryptoComboBox ) );
109
110 incomingWssSignatureCryptoComboBox = new JComboBox( new KeystoresComboBoxModel( wssContainer, null ) );
111 incomingWssTable.getColumnModel().getColumn( 2 ).setCellEditor( new DefaultCellEditor( incomingWssSignatureCryptoComboBox ) );
112
113 incomingWssTable.getColumnModel().getColumn( 3 ).setCellEditor( new DefaultCellEditor( new JPasswordField() ) );
114 incomingWssTable.getColumnModel().getColumn( 3 ).setCellRenderer( new PasswordTableCellRenderer() );
115
116 p.add( new JScrollPane( incomingWssTable ), BorderLayout.CENTER );
117 panel.add( p, BorderLayout.CENTER );
118 return panel;
119 }
120
121 private JPanel buildOutgoingConfigurationsTab()
122 {
123 JPanel panel = new JPanel( new BorderLayout() );
124
125 JPanel p = new JPanel( new BorderLayout() );
126 p.add( buildOutgoingWssToolbar(), BorderLayout.NORTH );
127
128 outgoingWssTable = new JTable( new OutgoingWssTableModel() );
129 outgoingWssTable.getSelectionModel().addListSelectionListener( new ListSelectionListener()
130 {
131
132 public void valueChanged( ListSelectionEvent e )
133 {
134 int selectedRow = outgoingWssTable.getSelectedRow();
135 selectedOutgoing = selectedRow == -1 ? null : wssContainer.getOutgoingWssAt( selectedRow );
136 removeOutgoingWssAction.setEnabled( selectedRow != -1 );
137 addOutgoingEntryButton.setEnabled( selectedRow != -1 );
138
139
140 entriesTabs.removeAll();
141 if( selectedOutgoing != null )
142 {
143 for( WssEntry entry : selectedOutgoing.getEntries() )
144 {
145 entriesTabs.addTab( entry.getLabel(), entry.getConfigurationPanel() );
146 }
147 }
148
149 entriesTabs.getParent().setVisible( entriesTabs.getTabCount() > 0 );
150 }
151 } );
152
153 outgoingWssTable.getColumnModel().getColumn( 2 ).setCellEditor( new DefaultCellEditor( new JPasswordField() ) );
154 outgoingWssTable.getColumnModel().getColumn( 2 ).setCellRenderer( new PasswordTableCellRenderer() );
155
156 JSplitPane split = UISupport.createVerticalSplit( new JScrollPane( outgoingWssTable ), buildOutgoingWssDetails() );
157 split.setDividerLocation( 140 );
158 p.add( split, BorderLayout.CENTER );
159 panel.add( p, BorderLayout.CENTER );
160 return panel;
161 }
162
163 private Component buildOutgoingWssDetails()
164 {
165 JPanel panel = new JPanel( new BorderLayout() );
166 panel.add( buildOutgoingEntriesToolbar(), BorderLayout.NORTH );
167 panel.add( buildOutgoingEntryList(), BorderLayout.CENTER );
168
169 entriesTabs.getParent().setVisible( false );
170
171
172
173
174
175
176 return panel;
177 }
178
179
180
181
182
183
184
185
186
187
188 private Component buildOutgoingEntryList()
189 {
190
191
192
193
194
195
196
197
198
199
200
201
202 entriesTabs = new JTabbedPane();
203 entriesTabs.addChangeListener( new ChangeListener()
204 {
205
206 public void stateChanged( ChangeEvent e )
207 {
208 selectedEntry = entriesTabs.getSelectedIndex() == -1 ? null :
209 selectedOutgoing.getEntries().get( entriesTabs.getSelectedIndex() );
210 removeOutgoingEntryButton.setEnabled( selectedEntry != null );
211 }
212 } );
213
214
215 return UISupport.createTabPanel( entriesTabs, true );
216 }
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234 private Component buildOutgoingEntriesToolbar()
235 {
236 JXToolBar toolbar = UISupport.createSmallToolbar();
237
238 toolbar.addFixed( addOutgoingEntryButton = UISupport.createToolbarButton( new AddOutgoingEntryAction() ) );
239 toolbar.addFixed( removeOutgoingEntryButton = UISupport.createToolbarButton( new RemoveOutgoingEntryAction(), false ) );
240
241 return toolbar;
242 }
243
244 private Component buildOutgoingWssToolbar()
245 {
246 JXToolBar toolbar = UISupport.createSmallToolbar();
247
248 toolbar.addFixed( UISupport.createToolbarButton( new AddOutgoingWssAction() ) );
249 removeOutgoingWssAction = new RemoveOutgoingWssAction();
250 toolbar.addFixed( UISupport.createToolbarButton( removeOutgoingWssAction ) );
251 toolbar.addGlue();
252 toolbar.addFixed( UISupport.createToolbarButton( new ShowOnlineHelpAction( HelpUrls.OUTGOINGWSS_HELP_URL ) ) );
253
254 return toolbar;
255 }
256
257 private JPanel buildCryptosTable()
258 {
259 JPanel panel = new JPanel( new BorderLayout() );
260 JPanel p = new JPanel( new BorderLayout() );
261
262 p.add( buildCryptosToolbar(), BorderLayout.NORTH );
263
264 cryptosTable = new JTable( new CryptosTableModel() );
265 cryptosTable.getSelectionModel().addListSelectionListener( new ListSelectionListener()
266 {
267
268 public void valueChanged( ListSelectionEvent e )
269 {
270 removeCryptoAction.setEnabled( cryptosTable.getSelectedRow() != -1 );
271 }
272 } );
273
274
275
276
277
278
279
280
281
282
283
284 cryptosTable.getColumnModel().getColumn( 2 ).setCellEditor( new DefaultCellEditor( new JPasswordField() ) );
285 cryptosTable.getColumnModel().getColumn( 2 ).setCellRenderer( new PasswordTableCellRenderer() );
286 cryptosTable.getColumnModel().getColumn( 4 ).setCellEditor( new DefaultCellEditor( new JPasswordField() ) );
287 cryptosTable.getColumnModel().getColumn( 4 ).setCellRenderer( new PasswordTableCellRenderer() );
288
289 p.add( new JScrollPane( cryptosTable ), BorderLayout.CENTER );
290
291 panel.add( p, BorderLayout.CENTER );
292 return panel;
293 }
294
295 private Component buildCryptosToolbar()
296 {
297 JXToolBar toolbar = UISupport.createSmallToolbar();
298
299 toolbar.addFixed( UISupport.createToolbarButton( new AddCryptoAction() ) );
300 removeCryptoAction = new RemoveCryptoAction();
301 toolbar.addFixed( UISupport.createToolbarButton( removeCryptoAction ) );
302 toolbar.addGlue();
303 toolbar.addFixed( UISupport.createToolbarButton( new ShowOnlineHelpAction( HelpUrls.CRYPTOSWSS_HELP_URL ) ) );
304 return toolbar;
305 }
306
307 private Component buildIncomingWssToolbar()
308 {
309 JXToolBar toolbar = UISupport.createSmallToolbar();
310
311 toolbar.addFixed( UISupport.createToolbarButton( new AddIncomingWssAction() ) );
312 removeIncomingWssAction = new RemoveIncomingWssAction();
313 toolbar.addFixed( UISupport.createToolbarButton( removeIncomingWssAction ) );
314
315 toolbar.addGlue();
316 toolbar.addFixed( UISupport.createToolbarButton( new ShowOnlineHelpAction( HelpUrls.INCOMINGWSS_HELP_URL ) ) );
317
318 return toolbar;
319 }
320
321 private Component buildMainToolbar()
322 {
323 JXToolBar toolbar = UISupport.createSmallToolbar();
324
325 toolbar.addGlue();
326 toolbar.addFixed( UISupport.createToolbarButton( new ShowOnlineHelpAction( HelpUrls.WSS_HELP_URL ) ) );
327 return toolbar;
328 }
329
330 public void release()
331 {
332 wssContainer.removeWssContainerListener( wssContainerListener );
333
334 ( (IncomingWssTableModel) incomingWssTable.getModel() ).release();
335 ( (OutgoingWssTableModel) outgoingWssTable.getModel() ).release();
336 ( (CryptosTableModel) cryptosTable.getModel() ).release();
337
338 ( (KeystoresComboBoxModel) incomingWssDecryptionCryptoComboBox.getModel() ).release();
339 ( (KeystoresComboBoxModel) incomingWssSignatureCryptoComboBox.getModel() ).release();
340
341 entriesTabs.removeAll();
342 }
343
344 public class CryptosTableModel extends AbstractTableModel
345 {
346 private static final String DEFAULT_OPTION = "<Default>";
347 private List<WssCrypto> cryptos;
348
349 public CryptosTableModel()
350 {
351 cryptos = wssContainer.getCryptoList();
352 }
353
354 public void release()
355 {
356 cryptos = null;
357 }
358
359 public int getColumnCount()
360 {
361
362 return 5;
363 }
364
365 @Override
366 public String getColumnName( int column )
367 {
368 switch( column )
369 {
370 case 0:
371 return "Source";
372 case 1:
373 return "Status";
374 case 2:
375 return "Password";
376 case 3:
377 return "Default Alias";
378 case 4:
379 return "Alias Password";
380 case 5:
381 return "Security Provider";
382 }
383
384 return null;
385 }
386
387 public int getRowCount()
388 {
389 return cryptos == null ? 0 : cryptos.size();
390 }
391
392 @Override
393 public boolean isCellEditable( int rowIndex, int columnIndex )
394 {
395 return columnIndex > 1;
396 }
397
398 public Object getValueAt( int rowIndex, int columnIndex )
399 {
400 KeyMaterialWssCrypto crypto = (KeyMaterialWssCrypto) cryptos.get( rowIndex );
401
402 switch( columnIndex )
403 {
404 case 0:
405 return crypto.getSource();
406 case 1:
407 return crypto.getStatus();
408 case 2:
409 return crypto.getPassword();
410 case 3:
411 return crypto.getDefaultAlias();
412 case 4:
413 return crypto.getAliasPassword();
414 case 5:
415 return StringUtils.hasContent( crypto.getCryptoProvider() ) ? crypto.getCryptoProvider() : DEFAULT_OPTION;
416 }
417
418 return null;
419 }
420
421 @Override
422 public void setValueAt( Object aValue, int rowIndex, int columnIndex )
423 {
424 KeyMaterialWssCrypto crypto = (KeyMaterialWssCrypto) cryptos.get( rowIndex );
425 if( aValue == null || aValue.equals( DEFAULT_OPTION ) )
426 aValue = "";
427
428 switch( columnIndex )
429 {
430 case 2:
431 crypto.setPassword( aValue.toString() );
432 break;
433 case 3:
434 crypto.setDefaultAlias( aValue.toString() );
435 break;
436 case 4:
437 crypto.setAliasPassword( aValue.toString() );
438 break;
439 case 5:
440 crypto.setCryptoProvider( aValue.toString() );
441 break;
442 }
443 }
444
445 public void cryptoAdded( WssCrypto crypto )
446 {
447 cryptos.add( crypto );
448 fireTableRowsInserted( cryptos.size() - 1, cryptos.size() - 1 );
449 }
450
451 public void cryptoRemoved( WssCrypto crypto )
452 {
453 int ix = cryptos.indexOf( crypto );
454 if( ix != -1 )
455 {
456 cryptos.remove( ix );
457 fireTableRowsDeleted( ix, ix );
458 }
459 }
460 }
461
462 private class AddCryptoAction extends AbstractAction
463 {
464 public AddCryptoAction()
465 {
466 putValue( SMALL_ICON, UISupport.createImageIcon( "/add_property.gif" ) );
467 putValue( SHORT_DESCRIPTION, "Adds a new crypto to this configuration" );
468 }
469
470 public void actionPerformed( ActionEvent e )
471 {
472 File file = UISupport.getFileDialogs().open( this, "Select Key Material", null, null, null );
473 if( file != null )
474 {
475 String password = UISupport.prompt( "Specify password for [" + file.getName() + "]", "Add Key Material", "" );
476 wssContainer.addCrypto( file.getAbsolutePath(), password );
477 cryptosTable.setRowSelectionInterval( cryptosTable.getRowCount() - 1, cryptosTable.getRowCount() - 1 );
478 }
479 }
480 }
481
482 private class RemoveCryptoAction extends AbstractAction
483 {
484 public RemoveCryptoAction()
485 {
486 putValue( SMALL_ICON, UISupport.createImageIcon( "/remove_property.gif" ) );
487 putValue( SHORT_DESCRIPTION, "Removes the selected crypto from this configuration" );
488
489 setEnabled( false );
490 }
491
492 public void actionPerformed( ActionEvent e )
493 {
494 int row = cryptosTable.getSelectedRow();
495 if( row == -1 )
496 return;
497
498 if( UISupport.confirm( "Removes selected crypto?", "Remove Crypto" ) )
499 {
500 wssContainer.removeCryptoAt( row );
501 }
502 }
503 }
504
505 public class IncomingWssTableModel extends AbstractTableModel
506 {
507 private List<IncomingWss> incomingWss;
508
509 public IncomingWssTableModel()
510 {
511 incomingWss = wssContainer.getIncomingWssList();
512 }
513
514 public void release()
515 {
516 incomingWss = null;
517 }
518
519 public int getColumnCount()
520 {
521 return 4;
522 }
523
524 @Override
525 public String getColumnName( int column )
526 {
527 switch( column )
528 {
529 case 0:
530 return "Name";
531 case 1:
532 return "Decrypt Keystore";
533 case 2:
534 return "Signature Keystore";
535 case 3:
536 return "Password";
537 }
538
539 return null;
540 }
541
542 public int getRowCount()
543 {
544 return incomingWss == null ? 0 : incomingWss.size();
545 }
546
547 @Override
548 public boolean isCellEditable( int rowIndex, int columnIndex )
549 {
550 return columnIndex > 0;
551 }
552
553 public Object getValueAt( int rowIndex, int columnIndex )
554 {
555 IncomingWss incoming = incomingWss.get( rowIndex );
556
557 switch( columnIndex )
558 {
559 case 0:
560 return incoming.getName();
561 case 1:
562 return wssContainer.getCryptoByName( incoming.getDecryptCrypto() );
563 case 2:
564 return wssContainer.getCryptoByName( incoming.getSignatureCrypto() );
565 case 3:
566 return incoming.getDecryptPassword();
567 }
568
569 return null;
570 }
571
572 @Override
573 public void setValueAt( Object aValue, int rowIndex, int columnIndex )
574 {
575 IncomingWss incoming = incomingWss.get( rowIndex );
576
577 switch( columnIndex )
578 {
579 case 1:
580 incoming.setDecryptCrypto( aValue == null ? null : aValue.toString() );
581 break;
582 case 2:
583 incoming.setSignatureCrypto( aValue == null ? null : aValue.toString() );
584 break;
585 case 3:
586 incoming.setDecryptPassword( aValue == null ? null : aValue.toString() );
587 break;
588 }
589 }
590
591 public void incomingWssAdded( IncomingWss incoming )
592 {
593 incomingWss.add( incoming );
594 fireTableRowsInserted( incomingWss.size() - 1, incomingWss.size() - 1 );
595
596 }
597
598 public void incomingWssRemoved( IncomingWss incoming )
599 {
600 int ix = incomingWss.indexOf( incoming );
601 if( ix != -1 )
602 {
603 incomingWss.remove( ix );
604 fireTableRowsDeleted( ix, ix );
605 }
606 }
607 }
608
609 private class AddIncomingWssAction extends AbstractAction
610 {
611 public AddIncomingWssAction()
612 {
613 putValue( SMALL_ICON, UISupport.createImageIcon( "/add_property.gif" ) );
614 putValue( SHORT_DESCRIPTION, "Adds a new Incoming WSS Configuration" );
615 }
616
617 public void actionPerformed( ActionEvent e )
618 {
619 String name = UISupport.prompt( "Specify unique name for configuration", "New Incoming WSS Configuration", "" );
620 if( StringUtils.hasContent( name ) && wssContainer.getIncomingWssByName( name ) == null )
621 {
622 wssContainer.addIncomingWss( name );
623 incomingWssTable.setRowSelectionInterval( incomingWssTable.getRowCount() - 1, incomingWssTable.getRowCount() - 1 );
624 }
625 }
626 }
627
628 private class RemoveIncomingWssAction extends AbstractAction
629 {
630 public RemoveIncomingWssAction()
631 {
632 putValue( SMALL_ICON, UISupport.createImageIcon( "/remove_property.gif" ) );
633 putValue( SHORT_DESCRIPTION, "Removes the selected Incoming WSS Configuration" );
634
635 setEnabled( false );
636 }
637
638 public void actionPerformed( ActionEvent e )
639 {
640 int row = incomingWssTable.getSelectedRow();
641 if( row == -1 )
642 return;
643
644 if( UISupport.confirm( "Removes selected configuration?", "Remove Configuration" ) )
645 {
646 wssContainer.removeIncomingWssAt( row );
647 }
648 }
649 }
650
651 public class OutgoingWssTableModel extends AbstractTableModel
652 {
653 private List<OutgoingWss> outgoingWss;
654
655 public OutgoingWssTableModel()
656 {
657 outgoingWss = wssContainer.getOutgoingWssList();
658 }
659
660 public void release()
661 {
662 outgoingWss = null;
663 }
664
665 public int getColumnCount()
666 {
667 return 5;
668 }
669
670 @Override
671 public String getColumnName( int column )
672 {
673 switch( column )
674 {
675 case 0:
676 return "Name";
677 case 1:
678 return "Default Username/Alias";
679 case 2:
680 return "Default Password";
681 case 3:
682 return "Actor";
683 case 4:
684 return "Must Understand";
685 }
686
687 return null;
688 }
689
690 @Override
691 public Class<?> getColumnClass( int columnIndex )
692 {
693 return columnIndex == 4 ? Boolean.class : String.class;
694 }
695
696 public int getRowCount()
697 {
698 return outgoingWss == null ? 0 : outgoingWss.size();
699 }
700
701 @Override
702 public boolean isCellEditable( int rowIndex, int columnIndex )
703 {
704 return columnIndex > 0;
705 }
706
707 public Object getValueAt( int rowIndex, int columnIndex )
708 {
709 OutgoingWss outgoing = outgoingWss.get( rowIndex );
710
711 switch( columnIndex )
712 {
713 case 0:
714 return outgoing.getName();
715 case 1:
716 return outgoing.getUsername();
717 case 2:
718 return outgoing.getPassword();
719 case 3:
720 return outgoing.getActor();
721 case 4:
722 return outgoing.getMustUnderstand();
723 }
724
725 return null;
726 }
727
728 @Override
729 public void setValueAt( Object aValue, int rowIndex, int columnIndex )
730 {
731 OutgoingWss outgoing = outgoingWss.get( rowIndex );
732
733 switch( columnIndex )
734 {
735 case 1:
736 outgoing.setUsername( aValue == null ? null : aValue.toString() );
737 break;
738 case 2:
739 outgoing.setPassword( aValue == null ? null : aValue.toString() );
740 break;
741 case 3:
742 outgoing.setActor( aValue == null ? null : aValue.toString() );
743 break;
744 case 4:
745 outgoing.setMustUnderstand( aValue == null ? false : (Boolean) aValue );
746 break;
747 }
748 }
749
750 public void outgoingWssAdded( OutgoingWss outgoing )
751 {
752 outgoingWss.add( outgoing );
753 fireTableRowsInserted( outgoingWss.size() - 1, outgoingWss.size() - 1 );
754 }
755
756 public void outgoingWssRemoved( OutgoingWss outgoing )
757 {
758 int ix = outgoingWss.indexOf( outgoing );
759 if( ix != -1 )
760 {
761 outgoingWss.remove( ix );
762 fireTableRowsDeleted( ix, ix );
763 }
764 }
765 }
766
767 private class AddOutgoingWssAction extends AbstractAction
768 {
769 public AddOutgoingWssAction()
770 {
771 putValue( SMALL_ICON, UISupport.createImageIcon( "/add_property.gif" ) );
772 putValue( SHORT_DESCRIPTION, "Adds a new Outgoing WSS Configuration" );
773 }
774
775 public void actionPerformed( ActionEvent e )
776 {
777 String name = UISupport.prompt( "Specify unique name for configuration", "New Outgoing WSS Configuration", "" );
778 if( StringUtils.hasContent( name ) && wssContainer.getOutgoingWssByName( name ) == null )
779 {
780 wssContainer.addOutgoingWss( name );
781 outgoingWssTable.setRowSelectionInterval( outgoingWssTable.getRowCount() - 1, outgoingWssTable.getRowCount() - 1 );
782 }
783 }
784 }
785
786 private class RemoveOutgoingWssAction extends AbstractAction
787 {
788 public RemoveOutgoingWssAction()
789 {
790 putValue( SMALL_ICON, UISupport.createImageIcon( "/remove_property.gif" ) );
791 putValue( SHORT_DESCRIPTION, "Removes the selected Outgoing WSS Configuration" );
792
793 setEnabled( false );
794 }
795
796 public void actionPerformed( ActionEvent e )
797 {
798 int row = outgoingWssTable.getSelectedRow();
799 if( row == -1 )
800 return;
801
802 if( UISupport.confirm( "Removes selected configuration?", "Remove Configuration" ) )
803 {
804 wssContainer.removeOutgoingWssAt( row );
805 }
806 }
807 }
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867 public class AddOutgoingEntryAction extends AbstractAction
868 {
869 public AddOutgoingEntryAction()
870 {
871 putValue( SHORT_DESCRIPTION, "Adds a new WSS Entry" );
872 putValue( SMALL_ICON, UISupport.createImageIcon( "/add_property.gif" ) );
873 setEnabled( false );
874 }
875
876 public void actionPerformed( ActionEvent e )
877 {
878 if( selectedOutgoing == null )
879 return;
880
881 String type = UISupport.prompt( "Select type of entry to add", "Add WSS Entry", WssEntryRegistry.get()
882 .getTypes() );
883 if( type != null )
884 {
885 WssEntry entry = selectedOutgoing.addEntry( type );
886 entriesTabs.setSelectedComponent( entry.getConfigurationPanel() );
887
888
889
890 }
891 }
892 }
893
894 public class RemoveOutgoingEntryAction extends AbstractAction
895 {
896 public RemoveOutgoingEntryAction()
897 {
898 putValue( SHORT_DESCRIPTION, "Removes the selected WSS-Entry" );
899 putValue( SMALL_ICON, UISupport.createImageIcon( "/remove_property.gif" ) );
900 }
901
902 public void actionPerformed( ActionEvent e )
903 {
904 if( selectedEntry == null )
905 return;
906
907 if( UISupport.confirm( "Remove entry [" + selectedEntry.getLabel() + "]", "Remove WSS Entry" ) )
908 {
909 selectedOutgoing.removeEntry( selectedEntry );
910 }
911 }
912 }
913
914 private class InternalWssContainerListener implements WssContainerListener
915 {
916 public void cryptoAdded( WssCrypto crypto )
917 {
918 ( (CryptosTableModel) cryptosTable.getModel() ).cryptoAdded( crypto );
919 }
920
921 public void cryptoRemoved( WssCrypto crypto )
922 {
923 ( (CryptosTableModel) cryptosTable.getModel() ).cryptoRemoved( crypto );
924 }
925
926 public void incomingWssAdded( IncomingWss incomingWss )
927 {
928 ( (IncomingWssTableModel) incomingWssTable.getModel() ).incomingWssAdded( incomingWss );
929
930 }
931
932 public void incomingWssRemoved( IncomingWss incomingWss )
933 {
934 ( (IncomingWssTableModel) incomingWssTable.getModel() ).incomingWssRemoved( incomingWss );
935
936 }
937
938 public void outgoingWssAdded( OutgoingWss outgoingWss )
939 {
940 ( (OutgoingWssTableModel) outgoingWssTable.getModel() ).outgoingWssAdded( outgoingWss );
941 }
942
943 public void outgoingWssEntryAdded( WssEntry entry )
944 {
945 if( entry.getOutgoingWss() == selectedOutgoing )
946 {
947 entriesTabs.addTab( entry.getLabel(), entry.getConfigurationPanel() );
948 entriesTabs.getParent().setVisible( true );
949 }
950
951 }
952
953 public void outgoingWssEntryRemoved( WssEntry entry )
954 {
955 if( entry.getOutgoingWss() == selectedOutgoing )
956 {
957 int ix = entriesTabs.indexOfComponent( entry.getConfigurationPanel() );
958 if( ix != -1 )
959 entriesTabs.remove( ix );
960
961 entriesTabs.getParent().setVisible( entriesTabs.getTabCount() > 0 );
962 }
963
964 }
965
966 public void outgoingWssRemoved( OutgoingWss outgoingWss )
967 {
968 ( (OutgoingWssTableModel) outgoingWssTable.getModel() ).outgoingWssRemoved( outgoingWss );
969 }
970
971 public void cryptoUpdated( WssCrypto crypto )
972 {
973 }
974 }
975
976 public class ImportWssSettingsAction extends AbstractAction
977 {
978 public ImportWssSettingsAction()
979 {
980 putValue( SHORT_DESCRIPTION, "Imports an existing WS-Security configuration from another project" );
981 putValue( SMALL_ICON, UISupport.createImageIcon( "/load_properties.gif" ) );
982 }
983
984 public void actionPerformed( ActionEvent e )
985 {
986 String[] names = ModelSupport.getNames( ( (WorkspaceImpl) SoapUI.getWorkspace() ).getOpenProjectList() );
987 String projectName = UISupport.prompt( "Select project to import from", "Import WSS Settings", names );
988 if( projectName != null )
989 {
990 WsdlProject prj = (WsdlProject) SoapUI.getWorkspace().getProjectByName( projectName );
991 wssContainer.importConfig( prj.getWssContainer() );
992 }
993 }
994 }
995
996 public static class PasswordTableCellRenderer extends JPasswordField implements TableCellRenderer
997 {
998 public PasswordTableCellRenderer()
999 {
1000 setEditable( false );
1001 setBorder( null );
1002 }
1003
1004 public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column )
1005 {
1006 setBackground( table.getBackground() );
1007 setText( value == null ? "" : value.toString() );
1008 return this;
1009 }
1010
1011 }
1012 }