1 /* |
|
2 * CDDL HEADER START |
|
3 * |
|
4 * The contents of this file are subject to the terms of the |
|
5 * Common Development and Distribution License (the "License"). |
|
6 * You may not use this file except in compliance with the License. |
|
7 * |
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 * or http://www.opensolaris.org/os/licensing. |
|
10 * See the License for the specific language governing permissions |
|
11 * and limitations under the License. |
|
12 * |
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 * If applicable, add the following below this CDDL HEADER, with the |
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 * |
|
19 * CDDL HEADER END |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.panels.firewall.client.swing; |
|
27 |
|
28 import java.awt.Component; |
|
29 import java.util.Map; |
|
30 import com.oracle.solaris.rad.client.RadPrivilegeException; |
|
31 import com.oracle.solaris.vp.panel.common.action.*; |
|
32 import com.oracle.solaris.vp.panel.common.control.*; |
|
33 import com.oracle.solaris.vp.panel.swing.control.SettingsControl; |
|
34 import com.oracle.solaris.vp.panels.firewall.client.swing.AccessPolicy.Type; |
|
35 import com.oracle.solaris.vp.util.misc.finder.Finder; |
|
36 import com.oracle.solaris.vp.util.misc.property.MutableProperty; |
|
37 |
|
38 public class FirewallDefaultTab |
|
39 extends SettingsControl<FirewallPanelDescriptor, FirewallSettingsPanel> |
|
40 { |
|
41 |
|
42 // |
|
43 // Static data |
|
44 // |
|
45 |
|
46 public static final String ID = "global_default"; |
|
47 private static final String NAME = |
|
48 Finder.getString("settings.objects.default.title"); |
|
49 private static final String DEFAULT_POLICY_DESC = |
|
50 Finder.getString("description.policy.default"); |
|
51 |
|
52 // |
|
53 // Constructors |
|
54 // |
|
55 |
|
56 public FirewallDefaultTab(FirewallPanelDescriptor descriptor) { |
|
57 super(ID, NAME, descriptor); |
|
58 } |
|
59 |
|
60 // |
|
61 // Control methods |
|
62 // |
|
63 |
|
64 @Override |
|
65 public String getHelpMapID() { |
|
66 return "firewall-default"; |
|
67 } |
|
68 |
|
69 @Override |
|
70 protected UnsavedChangesAction getUnsavedChangesAction() { |
|
71 // Automatically save changes to the FirewallPanelDescriptor -- |
|
72 // let MainControl prompt the user to save them to the repo |
|
73 return UnsavedChangesAction.SAVE; |
|
74 } |
|
75 |
|
76 @Override |
|
77 protected void save() throws ActionAbortedException, ActionFailedException, |
|
78 ActionUnauthorizedException { |
|
79 |
|
80 AccessProperty accessProperty = getComponent().getAccessProperty(); |
|
81 MutableProperty<Boolean> enabledProperty = |
|
82 getComponent().getEnableProperty(); |
|
83 |
|
84 AccessPolicy policy = accessProperty.getValue(); |
|
85 if (policy.getType() == Type.CUSTOM && |
|
86 policy.getCustomFile().isEmpty()) { |
|
87 |
|
88 throw new ActionFailedException(Finder.getString( |
|
89 "error.settings.customfile.empty")); |
|
90 } |
|
91 |
|
92 setPropertyChangeIgnore(true); |
|
93 try { |
|
94 getPanelDescriptor().updateAccessPolicy(policy); |
|
95 getPanelDescriptor().getEnabledProperty().setValue( |
|
96 enabledProperty.getValue()); |
|
97 } catch (RadPrivilegeException e) { |
|
98 throw new ActionUnauthorizedException(e); |
|
99 } finally { |
|
100 setPropertyChangeIgnore(false); |
|
101 } |
|
102 } |
|
103 |
|
104 @Override |
|
105 public void start(Navigator navigator, Map<String, String> parameters) |
|
106 throws NavigationAbortedException, InvalidParameterException, |
|
107 NavigationFailedException { |
|
108 setPropertyChangeSource(getPanelDescriptor()); |
|
109 super.start(navigator, parameters); |
|
110 } |
|
111 |
|
112 // |
|
113 // SwingControl methods |
|
114 // |
|
115 |
|
116 @Override |
|
117 protected FirewallSettingsPanel createComponent() { |
|
118 return new FirewallSettingsPanel( |
|
119 getPanelDescriptor().getFileSystemView(), DEFAULT_POLICY_DESC); |
|
120 } |
|
121 |
|
122 @Override |
|
123 protected void initComponent() { |
|
124 getComponent().setPanelDescriptor(getPanelDescriptor()); |
|
125 getComponent().init(getPanelDescriptor()); |
|
126 } |
|
127 } |
|