001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.websvc.wsitconf.ui.service.profiles;
043:
044: import java.awt.Dialog;
045: import javax.swing.JPanel;
046: import javax.swing.undo.UndoManager;
047: import org.netbeans.api.project.Project;
048: import org.netbeans.modules.websvc.wsitconf.spi.features.ClientDefaultsFeature;
049: import org.netbeans.modules.websvc.wsitconf.spi.features.ServiceDefaultsFeature;
050: import org.netbeans.modules.websvc.wsitconf.ui.ComboConstants;
051: import org.netbeans.modules.websvc.wsitconf.util.UndoCounter;
052: import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.ProfilesModelHelper;
053: import org.netbeans.modules.websvc.wsitconf.wsdlmodelext.ProprietarySecurityPolicyModelHelper;
054: import org.netbeans.modules.xml.wsdl.model.Binding;
055: import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
056: import org.netbeans.modules.xml.wsdl.model.WSDLModel;
057: import org.openide.DialogDescriptor;
058: import org.openide.DialogDisplayer;
059:
060: /**
061: * Transport Security Profile definition
062: *
063: * @author Martin Grebac
064: */
065: public class TransportSecurityProfile extends ProfileBase implements
066: ClientDefaultsFeature, ServiceDefaultsFeature {
067:
068: public int getId() {
069: return 30;
070: }
071:
072: public String getDisplayName() {
073: return ComboConstants.PROF_TRANSPORT;
074: }
075:
076: public String getDescription() {
077: return ComboConstants.PROF_TRANSPORT_INFO;
078: }
079:
080: /**
081: * Called when the profile is selected in the combo box.
082: */
083: @Override
084: public void profileSelected(WSDLComponent component,
085: boolean updateServiceUrl) {
086: ProfilesModelHelper.setSecurityProfile(component,
087: getDisplayName(), updateServiceUrl);
088: }
089:
090: /**
091: * Should return true if the profile is set on component, false otherwise
092: */
093: public boolean isCurrentProfile(WSDLComponent component) {
094: return getDisplayName().equals(
095: ProfilesModelHelper.getWSITSecurityProfile(component));
096: }
097:
098: @Override()
099: public void displayConfig(WSDLComponent component,
100: UndoManager undoManager) {
101: UndoCounter undoCounter = new UndoCounter();
102: WSDLModel model = component.getModel();
103:
104: model.addUndoableEditListener(undoCounter);
105:
106: JPanel profConfigPanel = new TransportSecurity(component);
107: DialogDescriptor dlgDesc = new DialogDescriptor(
108: profConfigPanel, getDisplayName());
109: Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);
110:
111: dlg.setVisible(true);
112: if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
113: for (int i = 0; i < undoCounter.getCounter(); i++) {
114: if (undoManager.canUndo()) {
115: undoManager.undo();
116: }
117: }
118: }
119:
120: model.removeUndoableEditListener(undoCounter);
121: }
122:
123: public void setClientDefaults(WSDLComponent component,
124: WSDLComponent serviceBinding, Project p) {
125: ProprietarySecurityPolicyModelHelper.setStoreLocation(
126: component, null, false, true);
127: ProprietarySecurityPolicyModelHelper.setStoreLocation(
128: component, null, true, true);
129: ProprietarySecurityPolicyModelHelper
130: .removeCallbackHandlerConfiguration((Binding) component);
131: }
132:
133: public void setServiceDefaults(WSDLComponent component, Project p) {
134: ProprietarySecurityPolicyModelHelper.setStoreLocation(
135: component, null, false, false);
136: ProprietarySecurityPolicyModelHelper.setStoreLocation(
137: component, null, true, false);
138: }
139:
140: public boolean isClientDefaultSetupUsed(WSDLComponent component,
141: Binding serviceBinding, Project p) {
142: if (ProprietarySecurityPolicyModelHelper
143: .getCBHConfiguration((Binding) component) != null) {
144: return false;
145: }
146: return true;
147: }
148:
149: public boolean isServiceDefaultSetupUsed(WSDLComponent component,
150: Project p) {
151: return true;
152: }
153:
154: }
|