📄 permissubjectpolicy.java
字号:
/*
* Copyright (c) 2000-2005, University of Salford
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the University of Salford nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package issrg.editor.gui;
import issrg.editor.PermisDomainTree;
import issrg.editor.PermisLdapTree;
import issrg.utils.LDAP_DIT;
import issrg.utils.DITSelectionListener;
import issrg.pba.rbac.policies.DITSubtree;
import issrg.pba.repository.UserEntry;
import issrg.pba.rbac.LDAPDNPrincipal;
import issrg.pba.rbac.policies.LDAPEntry;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseListener;
import java.awt.event.FocusEvent;
import java.util.ResourceBundle;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.StringTokenizer;
import javax.naming.Context;
import javax.naming.directory.InitialDirContext;
import javax.swing.border.TitledBorder;
import javax.swing.DefaultListModel;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.InternalFrameListener;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultMutableTreeNode;
import org.netbeans.lib.awtextra.AbsoluteLayout;
import org.netbeans.lib.awtextra.AbsoluteConstraints;
/**
* Classname: PermisSubjectPolicy
*
* Description: This class creates the Subject Policy windows, its associated
* buttons and their methods.
* Version 1.0.
*
* Copyright (c) the authors April 2004
*
* @author Professor D.W.Chadwick
* P. Langley
* U. Mbanaso
*/
public class PermisSubjectPolicy extends PermisPolicyPanel implements ActionListener
{
private PermisDomainTree policySubjectTree;
protected static final String ID = "ID";
protected static final String SUBJECT_DOMAIN_SPEC = "SubjectDomainSpec";
private static final String SUBJECT_POLICY = "SubjectPolicy";
private DefaultListModel subjectViewListModel;
private JButton closeSubjectButton;
private JButton subjectCancelButton;
private JButton subjectCloseButton;
private JButton subDeleteButton;
private JButton subjectDeleteButton;
private JButton subjectEditButton;
private JButton subjectExcludeButton;
private JButton subjectIncludeButton;
private JButton subjectOkButton;
private JComboBox subjectViewComboBox;
private JDesktopPane desktop;
private JInternalFrame subjectInternalFrame;
private JLabel subjectPolicyLDAPLabel;
private JList subjectViewList;
private JPanel subjectCreatePanel;
private JPanel subjectDomainPanel;
private JPanel subjectPolicyAvailableDomainsPanel;
private JPanel subjectPolicyButtonPanel;
private JPanel subjectPolicyButtonsPanel;
private JPanel subjectPolicyIdPanel;
private JPanel subjectPolicyOkButtonPanel;
private JPanel subjectViewPanel;
private JTextField subjectIdTextField;
private JTextField subjectPolicyLdapDnTextField;
private JTree treeSubject;
private JTree subTree;
private JTree ldapSubjectTree;
private JScrollPane subjectPolicyLDAPScrollPane;
private JScrollPane subjectPolicyTreeScrollPane;
private JScrollPane subjectPolicyViewScrollPane;
private javax.swing.JTabbedPane subjectPolicyTabbedPane;
private PermisPolicyLoader loader;
private PermisPolicyEditorButton parent;
private LDAP_DIT ldap_dit;
int number = 0;
boolean editPressed = false;
private final static String VIEW_ACTION = "view";
private final static String EDIT_ACTION = "edit";
private final static String DELETE_ACTION = "delete";
private final static String CLOSE_ACTION = "close";
private final static String INCLUDE_ACTION = "include";
private final static String EXCLUDE_ACTION = "exclude";
private final static String DELETE1_ACTION = "delete1";
private final static String OK_ACTION = "ok";
private final static String CANCEL_ACTION = "cancel";
private final static String CLOSE1_ACTION = "close1";
/**
* Constructor
*/
public PermisSubjectPolicy(PermisPolicyEditorButton parent)
{
this.parent = parent;
loader = this.parent.getLoader();
}
/**
* This method creates an instance of the classs and initilaises all the
* relevant variables
*
* @return A JInternalFrame containing the Subject Policy windows
*/
public JInternalFrame createPolicy()
{
subjectViewListModel = new DefaultListModel();
closeSubjectButton = new JButton();
subjectCancelButton = new JButton();
subjectCloseButton = new JButton();
subDeleteButton = new JButton();
subjectDeleteButton = new JButton();
subjectEditButton = new JButton();
subjectExcludeButton = new JButton();
subjectIncludeButton = new JButton();
subjectOkButton = new JButton();
subjectViewComboBox = new JComboBox();
subjectInternalFrame = new JInternalFrame();
subjectPolicyLDAPLabel = new JLabel();
subjectViewList = new JList(subjectViewListModel);
subjectCreatePanel = new JPanel();
subjectDomainPanel = new JPanel();
subjectPolicyAvailableDomainsPanel = new JPanel();
subjectPolicyButtonPanel = new JPanel();
subjectPolicyButtonsPanel = new JPanel();
subjectPolicyIdPanel = new JPanel();
subjectPolicyOkButtonPanel = new JPanel();
subjectViewPanel = new JPanel();
subjectPolicyTabbedPane = new JTabbedPane();
subjectPolicyLdapDnTextField = new JTextField();
subjectIdTextField = new JTextField();
subjectPolicyLDAPScrollPane = new JScrollPane();
subjectPolicyTreeScrollPane = new JScrollPane();
subjectPolicyViewScrollPane = new JScrollPane();
subjectInternalFrame.getContentPane().setLayout(new AbsoluteLayout());
subjectInternalFrame.setTitle(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_frm_title"));
subjectInternalFrame.setPreferredSize(new Dimension(667, 680));
subjectViewPanel.setLayout(new AbsoluteLayout());
subjectPolicyAvailableDomainsPanel.setLayout(new AbsoluteLayout());
subjectPolicyAvailableDomainsPanel.
setBorder(new TitledBorder(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_v_brd")));
subjectViewList.setToolTipText(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_sub_vlist"));
subjectPolicyViewScrollPane.setViewportView(subjectViewList);
subjectPolicyAvailableDomainsPanel.add(subjectPolicyViewScrollPane,
new AbsoluteConstraints(30, 110, 320, 170));
subjectViewComboBox.setBackground(new Color(255, 255, 204));
subjectViewComboBox.setToolTipText(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_combo_desc"));
subjectViewComboBox.setActionCommand(VIEW_ACTION);
subjectViewComboBox.addActionListener(this);
subjectPolicyAvailableDomainsPanel.add(subjectViewComboBox,
new AbsoluteConstraints(30, 50, 320, -1));
subjectViewPanel.add(subjectPolicyAvailableDomainsPanel,
new AbsoluteConstraints(70, 40, 380, 310));
subjectEditButton.setMnemonic('E');
subjectEditButton.setText(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_btn_edit"));
subjectEditButton.setToolTipText(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_tt_btn_edit"));
subjectEditButton.setMaximumSize(new Dimension(70, 26));
subjectEditButton.setMinimumSize(new Dimension(70, 26));
subjectEditButton.setPreferredSize(new Dimension(70, 26));
subjectEditButton.setActionCommand(EDIT_ACTION);
subjectEditButton.addActionListener(this);
subjectPolicyButtonPanel.add(subjectEditButton);
subDeleteButton.setMnemonic('D');
subDeleteButton.setText(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
getString("sub_pol_btn_v_del"));
subDeleteButton.setToolTipText(
ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -