⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 permisldapsetup.java

📁 一个完整的XACML工程,学习XACML技术的好例子!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
* 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 javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.util.ResourceBundle;
/**
 * Classname:   PermisLdapSetup
 * 
 * Description: This class creates LDAP directory entries and  associated 
 *              buttons and their methods.
 *              Version 1.2.4              
 *
 * Copyright (c) the authors April 2004
 *
 * @author      Professor D.W.Chadwick
 *                       U. Mbanaso
 */
public class PermisLdapSetup extends JDialog implements ActionListener {
    final static String FILENAME = "permisLdap.cfg";
    public final static String LDAP_ENTRY = "[LDAPENTRY]";

    private Properties prop;
    private javax.swing.DefaultListModel model;
    private ListSelectionModel lsm;
    private Properties ldapProp;
    private JTextField server, port, user, name, dns;
    private JLabel serverLabel, portLabel, userLabel, nameLabel, dnsLabel,
                     versionLabel, usernameLabel, passLabel;
    private JComboBox ver;
    private JTextField password;
    private JCheckBox anyolog;
    private JTabbedPane tab;
    private GridBagLayout grid_bl;
    private GridBagConstraints grid_cr;
    private JButton saveButton, closeButton, connectButton;
    //private PermisDirectoryName dir;
    private PermisPolicyEditorMain parent;
    private PermisLayout permisLayout;
    private JPanel pp, ps, mp, userPanel, serverPanel,py;

    private static final String ANONYMOUS_ACTION = "anyolog";
    private static final String SAVE_ACTION = "save";
    private static final String CANCEL_ACTION = "cancel";
    private static final String CONNECT_ACTION = "connect";
      
    private static final String NEW_ACTION = "new";
    private static final String DELETE_ACTION = "delete";
    private static final String EDIT_ACTION = "edit";

    private Hashtable deletedHash;
    
    private javax.swing.JPanel bPanel;
    private javax.swing.JPanel buttonPanel;
    private javax.swing.JButton deleteButton;
    private javax.swing.JLabel directoryLabel;
    private javax.swing.JList directoryList;
    private javax.swing.JPanel ePanel = new javax.swing.JPanel();
    private javax.swing.JButton editButton;
    private javax.swing.JPanel listPanel;
    private javax.swing.JScrollPane listScrollPane;
    private javax.swing.JButton newButton;
    
    private boolean editing = false;
  
    public JPanel createPanel() {
        JPanel mp = new JPanel();
        listPanel = new javax.swing.JPanel();
        directoryLabel = new javax.swing.JLabel();
        listScrollPane = new javax.swing.JScrollPane();
        model = new  javax.swing.DefaultListModel();
        directoryList = new javax.swing.JList(model);
        
        deletedHash = new Hashtable(1);
        
        buttonPanel = new javax.swing.JPanel();
        bPanel = new javax.swing.JPanel();
        newButton = new javax.swing.JButton();
       
        deleteButton = new javax.swing.JButton();
       
        editButton = new javax.swing.JButton();
        ePanel = new javax.swing.JPanel();

        mp.setLayout(new java.awt.GridLayout());

        listPanel.setLayout(new javax.swing.BoxLayout(listPanel, javax.swing.BoxLayout.Y_AXIS));

        directoryLabel.setText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_name"));
        listPanel.add(directoryLabel);
         
      
        directoryList.addListSelectionListener( new ListSelectionListener(){
            public void valueChanged(ListSelectionEvent evt){
              directoryListValueChanged();  
            }
        });
        listScrollPane.setViewportView(directoryList);

        listPanel.add(listScrollPane);

        mp.add(listPanel);

        buttonPanel.setLayout(new java.awt.GridLayout(1, 1));

        bPanel.setLayout(new java.awt.GridLayout(5, 0));

        newButton.setMnemonic('N');
        newButton.setText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("new_button"));
        newButton.setToolTipText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_service"));

        newButton.setActionCommand(NEW_ACTION);
        newButton.addActionListener(this);

        bPanel.add(newButton);

       

       // bPanel.add(renameButton);

