📄 permisldapconnection.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.
*/
/*
* PermisLdapConnection.java
*
* Created on 04 August 2004, 13:38
*/
package issrg.editor.gui;
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 javax.swing.JTextField;
import javax.swing.JOptionPane;
/**
*
* @author issrg
*/
public class PermisLdapConnection {
private LDAP_DIT ldap_dit;
public PermisPolicyEditorButton parent;
private String dns = null;
private ShowMessage msg;
boolean connected = false;
/** Creates a new instance of PermisLdapConnection */
public PermisLdapConnection(PermisPolicyEditorButton parent) {
this.parent = parent;
msg = new ShowMessage();
}
public boolean getConectionStatus()
{
return connected;
}
public LDAP_DIT initLDAP_DIT(String s)
{
try
{
if (s==null) s="";
this.ldap_dit = new LDAP_DIT(s.trim());
//ok
JOptionPane.showMessageDialog(this.parent.getPermisParent()," Directory is Ready","Successful ! ...",JOptionPane.ERROR_MESSAGE);
//set connection status
connected = true;
return this.ldap_dit;
}catch(javax.naming.NamingException ne)
{
//set connection status
connected = false;
return unsetLdap_1();
}
}
public LDAP_DIT unsetLdap_1()
{
JOptionPane.showMessageDialog(this.parent.getPermisParent(),"Directory is unavailable","Error",JOptionPane.ERROR_MESSAGE);
return new LDAP_DIT();
}
public void unsetLdap()
{
this.ldap_dit = new LDAP_DIT();
}
//not used for now
private class ShowMessage extends javax.swing.JDialog{
private PermisPolicyEditorButton parent;
private javax.swing.JDialog dialog;
private javax.swing.JLabel label;
private javax.swing.JButton button;
public ShowMessage(){
// this.setLayout( new javax.swing.BoxLayout())
label = new javax.swing. JLabel("Connecting ....!");
button = new javax.swing.JButton("Ok");
label.setSize(94, 26);
button.setEnabled(false);
button.setSize(76, 26);
button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonButtonActionPerformed(evt);
}
});
this.getContentPane().add(label);
this.getContentPane().add(button);
this.setSize(300, 200);
this.setModal(true);
this.setTitle("Directory Connection");
this.setResizable(true);
center(this);
this.pack();
}
private void buttonButtonActionPerformed(java.awt.event.ActionEvent evt){
this.dispose();
}
private void center(java.awt.Component cm)
{
center(cm, cm.getSize());
}
private void center(java.awt.Component cm, java.awt.Dimension me)
{
java.awt. Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
cm.setLocation(screenSize.width/2 - me.width/2,
screenSize.height/2 -me.height/2);
}
public void showDialog()
{
this.show();
}
public void setMsg(String msg)
{
label.setText(msg);
}
public void enableButton()
{
button.setEnabled(true);
}
public void disableButton()
{
button.setEnabled(false);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -