KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsitconf > ui > service > profiles > SenderVouchesProfile


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.wsitconf.ui.service.profiles;
21
22 import java.awt.Dialog JavaDoc;
23 import javax.swing.JPanel JavaDoc;
24 import javax.swing.undo.UndoManager JavaDoc;
25 import org.netbeans.modules.websvc.wsitconf.spi.SecurityProfile;
26 import org.netbeans.modules.websvc.wsitconf.ui.ComboConstants;
27 import org.netbeans.modules.websvc.wsitconf.util.UndoCounter;
28 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.ProfilesModelHelper;
29 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.RMModelHelper;
30 import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.SecurityPolicyModelHelper;
31 import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
32 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
33 import org.openide.DialogDescriptor;
34 import org.openide.DialogDisplayer;
35
36 /**
37  * Transport Security Profile definition
38  *
39  * @author Martin Grebac
40  */

41 public class SenderVouchesProfile extends SecurityProfile {
42     
43     public int getId() {
44         return 70;
45     }
46
47     public String JavaDoc getDisplayName() {
48         return ComboConstants.PROF_SAMLSENDER;
49     }
50
51     public String JavaDoc getDescription() {
52         return ComboConstants.PROF_SAMLSENDER_INFO;
53     }
54     
55     /**
56      * Called when the profile is selected in the combo box.
57      */

58     public void profileSelected(WSDLComponent component) {
59         ProfilesModelHelper.setSecurityProfile(component, getDisplayName());
60         boolean isRM = RMModelHelper.isRMEnabled(component);
61         if (isRM) {
62             ProfilesModelHelper.enableSecureConversation(component, true, getDisplayName());
63         }
64     }
65
66     /**
67      * Called when there's another profile selected, or security is disabled at all.
68      */

69     public void profileDeselected(WSDLComponent component) {
70         SecurityPolicyModelHelper.disableSecurity(component, false);
71     }
72
73     /**
74      * Should return true if the profile is set on component, false otherwise
75      */

76     public boolean isCurrentProfile(WSDLComponent component) {
77         return getDisplayName().equals(ProfilesModelHelper.getWSITSecurityProfile(component));
78     }
79     
80     @Override JavaDoc()
81     public void displayConfig(WSDLComponent component, UndoManager JavaDoc undoManager) {
82         UndoCounter undoCounter = new UndoCounter();
83         WSDLModel model = component.getModel();
84         
85         model.addUndoableEditListener(undoCounter);
86
87         JPanel JavaDoc profConfigPanel = new SenderVouches(component);
88         DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
89         Dialog JavaDoc dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);
90
91         dlg.setVisible(true);
92         if (dlgDesc.getValue() == dlgDesc.CANCEL_OPTION) {
93             for (int i=0; i<undoCounter.getCounter();i++) {
94                 if (undoManager.canUndo()) {
95                     undoManager.undo();
96                 }
97             }
98         }
99         
100         model.removeUndoableEditListener(undoCounter);
101     }
102 }
103
Popular Tags