        deleteButton.setMnemonic('d');
        deleteButton.setText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("sub_pol_btn_cm_delete"));
        deleteButton.setToolTipText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_delete"));

        deleteButton.setActionCommand(DELETE_ACTION);
        deleteButton.addActionListener(this);

        bPanel.add(deleteButton);

        editButton.setMnemonic('e');
        editButton.setText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("sub_pol_btn_edit"));
        editButton.setToolTipText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_edit"));

        editButton.setActionCommand(EDIT_ACTION);
        editButton.addActionListener(this);

        bPanel.add(editButton);
        //bPanel.add(ePanel);
        buttonPanel.add(bPanel);

        buttonPanel.add(ePanel);

        mp.add(buttonPanel);
        return mp;

    }


    public JPanel getProgressPanel()
    {
        return  ePanel;
    }


    public Hashtable getDeletedHash()
    {
        return deletedHash;
    }


    private void editButtonActionPerformed() {
       // parent.read();
        if(getItem() != null){
         addTabObject(2);
        //add this server name to HastTable to check if the user changed the name
         deletedHash.put(getItem(), getItem());
         
         setEntry((Properties)ldapProp.get(getItem()));
         tab.setSelectedIndex(1);
         saveButton.setEnabled(true);
         connectButton.setEnabled(false);
         //set editing to true
         editing = true;
       }
    }


    private void deleteButtonActionPerformed() {
        String s = (String)directoryList.getSelectedValue();
        if(s!=null){
          if(dialog(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                  getString("warning"), ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                  getString("confirm_directory_delete"))){
            model.removeElementAt(directoryList.getSelectedIndex());
            ldapProp.remove(s);
            saveButton.setEnabled(true);
          }
        }
    }


     private void newButtonActionPerformed() {
        clearTextFields();
        
        addTabObject(2);
        tab.setSelectedIndex(1);
        saveButton.setEnabled(true);
        connectButton.setEnabled(false);
        editing = true;
    }


    public void addItem(String s){
        if (s != null && !isInTheList(s)){
            model.addElement(s);
        }
    }


    public String getItem()
    { 
      return (String)directoryList.getSelectedValue();
    }

    private boolean isInTheList(String s)
    { // model.contains?
        for( int i = 0; i< model.getSize(); i++){
            if(model.getElementAt(i).equals(s)){
                return true;
            }
            
        }
        return false;
    }



   public boolean dialog(String title, String message)
   {
    int n = JOptionPane.showConfirmDialog( this, 
                                               message,
                                               title,
                                               JOptionPane.YES_NO_OPTION);  
    return n == JOptionPane.YES_OPTION; 	
   }
   
   private void  directoryListValueChanged()
   {
       connectButton.setEnabled(true);
   }

    /**
     * Constructor
     */  
    public PermisLdapSetup(
                           PermisPolicyEditorMain parent
                           ) {
           
        super(parent, ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_setup"), true);
        this.parent = parent;

        permisLayout = new PermisLayout(parent);

        initComponents();
        setSize(497,  325);
        setResizable(false);
    }
    

    
    /**
     * This method creates an instance of the class and initilaises all the 
     * relevant variables.
     */
    private void initComponents()
    {
        grid_bl = new GridBagLayout();
        grid_cr = new GridBagConstraints();
        tab = new JTabbedPane();
        pp = new JPanel();
        ps = new JPanel();
        this.mp = new JPanel();
        userPanel = new JPanel();
        serverPanel = new JPanel();
        py = new JPanel();
        mp.setLayout(grid_bl);
        
        ps = createPanel();
        
        pp.setLayout(grid_bl);
        //
        py.setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED, null, java.awt.Color.lightGray, null, null));
        py.setLayout( new BorderLayout() );
        //
       serverPanel.setBorder(BorderFactory.createTitledBorder("Server Info"));
       serverPanel.setLayout(grid_bl);
       grid_cr.insets = new Insets(1,1,1, 1);
       grid_cr.anchor = GridBagConstraints.EAST;
       nameLabel = new JLabel(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_name"));
       nameLabel.setToolTipText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_name_tt"));
       permisLayout.add(serverPanel,nameLabel ,grid_bl, grid_cr, 0,0,1,1);
       serverLabel = new JLabel(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_dns"));
        serverLabel.setToolTipText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_dns_tt"));
        
       permisLayout.add(serverPanel, serverLabel ,grid_bl, grid_cr, 0,1,1,1);
       dnsLabel =  new JLabel(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_base"));
       dnsLabel.setToolTipText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_base_tt"));
       permisLayout.add(serverPanel,dnsLabel,grid_bl, grid_cr, 0,2,1,1);
       portLabel = new JLabel(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_port"));
         portLabel.setToolTipText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_port_tt"));
       permisLayout.add(serverPanel, portLabel ,grid_bl, grid_cr, 3,1,1,1);
       
       versionLabel =  new JLabel(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_version"));
        versionLabel.setToolTipText(ResourceBundle.getBundle("issrg/editor/gui/Editor_GUI_i18n").
                         getString("directory_version_tt"));
       permisLayout.add(serverPanel,  versionLabel,grid_bl, grid_cr, 6,1,1,1);
       
       grid_cr.anchor = GridBagConstraints.WEST;
       
       permisLayout.add(serverPanel, ver = new JComboBox(new String [] 
                                              {"1","2","3"}),grid_bl, grid_cr, 7,1,1,1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -