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) 2009, 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 |
|
37 public class FirewallOverrideTab |
|
38 extends SettingsControl<FirewallPanelDescriptor, FirewallSettingsPanel> |
|
39 { |
|
40 |
|
41 // |
|
42 // Static data |
|
43 // |
|
44 private static final String ID = "Override"; |
|
45 private static final String NAME = |
|
46 Finder.getString("settings.objects.override.title"); |
|
47 private static final String OVERRIDE_POLICY_DESC = |
|
48 Finder.getString("description.policy.override"); |
|
49 |
|
50 // |
|
51 // Constructors |
|
52 // |
|
53 |
|
54 public FirewallOverrideTab(FirewallPanelDescriptor descriptor) { |
|
55 super(ID, NAME, descriptor); |
|
56 } |
|
57 |
|
58 // |
|
59 // Control methods |
|
60 // |
|
61 |
|
62 @Override |
|
63 public String getHelpMapID() { |
|
64 return "firewall-override"; |
|
65 } |
|
66 |
|
67 @Override |
|
68 protected UnsavedChangesAction getUnsavedChangesAction() { |
|
69 // Automatically save changes to the ApachePanelDescriptor -- |
|
70 // let MainControl prompt the user to save them to the repo |
|
71 return UnsavedChangesAction.SAVE; |
|
72 } |
|
73 |
|
74 @Override |
|
75 protected boolean isChanged() { |
|
76 return (getComponent().getAccessProperty().isChanged()); |
|
77 } |
|
78 |
|
79 @Override |
|
80 protected void save() throws ActionAbortedException, ActionFailedException, |
|
81 ActionUnauthorizedException { |
|
82 |
|
83 AccessProperty aProperty = getComponent().getAccessProperty(); |
|
84 setPropertyChangeIgnore(true); |
|
85 |
|
86 try { |
|
87 getPanelDescriptor().updateOvrAccessPolicy(aProperty.getValue()); |
|
88 } catch (RadPrivilegeException e) { |
|
89 throw new ActionUnauthorizedException(e); |
|
90 } finally { |
|
91 setPropertyChangeIgnore(false); |
|
92 } |
|
93 } |
|
94 |
|
95 @Override |
|
96 public void start(Navigator navigator, Map<String, String> parameters) |
|
97 throws NavigationAbortedException, InvalidParameterException, |
|
98 NavigationFailedException { |
|
99 setPropertyChangeSource(getPanelDescriptor()); |
|
100 super.start(navigator, parameters); |
|
101 } |
|
102 |
|
103 // |
|
104 // SwingControl methods |
|
105 // |
|
106 |
|
107 @Override |
|
108 protected FirewallSettingsPanel createComponent() { |
|
109 return new FirewallSettingsPanel(null, OVERRIDE_POLICY_DESC, |
|
110 Type.NONE, Type.DENY, Type.ALLOW); |
|
111 } |
|
112 |
|
113 @Override |
|
114 protected void initComponent() { |
|
115 getComponent().setPanelDescriptor(getPanelDescriptor()); |
|
116 getComponent().init(getPanelDescriptor().getOvrAccessPolicy()); |
|
117 } |
|
118 } |
|