1 19 20 package org.netbeans.modules.websvc.wsitconf.ui.service.profiles; 21 22 import java.awt.Dialog ; 23 import javax.swing.JPanel ; 24 import javax.swing.undo.UndoManager ; 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 41 public class UsernameAuthenticationProfile extends SecurityProfile { 42 43 public int getId() { 44 return 10; 45 } 46 47 public String getDisplayName() { 48 return ComboConstants.PROF_USERNAME; 49 } 50 51 public String getDescription() { 52 return ComboConstants.PROF_USERNAME_INFO; 53 } 54 55 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 69 public void profileDeselected(WSDLComponent component) { 70 SecurityPolicyModelHelper.disableSecurity(component, false); 71 } 72 73 76 public boolean isCurrentProfile(WSDLComponent component) { 77 return getDisplayName().equals(ProfilesModelHelper.getWSITSecurityProfile(component)); 78 } 79 80 @Override () 81 public void displayConfig(WSDLComponent component, UndoManager undoManager) { 82 UndoCounter undoCounter = new UndoCounter(); 83 WSDLModel model = component.getModel(); 84 85 model.addUndoableEditListener(undoCounter); 86 87 JPanel profConfigPanel = new UsernameAuthentication(component); 88 DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName()); 89 Dialog 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 |