42 changed files with 3692 additions and 1 deletions
@ -1,3 +1,6 @@
|
||||
# open-JSD-8176 |
||||
|
||||
JSD-8176 开源任务材料 |
||||
JSD-8176 开源任务材料\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。 |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<plugin> |
||||
<id>com.fr.plugin.third.party.jsd8176</id> |
||||
<name><![CDATA[多域ldap认证和用户同步]]></name> |
||||
<active>yes</active> |
||||
<hidden>no</hidden> |
||||
<version>0.15</version> |
||||
<env-version>10.0~</env-version> |
||||
<jartime>2020-01-01</jartime> |
||||
<description><![CDATA[多域ldap认证和用户同步]]></description> |
||||
<change-notes><![CDATA[]]></change-notes> |
||||
<function-recorder class="com.fr.plugin.third.party.jsdibhg.db.MultiLdapDBAccessBridge"/> |
||||
<extra-decision> |
||||
<HttpHandlerProvider class="com.fr.plugin.third.party.jsdibhg.MultiLdapOperateHandlerBridge"/> |
||||
<URLAliasProvider class="com.fr.plugin.third.party.jsdibhg.MultiLdapUrlAliasBridge"/> |
||||
<PassportProvider class="com.fr.plugin.third.party.jsdibhg.MultiLdapPassportProvider"/> |
||||
<WebResourceProvider class="com.fr.plugin.third.party.jsdibhg.MultiLdapWebResourceProvider"/> |
||||
</extra-decision> |
||||
<extra-core> |
||||
<DBAccessProvider class="com.fr.plugin.third.party.jsdibhg.db.MultiLdapDBAccessBridge"/> |
||||
<LocaleFinder class="com.fr.plugin.third.party.jsdibhg.MultiLdapLocaleFinderBridge"/> |
||||
</extra-core> |
||||
<extra-designer> |
||||
<ServerTableDataDefineProvider class="com.fr.plugin.third.party.jsdibhg.data.CustomHttpTableDataDefine"/> |
||||
<TableDataDefineProvider class="com.fr.plugin.third.party.jsdibhg.data.CustomHttpTableDataDefine"/> |
||||
</extra-designer> |
||||
<lifecycle-monitor class="com.fr.plugin.third.party.jsdibhg.MultiLdapLifecycleMonitor"/> |
||||
</plugin> |
@ -0,0 +1,22 @@
|
||||
package com.fr.plugin.third.party.jsdibhg; |
||||
|
||||
import com.fr.decision.authorize.Passport; |
||||
import com.fr.decision.webservice.bean.authentication.PassportBean; |
||||
import com.fr.third.fasterxml.jackson.annotation.JsonSubTypes.Type; |
||||
|
||||
@Type(value = MultiLdapAuthenticBean.class, name = "MultiLdapAuthenticBean") |
||||
public class MultiLdapAuthenticBean extends PassportBean<MultiLdapPassport> { |
||||
public String markType() { |
||||
return "multiLdap"; |
||||
} |
||||
|
||||
public PassportBean<MultiLdapPassport> createPassportBean(MultiLdapPassport paramMultiLdapPassport) { |
||||
return this; |
||||
} |
||||
|
||||
public Passport createPassport() { |
||||
return (Passport)new MultiLdapPassport(); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,58 @@
|
||||
package com.fr.plugin.third.party.jsdibhg; |
||||
|
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.MultiLdapService; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.security.encryption.storage.trigger.EncryptionScene; |
||||
import com.fr.security.encryption.storage.trigger.EncryptionTrigger; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.collections.CollectionUtils; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
|
||||
import java.util.LinkedList; |
||||
import java.util.List; |
||||
|
||||
public class MultiLdapEncryptionTrigger extends EncryptionTrigger { |
||||
private static MultiLdapEncryptionTrigger instance = new MultiLdapEncryptionTrigger(); |
||||
|
||||
public static MultiLdapEncryptionTrigger getInstance() { |
||||
return instance; |
||||
} |
||||
|
||||
public List<EncryptionScene> getEncryptionSceneList() { |
||||
LinkedList<EncryptionScene> linkedList = new LinkedList(); |
||||
List<LdapPassportEntity> list = null; |
||||
try { |
||||
list = MultiLdapService.getLdap(QueryFactory.create().addRestriction(RestrictionFactory.neq("systemPassword", ""))); |
||||
} catch (Exception exception) { |
||||
FineLoggerFactory.getLogger().error("Get multiLdap config failed!"); |
||||
} |
||||
if (!CollectionUtils.isEmpty(list)) |
||||
list.forEach(ldapPassportEntity -> linkedList.add(new EncryptionScene() { |
||||
public String getOriginCipherText() { |
||||
return ldapPassportEntity.getSystemPassword(); |
||||
} |
||||
|
||||
public void setNewCipherText(String param1String) { |
||||
ldapPassportEntity.setSystemPassword(param1String); |
||||
try { |
||||
MultiLdapService.update(ldapPassportEntity); |
||||
} catch (Exception exception) { |
||||
FineLoggerFactory.getLogger().error("Update multiLdap config failed!"); |
||||
} |
||||
} |
||||
})); |
||||
return linkedList; |
||||
} |
||||
|
||||
public String errorLogInfo() { |
||||
return "Failed to replace the password of multiLdap!"; |
||||
} |
||||
|
||||
public boolean equals(Object paramObject) { |
||||
return StringUtils.equals(getClass().getName(), paramObject.getClass().getName()); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.fr.plugin.third.party.jsdibhg; |
||||
|
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor; |
||||
import com.fr.security.encryption.storage.trigger.EncryptionTriggerManager; |
||||
|
||||
public class MultiLdapLifecycleMonitor extends AbstractPluginLifecycleMonitor { |
||||
public void afterRun(PluginContext paramPluginContext) { |
||||
EncryptionTriggerManager.getInstance().getEncryptionTriggerList().remove(MultiLdapEncryptionTrigger.getInstance()); |
||||
EncryptionTriggerManager.getInstance().register(MultiLdapEncryptionTrigger.getInstance()); |
||||
} |
||||
|
||||
public void beforeUninstall(PluginContext paramPluginContext) { |
||||
/* |
||||
//卸载清空数据
|
||||
try { |
||||
MultiLdapService.removeLdap(QueryFactory.create().addRestriction(RestrictionFactory.neq("id", ""))); |
||||
} catch (Exception exception) { |
||||
FineLoggerFactory.getLogger().error(exception.getMessage(), exception); |
||||
} |
||||
final Map<OperationType, AbstractPassport> passports = FSConfig.getInstance().getPassports(); |
||||
Configurations.update(new Worker() { |
||||
public void run() { |
||||
passports.forEach((param1OperationType, param1AbstractPassport) -> { |
||||
if (StringUtils.equals(param1AbstractPassport.markType(), "multiLdap")) |
||||
FSConfig.getInstance().setPassport(param1OperationType, (AbstractPassport) new DefaultPassport()); |
||||
}); |
||||
} |
||||
|
||||
public Class<? extends Configuration>[] targets() { |
||||
return (Class<? extends Configuration>[]) new Class[]{FSConfig.class}; |
||||
} |
||||
}); |
||||
EncryptionTriggerManager.getInstance().getEncryptionTriggerList().remove(MultiLdapEncryptionTrigger.getInstance()); |
||||
|
||||
*/ |
||||
} |
||||
|
||||
public void beforeStop(PluginContext paramPluginContext) {} |
||||
} |
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.fr.plugin.third.party.jsdibhg; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
public class MultiLdapLocaleFinderBridge extends AbstractLocaleFinder { |
||||
public String find() { |
||||
return "com/fr/plugin/third/party/jsdibhg/locale/passport"; |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.fr.plugin.third.party.jsdibhg; |
||||
|
||||
import com.fr.decision.fun.HttpHandler; |
||||
import com.fr.decision.fun.impl.AbstractHttpHandlerProvider; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.http.*; |
||||
|
||||
public class MultiLdapOperateHandlerBridge extends AbstractHttpHandlerProvider { |
||||
public HttpHandler[] registerHandlers() { |
||||
return new HttpHandler[] { (HttpHandler)new AddMultiLdapAction(), (HttpHandler)new RemoveMultiLdapAction(), (HttpHandler)new UpdateMultiLdapAction(), (HttpHandler)new GetMultiLdapAction(), (HttpHandler)new TestConnectionAction() }; |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,60 @@
|
||||
package com.fr.plugin.third.party.jsdibhg; |
||||
|
||||
import com.fr.config.Identifier; |
||||
import com.fr.config.holder.Conf; |
||||
import com.fr.config.holder.factory.Holders; |
||||
import com.fr.decision.authority.AuthorityContext; |
||||
import com.fr.decision.authority.data.User; |
||||
import com.fr.decision.authorize.impl.AbstractPassport; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.third.party.jsdibhg.data.ldap.LdapTicket; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.MultiLdapService; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.stable.collections.CollectionUtils; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class MultiLdapPassport extends AbstractPassport { |
||||
@Identifier("type") |
||||
private Conf<String> type = Holders.simple("multiLdap"); |
||||
|
||||
public String markType() { |
||||
return "multiLdap"; |
||||
} |
||||
|
||||
public boolean checkTicket(String username, String inputPassword, String savedPassword, String hashPassword) { |
||||
List<LdapPassportEntity> list = null; |
||||
try { |
||||
User user = (User) AuthorityContext.getInstance().getUserController().findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("userName", username))); |
||||
list = MultiLdapService.getLdap(QueryFactory.create().addRestriction(RestrictionFactory.eq("creationType", Integer.valueOf(user.getCreationType().toInteger()))).addSort("createTime", true)); |
||||
} catch (Exception exception) { |
||||
FineLoggerFactory.getLogger().error("Get passport config error", exception); |
||||
} |
||||
if (CollectionUtils.isEmpty(list)) |
||||
return false; |
||||
|
||||
LdapTicket ldapTicket; |
||||
for (LdapPassportEntity ldapPassportEntity : list) { |
||||
ldapTicket = new LdapTicket(ldapPassportEntity); |
||||
if (ldapTicket.checkTicket(username, inputPassword, savedPassword, hashPassword)) { |
||||
return true; |
||||
} |
||||
|
||||
//if (ldapPassportEntity.createPassport().checkTicket(username, inputPassword, savedPassword, hashPassword))
|
||||
// return true;
|
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public String getType() { |
||||
return (String) this.type.get(); |
||||
} |
||||
|
||||
public void setType(String paramString) { |
||||
this.type.set(paramString); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.fr.plugin.third.party.jsdibhg; |
||||
|
||||
import com.fr.decision.authorize.Passport; |
||||
import com.fr.decision.fun.impl.AbstractPassportProvider; |
||||
import com.fr.decision.webservice.bean.authentication.PassportBean; |
||||
|
||||
public class MultiLdapPassportProvider extends AbstractPassportProvider { |
||||
public static final String PASSPORT_TYPE = "multiLdap"; |
||||
|
||||
public String passportType() { |
||||
return "multiLdap"; |
||||
} |
||||
|
||||
public Class<? extends PassportBean> classForPassportBean() { |
||||
return (Class) MultiLdapAuthenticBean.class; |
||||
} |
||||
|
||||
public Class<? extends Passport> classForPassportConfig() { |
||||
return (Class) MultiLdapPassport.class; |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.fr.plugin.third.party.jsdibhg; |
||||
|
||||
import com.fanruan.api.net.URLAliasKit; |
||||
import com.fr.decision.fun.impl.AbstractURLAliasProvider; |
||||
import com.fr.decision.webservice.url.alias.URLAlias; |
||||
|
||||
public class MultiLdapUrlAliasBridge extends AbstractURLAliasProvider { |
||||
public URLAlias[] registerAlias() { |
||||
return new URLAlias[] { URLAliasKit.createPluginAlias("/multi/ldap", "/multi/ldap", false), URLAliasKit.createPluginAlias("/ldap/test", "/ldap/test", false) }; |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.fr.plugin.third.party.jsdibhg; |
||||
|
||||
import com.fr.decision.fun.impl.AbstractWebResourceProvider; |
||||
import com.fr.decision.web.MainComponent; |
||||
import com.fr.web.struct.Atom; |
||||
import com.fr.web.struct.Component; |
||||
import com.fr.web.struct.browser.RequestClient; |
||||
import com.fr.web.struct.category.ScriptPath; |
||||
import com.fr.web.struct.category.StylePath; |
||||
|
||||
public class MultiLdapWebResourceProvider extends AbstractWebResourceProvider { |
||||
public Atom attach() { |
||||
return (Atom)MainComponent.KEY; |
||||
} |
||||
|
||||
public Atom client() { |
||||
return (Atom)new Component() { |
||||
public ScriptPath script(RequestClient param1RequestClient) { |
||||
return ScriptPath.build("/com/fr/plugin/third/party/jsdibhg/js/plugin.min.js"); |
||||
} |
||||
|
||||
public StylePath style(RequestClient param1RequestClient) { |
||||
return StylePath.build("/com/fr/plugin/third/party/jsdibhg/css/plugin.min.css"); |
||||
} |
||||
}; |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,156 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.data; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.base.TableData; |
||||
import com.fr.data.AbstractDataModel; |
||||
import com.fr.general.data.TableDataException; |
||||
import com.fr.plugin.third.party.jsdibhg.data.ldap.LdapInfo; |
||||
import com.fr.plugin.third.party.jsdibhg.data.ldap.LdapInfoWithJava; |
||||
import com.fr.plugin.third.party.jsdibhg.data.ldap.LdapObject; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.MultiLdapService; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.stable.query.QueryFactory; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class CustomHttpDataModel extends AbstractDataModel { |
||||
private static String[] COLUMN_NAMES = {"user_id", "username", "password", "mail", "mobile", "dept_name", "job_title", "description"}; |
||||
private int rowCount = TableData.RESULT_ALL; |
||||
private DatasetData datas = new DatasetData(); |
||||
|
||||
public CustomHttpDataModel(int count) { |
||||
this.rowCount = count; |
||||
if (this.rowCount == 0) { |
||||
return; |
||||
} |
||||
queryData(); |
||||
} |
||||
|
||||
@Override |
||||
public int getColumnCount() throws TableDataException { |
||||
return COLUMN_NAMES.length; |
||||
} |
||||
|
||||
@Override |
||||
public String getColumnName(int i) throws TableDataException { |
||||
return COLUMN_NAMES[i]; |
||||
} |
||||
|
||||
@Override |
||||
public boolean hasRow(int rowIndex) throws TableDataException { |
||||
int count = getRowCount(); |
||||
return rowIndex < count; |
||||
} |
||||
|
||||
@Override |
||||
public int getRowCount() throws TableDataException { |
||||
if (this.datas == null) { |
||||
return 0; |
||||
} |
||||
List<List<Object>> values = this.datas.getValues(); |
||||
if (values == null) { |
||||
return 0; |
||||
} |
||||
int count = values.size(); |
||||
return count; |
||||
} |
||||
|
||||
@Override |
||||
public Object getValueAt(int rowIndex, int columnIndex) throws TableDataException { |
||||
if (this.datas == null) { |
||||
return ""; |
||||
} |
||||
List<List<Object>> values = this.datas.getValues(); |
||||
if ((values == null) || (values.size() <= rowIndex)) { |
||||
return ""; |
||||
} |
||||
List<Object> rowValues = values.get(rowIndex); |
||||
if ((rowValues == null) || (rowValues.size() <= columnIndex)) { |
||||
return ""; |
||||
} |
||||
return rowValues.get(columnIndex); |
||||
} |
||||
|
||||
@Override |
||||
public void release() throws Exception { |
||||
this.datas = null; |
||||
} |
||||
|
||||
/** |
||||
* 查询数据 |
||||
*/ |
||||
private void queryData() { |
||||
try { |
||||
createDatas(); |
||||
if (getRowCount() <= 0) { |
||||
throw new NullPointerException("LDAP数据集获取用户信息为空"); |
||||
} |
||||
} catch (Exception e) { |
||||
LogKit.error("LDAP数据集获取用户信息,请求出错," + e.getMessage() + "," + e.getCause(), e); |
||||
throw new NullPointerException("LDAP数据集获取用户信息,请求出错," + e.getMessage() + "," + e.getCause()); |
||||
} |
||||
} |
||||
|
||||
private void createDatas() throws Exception { |
||||
String deptName = "", jobTitle = "", userId = "", userName = "", password = "", mobile = "", mail = "", userDesc = ""; |
||||
|
||||
List<LdapPassportEntity> ldapCons = MultiLdapService.getLdap(QueryFactory.create()); |
||||
if ((ldapCons == null) || (ldapCons.size() <= 0)) { |
||||
return; |
||||
} |
||||
|
||||
LdapInfoWithJava ldapInfo; |
||||
for (int j = 0, jMax = ldapCons.size() - 1; j <= jMax; j++) { |
||||
ldapInfo = new LdapInfoWithJava(); |
||||
ldapInfo.setLdapPassportEntity(ldapCons.get(j)); |
||||
ldapInfo.queryData(); |
||||
List<LdapObject> ldapObjects = ldapInfo.getLdapObjects(); |
||||
LdapObject tempLdapObject, tempLdapObject1, tempLdapObject2; |
||||
for (int i = 0, max = ldapObjects.size() - 1; i <= max; i++) { |
||||
userId = ""; |
||||
userName = ""; |
||||
password = "111111"; |
||||
mail = ""; |
||||
mobile = ""; |
||||
deptName = ""; |
||||
jobTitle = ""; |
||||
userDesc = ""; |
||||
tempLdapObject = ldapObjects.get(i); |
||||
if (tempLdapObject.isPerson()) { |
||||
LogKit.info("ldap 生成用户信息 :" + i); |
||||
userId = tempLdapObject.getUserId(); |
||||
userId = userId.trim(); |
||||
if (StringKit.isEmpty(userId)) { |
||||
continue; |
||||
} |
||||
userName = tempLdapObject.getName(); |
||||
mail = tempLdapObject.getMail(); |
||||
|
||||
mobile = tempLdapObject.getMobile(); |
||||
deptName = tempLdapObject.getDept(); |
||||
jobTitle = tempLdapObject.getJobTitle(); |
||||
userDesc = tempLdapObject.getUserDesc(); |
||||
addRowDatas(userId, userName, password, mail, mobile, deptName, jobTitle, userDesc); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
// {"dept_name", "job_title", "user_id", "username", "password", "mobile", "mail", "code", "fcode"};
|
||||
private void addRowDatas(String userId, String userName, String password, String mail, String mobile, String deptName, String jobTitle, String userDesc) { |
||||
List<Object> rowDatas = new ArrayList<>(); |
||||
rowDatas.add(userId); |
||||
rowDatas.add(userName); |
||||
rowDatas.add(password); |
||||
rowDatas.add(mail); |
||||
rowDatas.add(mobile); |
||||
rowDatas.add(deptName); |
||||
rowDatas.add(jobTitle); |
||||
rowDatas.add(userDesc); |
||||
List<List<Object>> values = this.datas.getValues(); |
||||
values.add(rowDatas); |
||||
} |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.data; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.data.AbstractParameterTableData; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.script.Calculator; |
||||
|
||||
public class CustomHttpTableData extends AbstractParameterTableData { |
||||
@Override |
||||
public DataModel createDataModel(Calculator calculator) { |
||||
return createDataModel(calculator, TableData.RESULT_ALL); |
||||
} |
||||
|
||||
@Override |
||||
public DataModel createDataModel(Calculator calculator, int rowCount) { |
||||
return new CustomHttpDataModel(rowCount); |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.data; |
||||
|
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; |
||||
import com.fr.design.fun.ServerTableDataDefineProvider; |
||||
import com.fr.design.fun.impl.AbstractTableDataDefineProvider; |
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
|
||||
public class CustomHttpTableDataDefine extends AbstractTableDataDefineProvider implements ServerTableDataDefineProvider { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends TableData> classForTableData() { |
||||
return CustomHttpTableData.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends TableData> classForInitTableData() { |
||||
return CustomHttpTableData.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends AbstractTableDataPane> appearanceForTableData() { |
||||
|
||||
return CustomHttpTableDataPane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForTableData() { |
||||
return Toolkit.i18nText("多域LDAP数据集"); |
||||
} |
||||
|
||||
@Override |
||||
public String prefixForTableData() { |
||||
return "ldap"; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForTableData() { |
||||
return ""; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,76 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.data; |
||||
|
||||
import com.fanruan.api.design.DesignKit; |
||||
import com.fanruan.api.design.ui.component.UIButton; |
||||
import com.fr.design.data.datapane.preview.PreviewTablePane; |
||||
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; |
||||
import com.fr.general.IOUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
|
||||
public class CustomHttpTableDataPane extends AbstractTableDataPane<CustomHttpTableData> { |
||||
public CustomHttpTableDataPane() { |
||||
super(); |
||||
createContent(); |
||||
} |
||||
|
||||
|
||||
|
||||
@Override |
||||
public void populateBean(CustomHttpTableData ob) { |
||||
if (ob == null) { |
||||
return; |
||||
} |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public CustomHttpTableData updateBean() { |
||||
CustomHttpTableData tableData = new CustomHttpTableData(); |
||||
return tableData; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return DesignKit.i18nText("多域LDAP数据集"); |
||||
} |
||||
|
||||
|
||||
private void createContent() { |
||||
setLayout(new BorderLayout()); |
||||
JPanel contentPane = new JPanel(); |
||||
contentPane.setLayout(new BorderLayout()); |
||||
add(contentPane, BorderLayout.CENTER); |
||||
|
||||
|
||||
JPanel connectionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 5)); |
||||
|
||||
UIButton previewButton = createIconButton("Fine-Design_Basic_Preview", "/com/fr/design/images/m_file/preview.png"); |
||||
previewButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
PreviewTablePane.previewTableData(updateBean()); |
||||
} |
||||
}); |
||||
connectionPanel.add(previewButton); |
||||
contentPane.add(connectionPanel, BorderLayout.NORTH); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 获取图标按钮 |
||||
* |
||||
* @param toolTip 提示信息,国际化key |
||||
* @param iconPath 图标路径 |
||||
* @return |
||||
*/ |
||||
public static UIButton createIconButton(String toolTip, String iconPath) { |
||||
UIButton iconButton = new UIButton(IOUtils.readIcon(iconPath)); |
||||
iconButton.setToolTipText(DesignKit.i18nText(toolTip)); |
||||
return iconButton; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,67 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.data; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 数据集数据 |
||||
*/ |
||||
public class DatasetData { |
||||
private String name; |
||||
private List<String> columns; |
||||
private List<List<Object>> values; |
||||
|
||||
public DatasetData() { |
||||
columns = new ArrayList<String>(); |
||||
values = new ArrayList<List<Object>>(); |
||||
} |
||||
|
||||
/** |
||||
* 获取表名 |
||||
* @return 表名 |
||||
*/ |
||||
public String getName() { |
||||
return this.name; |
||||
} |
||||
|
||||
/** |
||||
* 设置表名 |
||||
* @param name 表名 |
||||
*/ |
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
/** |
||||
* 获取列名 |
||||
* @return 列名 |
||||
*/ |
||||
public List<String> getColumns() { |
||||
return this.columns; |
||||
} |
||||
|
||||
/** |
||||
* 设置列名 |
||||
* @param columns 列名 |
||||
*/ |
||||
public void setColumns(List<String> columns) { |
||||
this.columns = columns; |
||||
} |
||||
|
||||
/** |
||||
* 获取表数据 |
||||
* @return 表数据 |
||||
*/ |
||||
public List<List<Object>> getValues() { |
||||
return this.values; |
||||
} |
||||
|
||||
/** |
||||
* 设置表数据 |
||||
* @param values |
||||
*/ |
||||
public void setValues(List<List<Object>> values) { |
||||
this.values = values; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,238 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.data.ldap; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.security.encryption.storage.StorageEncryptors; |
||||
import com.novell.ldap.*; |
||||
|
||||
import java.io.UnsupportedEncodingException; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class LdapInfo { |
||||
private String hostName = "localhost"; |
||||
private int port = 389; |
||||
private String userDN = "cn=Manager,dc=micmiu,dc=com"; |
||||
private String password = "secret"; |
||||
private String baseDN = "dc=micmiu,dc=com"; |
||||
private String searchFilter = "objectClass=*"; |
||||
|
||||
private String ldapUrl; |
||||
|
||||
private LdapPassportEntity ldapEntity; |
||||
|
||||
private List<LdapObject> ldapObjects = new ArrayList<>(); |
||||
private Map<String, LdapObject> orgMap = new HashMap<>(); |
||||
|
||||
public void queryData() throws Exception { |
||||
//this.hostName = CustomDataConfig.getInstance().getHostname();
|
||||
//this.port = CustomDataConfig.getInstance().getPort();
|
||||
//this.userDN = CustomDataConfig.getInstance().getUserDN();
|
||||
//this.password = CustomDataConfig.getInstance().getPassword();
|
||||
//this.baseDN = CustomDataConfig.getInstance().getBaseDN();
|
||||
if (this.ldapEntity == null) { |
||||
return; |
||||
} |
||||
|
||||
|
||||
setDatas(); |
||||
|
||||
LDAPConnection lc = createConnection(); |
||||
|
||||
LogKit.error("LDAP数据集获取用户信息,bind..."); |
||||
LDAPSearchConstraints ldsc = new LDAPSearchConstraints(); |
||||
ldsc.setReferralFollowing(false); |
||||
//ldsc.setReferralFollowing(true);
|
||||
ldsc.setMaxResults(100000); |
||||
lc.setConstraints(ldsc); |
||||
String filter = "(" + this.ldapEntity.getUserIdColumnName() + "=*)"; |
||||
// 查询范围
|
||||
// SCOPE_BASE、SCOPE_ONE、SCOPE_SUB、SCOPE_SUBORDINATESUBTREE
|
||||
int searchScope = LDAPConnection.SCOPE_SUB; |
||||
LDAPSearchResults searchResults = lc.search(baseDN,searchScope, filter, null, false); |
||||
LDAPEntry nextEntry = null; |
||||
LdapObject ldapObject; |
||||
int count = 0; |
||||
while (searchResults.hasMore()) { |
||||
count++; |
||||
LogKit.error("LDAP数据集获取用户信息,searchResults..." + count); |
||||
try { |
||||
nextEntry = searchResults.next(); |
||||
} catch (LDAPReferralException e) { |
||||
LogKit.error("LDAP数据集获取用户信息,searchResults...Referral" + count); |
||||
continue; |
||||
} |
||||
ldapObject = new LdapObject(); |
||||
ldapObject.setUserIdColumn(this.ldapEntity.getUserIdColumnName()); |
||||
ldapObject.setUsernameColumn(this.ldapEntity.getUserNameColumnName()); |
||||
ldapObject.setEmailColumn(this.ldapEntity.getUserEmailColumnName()); |
||||
|
||||
ldapObject.setMobileColumn(this.ldapEntity.getUserMobileColumnName()); |
||||
ldapObject.setDeptColumn(this.ldapEntity.getUserDeptColumnName()); |
||||
ldapObject.setJobTitleColumn(this.ldapEntity.getUserTitleColumnName()); |
||||
ldapObject.setDescColumn(this.ldapEntity.getUserDescColumnName()); |
||||
|
||||
LogKit.error("LDAP数据集获取用户信息,loadData..." + count); |
||||
ldapObject.loadData(nextEntry); |
||||
if (!ldapObject.isValidOption()) { |
||||
continue; |
||||
} |
||||
if (ldapObject.isPerson()) { |
||||
ldapObjects.add(ldapObject); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public LDAPConnection createConnection() throws LDAPException, UnsupportedEncodingException { |
||||
LogKit.error("LDAP数据集获取用户信息,hostName:" + this.hostName); |
||||
LogKit.error("LDAP数据集获取用户信息,port:" + this.port); |
||||
LogKit.error("LDAP数据集获取用户信息,userDN:" + this.userDN); |
||||
LogKit.error("LDAP数据集获取用户信息,password:" + this.password); |
||||
LogKit.error("LDAP数据集获取用户信息,baseDN:" + this.baseDN); |
||||
|
||||
//超时30秒
|
||||
int timeout = 30000; |
||||
LDAPConnection lc = new LDAPConnection(timeout); |
||||
lc.connect(this.hostName, this.port); |
||||
LogKit.error("LDAP数据集获取用户信息,connect..."); |
||||
lc.bind(LDAPConnection.LDAP_V3, this.userDN, this.password.getBytes("UTF8")); |
||||
return lc; |
||||
} |
||||
|
||||
public void setDatas() { |
||||
setLdapUrl(this.ldapEntity.getUrl()); |
||||
setUserDN(this.ldapEntity.getSystemName()); |
||||
setPassword(StorageEncryptors.getInstance().decrypt(this.ldapEntity.getSystemPassword())); |
||||
setBaseDN(this.ldapEntity.getSearchBase()); |
||||
createHostNameAndPort(); |
||||
} |
||||
|
||||
|
||||
public boolean login() throws Exception { |
||||
if (this.ldapEntity == null) { |
||||
return false; |
||||
} |
||||
|
||||
LogKit.error("LDAP登录,createConnection..."); |
||||
LDAPConnection lc = createConnection(); |
||||
|
||||
LogKit.error("LDAP登录,bind..."); |
||||
LDAPSearchConstraints ldsc = new LDAPSearchConstraints(); |
||||
ldsc.setReferralFollowing(false); |
||||
//ldsc.setReferralFollowing(true);
|
||||
ldsc.setMaxResults(100000); |
||||
lc.setConstraints(ldsc); |
||||
String filter = "(" + this.ldapEntity.getUserIdColumnName() + "=" + this.userDN + ")"; |
||||
LogKit.error("LDAP登录,filter:" + filter); |
||||
// 查询范围
|
||||
// SCOPE_BASE、SCOPE_ONE、SCOPE_SUB、SCOPE_SUBORDINATESUBTREE
|
||||
int searchScope = LDAPConnection.SCOPE_SUB; |
||||
LDAPSearchResults searchResults = lc.search(baseDN, |
||||
searchScope, filter, null, false); |
||||
if (searchResults.hasMore()) { |
||||
LogKit.error("LDAP登录,true..."); |
||||
return true; |
||||
} |
||||
LogKit.error("LDAP登录,false..."); |
||||
return false; |
||||
} |
||||
|
||||
|
||||
private void createHostNameAndPort() { |
||||
setPort(389); |
||||
String url = getLdapUrl(); |
||||
if (StringKit.isEmpty(url)) { |
||||
return; |
||||
} |
||||
url = url.trim(); |
||||
if (StringKit.isEmpty(url)) { |
||||
return; |
||||
} |
||||
|
||||
int index = url.indexOf("//"); |
||||
if (index < 0) { |
||||
return; |
||||
} |
||||
String tempValue; |
||||
int index1 = url.indexOf(":", index + 1); |
||||
if (index1 < 0) { |
||||
tempValue = url.substring(index + 2); |
||||
setHostName(tempValue); |
||||
return; |
||||
} else { |
||||
tempValue = url.substring(index + 2, index1); |
||||
setHostName(tempValue); |
||||
} |
||||
|
||||
tempValue = url.substring(index1 + 1); |
||||
int tempPort = Integer.valueOf(tempValue); |
||||
setPort(tempPort); |
||||
} |
||||
|
||||
public List<LdapObject> getLdapObjects() { |
||||
return ldapObjects; |
||||
} |
||||
|
||||
public Map<String, LdapObject> getOrgMap() { |
||||
return orgMap; |
||||
} |
||||
|
||||
public String getHostName() { |
||||
return hostName; |
||||
} |
||||
|
||||
public void setHostName(String hostName) { |
||||
this.hostName = hostName; |
||||
} |
||||
|
||||
public int getPort() { |
||||
return port; |
||||
} |
||||
|
||||
public void setPort(int port) { |
||||
this.port = port; |
||||
} |
||||
|
||||
public String getUserDN() { |
||||
return userDN; |
||||
} |
||||
|
||||
public void setUserDN(String userDN) { |
||||
this.userDN = userDN; |
||||
} |
||||
|
||||
public String getPassword() { |
||||
return password; |
||||
} |
||||
|
||||
public void setPassword(String password) { |
||||
this.password = password; |
||||
} |
||||
|
||||
public String getBaseDN() { |
||||
return baseDN; |
||||
} |
||||
|
||||
public void setBaseDN(String baseDN) { |
||||
this.baseDN = baseDN; |
||||
} |
||||
|
||||
public String getLdapUrl() { |
||||
return ldapUrl; |
||||
} |
||||
|
||||
public void setLdapUrl(String ldapUrl) { |
||||
this.ldapUrl = ldapUrl; |
||||
} |
||||
|
||||
public LdapPassportEntity getLdapPassportEntity() { |
||||
return ldapEntity; |
||||
} |
||||
|
||||
public void setLdapPassportEntity(LdapPassportEntity ldapPassportEntity) { |
||||
this.ldapEntity = ldapPassportEntity; |
||||
} |
||||
} |
@ -0,0 +1,341 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.data.ldap; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.security.encryption.storage.StorageEncryptors; |
||||
import com.novell.ldap.*; |
||||
|
||||
import javax.naming.Context; |
||||
import javax.naming.NamingEnumeration; |
||||
import javax.naming.directory.Attribute; |
||||
import javax.naming.directory.SearchControls; |
||||
import javax.naming.directory.SearchResult; |
||||
import javax.naming.ldap.*; |
||||
import java.io.UnsupportedEncodingException; |
||||
import java.util.*; |
||||
|
||||
public class LdapInfoWithJava { |
||||
private String hostName = "localhost"; |
||||
private int port = 389; |
||||
private String userDN = "cn=Manager,dc=micmiu,dc=com"; |
||||
private String password = "secret"; |
||||
private String baseDN = "dc=micmiu,dc=com"; |
||||
private String searchFilter = "objectClass=*"; |
||||
|
||||
private String ldapUrl; |
||||
|
||||
private LdapPassportEntity ldapEntity; |
||||
|
||||
private List<LdapObject> ldapObjects = new ArrayList<>(); |
||||
private Map<String, LdapObject> orgMap = new HashMap<>(); |
||||
|
||||
public void queryData() throws Exception { |
||||
if (this.ldapEntity == null) { |
||||
return; |
||||
} |
||||
setDatas(); |
||||
|
||||
String refeeral = this.ldapEntity.getReferral(); |
||||
String url = this.ldapEntity.getUrl(); |
||||
String basedn = this.baseDN; // basedn
|
||||
String factory = this.ldapEntity.getContextFactory(); |
||||
String principalSuffix = this.ldapEntity.getPrincipalSuffix(); |
||||
String root = this.userDN; // 用户
|
||||
if (StringKit.isNotEmpty(principalSuffix)) { |
||||
root = root + principalSuffix; |
||||
} |
||||
|
||||
// String pwd = this.ldapEntity.getLdapSystemPassword(); // pwd
|
||||
String pwd = this.password; |
||||
String simple = this.ldapEntity.getAuthentication(); |
||||
Hashtable<String, String> env = new Hashtable<String, String>(); |
||||
env.put(Context.INITIAL_CONTEXT_FACTORY, factory); |
||||
env.put(Context.PROVIDER_URL, url); |
||||
env.put(Context.SECURITY_AUTHENTICATION, simple); |
||||
env.put(Context.SECURITY_PRINCIPAL, root); |
||||
env.put(Context.SECURITY_CREDENTIALS, pwd); |
||||
env.put(Context.REFERRAL, refeeral); |
||||
LdapContext ctx = null; |
||||
Control[] connCtls = null; |
||||
try { |
||||
ctx = new InitialLdapContext(env, connCtls); |
||||
//System.out.println("认证成功");
|
||||
} catch (javax.naming.AuthenticationException e) { |
||||
System.out.println("认证失败:"); |
||||
LogKit.error(e.getMessage(), e); |
||||
return; |
||||
} catch (Exception e) { |
||||
System.out.println("认证出错:"); |
||||
LogKit.error(e.getMessage(), e); |
||||
return; |
||||
} |
||||
LogKit.info("ldap 认证通过"); |
||||
int userCount = 0; |
||||
try { |
||||
int pageSize = 1000; //设定LDAP每次分页所取的资料笔数
|
||||
byte[] cookie = null; |
||||
//过滤条件
|
||||
//String filter = "(&(sAMAccountName=*)(ObjectClass=user))";
|
||||
String filter = "(" + this.ldapEntity.getUserIdColumnName() + "=*)"; |
||||
LogKit.info("ldap 认证 filter:" + filter); |
||||
String[] attrPersonArray = {this.ldapEntity.getUserIdColumnName(), |
||||
this.ldapEntity.getUserNameColumnName(), |
||||
this.ldapEntity.getUserEmailColumnName(), |
||||
this.ldapEntity.getUserMobileColumnName(), |
||||
this.ldapEntity.getUserDeptColumnName(), |
||||
this.ldapEntity.getUserTitleColumnName(), |
||||
this.ldapEntity.getUserDescColumnName()}; |
||||
LogKit.info("ldap 认证attrPersonArray:" + attrPersonArray); |
||||
//String[] attrPersonArray = {"uid"};
|
||||
// String[] attrPersonArray = null;
|
||||
SearchControls searchControls = new SearchControls();//搜索控件
|
||||
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);//搜索范围
|
||||
searchControls.setReturningAttributes(attrPersonArray); |
||||
|
||||
ctx.setRequestControls(new Control[]{new PagedResultsControl(pageSize, Control.CRITICAL)}); |
||||
LdapObject ldapObject; |
||||
String attributeId; |
||||
String attributeValue; |
||||
String userPrefix = getUserPrefix(); |
||||
do { |
||||
//1.要搜索的上下文或对象的名称;2.过滤条件,可为null,默认搜索所有信息;3.搜索控件,可为null,使用默认的搜索控件
|
||||
NamingEnumeration<SearchResult> answer = ctx.search(basedn, filter, searchControls); |
||||
while (answer.hasMore()) { |
||||
SearchResult result = answer.next(); |
||||
NamingEnumeration<? extends Attribute> attrs = result.getAttributes().getAll(); |
||||
ldapObject = new LdapObject(); |
||||
while (attrs.hasMore()) { |
||||
Attribute attr = attrs.next(); |
||||
if (attr == null) { |
||||
continue; |
||||
} |
||||
attributeId = attr.getID(); |
||||
attributeValue = String.valueOf(attr.get()); |
||||
LogKit.info("ldap 获取用户信息 this.ldapEntity.getUserDescColumnName():" + this.ldapEntity.getUserDescColumnName()); |
||||
LogKit.info("ldap 获取用户信息 attributeId:" + attributeId); |
||||
LogKit.info("ldap 获取用户信息 attributeValue:" + attributeValue); |
||||
if (StringKit.equals(this.ldapEntity.getUserIdColumnName(), attributeId)) { |
||||
ldapObject.setUserId(attributeValue); |
||||
} else if (StringKit.equals(this.ldapEntity.getUserNameColumnName(), attributeId)) { |
||||
ldapObject.setName(attributeValue); |
||||
} else if (StringKit.equals(this.ldapEntity.getUserEmailColumnName(), attributeId)) { |
||||
ldapObject.setMail(attributeValue); |
||||
} else if (StringKit.equals(this.ldapEntity.getUserMobileColumnName(), attributeId)) { |
||||
ldapObject.setMobile(attributeValue); |
||||
} else if (StringKit.equals(this.ldapEntity.getUserDeptColumnName(), attributeId)) { |
||||
ldapObject.setDept(attributeValue); |
||||
} else if (StringKit.equals(this.ldapEntity.getUserTitleColumnName(), attributeId)) { |
||||
ldapObject.setJobTitle(attributeValue); |
||||
} else if (StringKit.equals(this.ldapEntity.getUserDescColumnName(), attributeId)) { |
||||
LogKit.info("ldap 获取用户信息 setUserDesc:" + attributeValue); |
||||
ldapObject.setUserDesc(attributeValue); |
||||
} |
||||
} |
||||
String userId = ldapObject.getUserId(); |
||||
if (StringKit.isEmpty(userId)) { |
||||
continue; |
||||
} |
||||
if (StringKit.isNotEmpty(userPrefix)) { |
||||
userId = userPrefix + "\\" + userId; |
||||
} |
||||
|
||||
userCount++; |
||||
LogKit.info("ldap 获取用户信息:" + userCount); |
||||
ldapObject.setUserId(userId.toLowerCase()); |
||||
ldapObject.setType(LdapObject.LDAP_OBJECT_TYPE_PERSON); |
||||
ldapObjects.add(ldapObject); |
||||
} |
||||
Control[] controls = ctx.getResponseControls(); |
||||
if (controls != null) { |
||||
for (int i = 0; i < controls.length; i++) { |
||||
if (controls[i] instanceof PagedResultsResponseControl) { |
||||
PagedResultsResponseControl prrc = |
||||
(PagedResultsResponseControl) controls[i]; |
||||
cookie = prrc.getCookie(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// 将cookie资讯提供给InitialLdapContext,让它在接下来的查询中进行换页
|
||||
ctx.setRequestControls(new Control[]{new PagedResultsControl( |
||||
pageSize, cookie, Control.CRITICAL)}); |
||||
|
||||
} while (cookie != null); |
||||
|
||||
|
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
try { |
||||
if (ctx != null) |
||||
ctx.close(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
private String getUserPrefix() { |
||||
if (this.ldapEntity == null) { |
||||
return ""; |
||||
} |
||||
|
||||
String tempValue = this.ldapEntity.getUserPrefix(); |
||||
tempValue = StringKit.trim(tempValue); |
||||
if (StringKit.isEmpty(tempValue)) { |
||||
return ""; |
||||
} |
||||
return tempValue; |
||||
} |
||||
|
||||
public LDAPConnection createConnection() throws LDAPException, UnsupportedEncodingException { |
||||
LogKit.error("LDAP数据集获取用户信息,hostName:" + this.hostName); |
||||
LogKit.error("LDAP数据集获取用户信息,port:" + this.port); |
||||
LogKit.error("LDAP数据集获取用户信息,userDN:" + this.userDN); |
||||
LogKit.error("LDAP数据集获取用户信息,password:" + this.password); |
||||
LogKit.error("LDAP数据集获取用户信息,baseDN:" + this.baseDN); |
||||
|
||||
//超时30秒
|
||||
int timeout = 30000; |
||||
LDAPConnection lc = new LDAPConnection(timeout); |
||||
lc.connect(this.hostName, this.port); |
||||
LogKit.error("LDAP数据集获取用户信息,connect..."); |
||||
lc.bind(LDAPConnection.LDAP_V3, this.userDN, this.password.getBytes("UTF8")); |
||||
return lc; |
||||
} |
||||
|
||||
public void setDatas() { |
||||
setLdapUrl(this.ldapEntity.getUrl()); |
||||
setUserDN(this.ldapEntity.getSystemName()); |
||||
setPassword(StorageEncryptors.getInstance().decrypt(this.ldapEntity.getSystemPassword())); |
||||
setBaseDN(this.ldapEntity.getSearchBase()); |
||||
createHostNameAndPort(); |
||||
} |
||||
|
||||
|
||||
public boolean login() throws Exception { |
||||
if (this.ldapEntity == null) { |
||||
return false; |
||||
} |
||||
|
||||
LogKit.error("LDAP登录,createConnection..."); |
||||
LDAPConnection lc = createConnection(); |
||||
|
||||
LogKit.error("LDAP登录,bind..."); |
||||
LDAPSearchConstraints ldsc = new LDAPSearchConstraints(); |
||||
ldsc.setReferralFollowing(false); |
||||
//ldsc.setReferralFollowing(true);
|
||||
ldsc.setMaxResults(100000); |
||||
lc.setConstraints(ldsc); |
||||
String filter = "(" + this.ldapEntity.getUserIdColumnName() + "=" + this.userDN + ")"; |
||||
LogKit.error("LDAP登录,filter:" + filter); |
||||
// 查询范围
|
||||
// SCOPE_BASE、SCOPE_ONE、SCOPE_SUB、SCOPE_SUBORDINATESUBTREE
|
||||
int searchScope = LDAPConnection.SCOPE_SUB; |
||||
LDAPSearchResults searchResults = lc.search(baseDN, |
||||
searchScope, filter, null, false); |
||||
if (searchResults.hasMore()) { |
||||
LogKit.error("LDAP登录,true..."); |
||||
return true; |
||||
} |
||||
LogKit.error("LDAP登录,false..."); |
||||
return false; |
||||
} |
||||
|
||||
|
||||
private void createHostNameAndPort() { |
||||
setPort(389); |
||||
String url = getLdapUrl(); |
||||
if (StringKit.isEmpty(url)) { |
||||
return; |
||||
} |
||||
url = url.trim(); |
||||
if (StringKit.isEmpty(url)) { |
||||
return; |
||||
} |
||||
|
||||
int index = url.indexOf("//"); |
||||
if (index < 0) { |
||||
return; |
||||
} |
||||
String tempValue; |
||||
int index1 = url.indexOf(":", index + 1); |
||||
if (index1 < 0) { |
||||
tempValue = url.substring(index + 2); |
||||
setHostName(tempValue); |
||||
return; |
||||
} else { |
||||
tempValue = url.substring(index + 2, index1); |
||||
setHostName(tempValue); |
||||
} |
||||
|
||||
tempValue = url.substring(index1 + 1); |
||||
int tempPort = Integer.valueOf(tempValue); |
||||
setPort(tempPort); |
||||
} |
||||
|
||||
public List<LdapObject> getLdapObjects() { |
||||
return ldapObjects; |
||||
} |
||||
|
||||
public Map<String, LdapObject> getOrgMap() { |
||||
return orgMap; |
||||
} |
||||
|
||||
public String getHostName() { |
||||
return hostName; |
||||
} |
||||
|
||||
public void setHostName(String hostName) { |
||||
this.hostName = hostName; |
||||
} |
||||
|
||||
public int getPort() { |
||||
return port; |
||||
} |
||||
|
||||
public void setPort(int port) { |
||||
this.port = port; |
||||
} |
||||
|
||||
public String getUserDN() { |
||||
return userDN; |
||||
} |
||||
|
||||
public void setUserDN(String userDN) { |
||||
this.userDN = userDN; |
||||
} |
||||
|
||||
public String getPassword() { |
||||
return password; |
||||
} |
||||
|
||||
public void setPassword(String password) { |
||||
this.password = password; |
||||
} |
||||
|
||||
public String getBaseDN() { |
||||
return baseDN; |
||||
} |
||||
|
||||
public void setBaseDN(String baseDN) { |
||||
this.baseDN = baseDN; |
||||
} |
||||
|
||||
public String getLdapUrl() { |
||||
return ldapUrl; |
||||
} |
||||
|
||||
public void setLdapUrl(String ldapUrl) { |
||||
this.ldapUrl = ldapUrl; |
||||
} |
||||
|
||||
public LdapPassportEntity getLdapPassportEntity() { |
||||
return ldapEntity; |
||||
} |
||||
|
||||
public void setLdapPassportEntity(LdapPassportEntity ldapPassportEntity) { |
||||
this.ldapEntity = ldapPassportEntity; |
||||
} |
||||
} |
@ -0,0 +1,310 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.data.ldap; |
||||
|
||||
import com.fanruan.api.util.StringKit; |
||||
import com.novell.ldap.LDAPAttribute; |
||||
import com.novell.ldap.LDAPEntry; |
||||
|
||||
public class LdapObject { |
||||
public static String LDAP_OBJECT_TYPE_ORG = "ORG"; |
||||
public static String LDAP_OBJECT_TYPE_PERSON = "PERSON"; |
||||
public static String LDAP_OBJECT_TYPE_NONE = "NONE"; |
||||
|
||||
private LDAPEntry ldapEntry; |
||||
|
||||
private String dn = ""; |
||||
private String type = ""; |
||||
private String objectGUID = ""; |
||||
private String name = ""; |
||||
|
||||
private String userId; |
||||
private String jobTitle; |
||||
private String mobile; |
||||
private String mail; |
||||
private String dept; |
||||
private String userDesc; |
||||
|
||||
private String parentDn = ""; |
||||
|
||||
private boolean validOption = false; |
||||
|
||||
private String userIdColumn; |
||||
private String usernameColumn; |
||||
private String emailColumn; |
||||
|
||||
private String mobileColumn; |
||||
private String deptColumn; |
||||
private String jobTitleColumn; |
||||
|
||||
private String descColumn; |
||||
private String userPrefix; |
||||
|
||||
public void loadData(LDAPEntry entry) { |
||||
setValidOption(false); |
||||
if (entry == null) { |
||||
return; |
||||
} |
||||
this.ldapEntry = entry; |
||||
setDn(this.ldapEntry.getDN()); |
||||
setType(createType()); |
||||
if (LDAP_OBJECT_TYPE_NONE.equals(this.type)) { |
||||
return; |
||||
} |
||||
|
||||
//String tempValue = getAttribute("objectGUID");
|
||||
//setObjectGUID(Base64.encode(tempValue.getBytes()));
|
||||
//tempValue = getAttribute("name");
|
||||
//setName(tempValue);
|
||||
|
||||
//setParentDn(createParentDn());
|
||||
//用户名(登录的username)
|
||||
//用户姓名(realname)
|
||||
//角色(对应域的usergroup)
|
||||
//邮箱
|
||||
String tempValue; |
||||
if (isPerson()) { |
||||
tempValue = getAttribute(getUserIdColumn()); |
||||
setUserId(tempValue); |
||||
tempValue = getAttribute(getUsernameColumn()); |
||||
setName(tempValue); |
||||
tempValue = getAttribute(getEmailColumn()); |
||||
setMail(tempValue); |
||||
|
||||
tempValue = getAttribute(getMobileColumn()); |
||||
setMobile(tempValue); |
||||
tempValue = getAttribute(getDeptColumn()); |
||||
setDept(tempValue); |
||||
tempValue = getAttribute(getJobTitleColumn()); |
||||
setJobTitle(tempValue); |
||||
tempValue = getAttribute(getDescColumn()); |
||||
setUserDesc(tempValue); |
||||
} |
||||
setValidOption(true); |
||||
} |
||||
|
||||
|
||||
private String getAttribute(String attrName) { |
||||
if (StringKit.isEmpty(attrName)) { |
||||
return ""; |
||||
} |
||||
|
||||
if ((this.ldapEntry == null) || (StringKit.isEmpty(attrName))) { |
||||
return ""; |
||||
} |
||||
LDAPAttribute ldapAttribute = this.ldapEntry.getAttribute(attrName); |
||||
if (ldapAttribute == null) { |
||||
return ""; |
||||
} |
||||
|
||||
String[] values = ldapAttribute.getStringValueArray(); |
||||
if ((values == null) || (values.length <= 0)) { |
||||
return ""; |
||||
} |
||||
String value = values[0]; |
||||
return value; |
||||
} |
||||
|
||||
private String createParentDn() { |
||||
if (StringKit.isEmpty(this.dn)) { |
||||
return ""; |
||||
} |
||||
int index = this.dn.indexOf(","); |
||||
if (index < 0) { |
||||
return ""; |
||||
} |
||||
String tempValue = this.dn.substring(index + 1); |
||||
return tempValue; |
||||
} |
||||
|
||||
|
||||
private String createType() { |
||||
if (StringKit.isEmpty(this.dn)) { |
||||
return LDAP_OBJECT_TYPE_NONE; |
||||
} |
||||
String tempDn = this.dn.toUpperCase(); |
||||
if (tempDn.startsWith("CN=")) { |
||||
return LDAP_OBJECT_TYPE_PERSON; |
||||
} else if (tempDn.startsWith("OU=")) { |
||||
return LDAP_OBJECT_TYPE_ORG; |
||||
} |
||||
return LDAP_OBJECT_TYPE_NONE; |
||||
} |
||||
|
||||
|
||||
public boolean isOrg() { |
||||
if (LDAP_OBJECT_TYPE_ORG.equals(this.type)) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public boolean isPerson() { |
||||
if (LDAP_OBJECT_TYPE_PERSON.equals(this.type)) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
|
||||
public String getDn() { |
||||
return dn; |
||||
} |
||||
|
||||
public void setDn(String dn) { |
||||
this.dn = dn; |
||||
} |
||||
|
||||
public String getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(String type) { |
||||
this.type = type; |
||||
} |
||||
|
||||
public boolean isValidOption() { |
||||
return validOption; |
||||
} |
||||
|
||||
public void setValidOption(boolean option) { |
||||
this.validOption = option; |
||||
} |
||||
|
||||
public String getObjectGUID() { |
||||
return objectGUID; |
||||
} |
||||
|
||||
public void setObjectGUID(String guid) { |
||||
this.objectGUID = guid; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getUserId() { |
||||
return userId; |
||||
} |
||||
|
||||
public void setUserId(String id) { |
||||
//if (StringKit.isNotEmpty(id)) {
|
||||
// id = id.toUpperCase();
|
||||
//}
|
||||
this.userId = id; |
||||
} |
||||
|
||||
public String getJobTitle() { |
||||
return jobTitle; |
||||
} |
||||
|
||||
public void setJobTitle(String jobTitle) { |
||||
this.jobTitle = jobTitle; |
||||
} |
||||
|
||||
public String getMobile() { |
||||
return mobile; |
||||
} |
||||
|
||||
public void setMobile(String mobile) { |
||||
this.mobile = mobile; |
||||
} |
||||
|
||||
public String getMail() { |
||||
return mail; |
||||
} |
||||
|
||||
public void setMail(String mail) { |
||||
this.mail = mail; |
||||
} |
||||
|
||||
public String getParentDn() { |
||||
return parentDn; |
||||
} |
||||
|
||||
public void setParentDn(String dn) { |
||||
this.parentDn = dn; |
||||
} |
||||
|
||||
public String getUserIdColumn() { |
||||
return userIdColumn; |
||||
} |
||||
|
||||
public void setUserIdColumn(String userIdColumn) { |
||||
this.userIdColumn = userIdColumn; |
||||
} |
||||
|
||||
public String getUsernameColumn() { |
||||
return usernameColumn; |
||||
} |
||||
|
||||
public void setUsernameColumn(String usernameColumn) { |
||||
this.usernameColumn = usernameColumn; |
||||
} |
||||
|
||||
public String getEmailColumn() { |
||||
return emailColumn; |
||||
} |
||||
|
||||
public void setEmailColumn(String emailColumn) { |
||||
this.emailColumn = emailColumn; |
||||
} |
||||
|
||||
public String getMobileColumn() { |
||||
return mobileColumn; |
||||
} |
||||
|
||||
public void setMobileColumn(String mobileColumn) { |
||||
this.mobileColumn = mobileColumn; |
||||
} |
||||
|
||||
public String getDeptColumn() { |
||||
return deptColumn; |
||||
} |
||||
|
||||
public void setDeptColumn(String deptColumn) { |
||||
this.deptColumn = deptColumn; |
||||
} |
||||
|
||||
public String getDept() { |
||||
return dept; |
||||
} |
||||
|
||||
public void setDept(String dept) { |
||||
this.dept = dept; |
||||
} |
||||
|
||||
public String getJobTitleColumn() { |
||||
return jobTitleColumn; |
||||
} |
||||
|
||||
public void setJobTitleColumn(String jobTitleColumn) { |
||||
this.jobTitleColumn = jobTitleColumn; |
||||
} |
||||
|
||||
public String getDescColumn() { |
||||
return descColumn; |
||||
} |
||||
|
||||
public void setDescColumn(String descColumn) { |
||||
this.descColumn = descColumn; |
||||
} |
||||
|
||||
public String getUserPrefix() { |
||||
return userPrefix; |
||||
} |
||||
|
||||
public void setUserPrefix(String userPrefix) { |
||||
this.userPrefix = userPrefix; |
||||
} |
||||
|
||||
public String getUserDesc() { |
||||
return userDesc; |
||||
} |
||||
|
||||
public void setUserDesc(String userDesc) { |
||||
this.userDesc = userDesc; |
||||
} |
||||
} |
@ -0,0 +1,67 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.data.ldap; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
public class LdapTicket { |
||||
private LdapPassportEntity ldapEntity; |
||||
|
||||
public LdapTicket() { |
||||
} |
||||
|
||||
public LdapTicket(LdapPassportEntity entity) { |
||||
this.setLdapEntity(entity); |
||||
} |
||||
|
||||
public boolean checkTicket(String username, String inputPassword, String savedPassword, String hashPassword) { |
||||
try { |
||||
if (StringUtils.isEmpty(inputPassword)) { |
||||
return false; |
||||
} |
||||
if (this.ldapEntity == null) { |
||||
return false; |
||||
} |
||||
|
||||
String tempUsername = username; |
||||
if (StringKit.isEmpty(tempUsername)) { |
||||
return false; |
||||
} |
||||
int index = tempUsername.indexOf("\\"); |
||||
String userPrefix = ""; |
||||
if (index >= 0) { |
||||
userPrefix = tempUsername.substring(0, index); |
||||
tempUsername = tempUsername.substring(index + 1); |
||||
} |
||||
|
||||
if (StringKit.isNotEmpty(userPrefix) && (!StringKit.equalsIgnoreCase(userPrefix, ldapEntity.getUserPrefix()))) { |
||||
return false; |
||||
} |
||||
|
||||
String suffix = this.ldapEntity.getPrincipalSuffix(); |
||||
if (StringKit.isNotEmpty(suffix)) { |
||||
tempUsername = tempUsername + suffix; |
||||
} |
||||
|
||||
LdapInfo ldapInfo = new LdapInfo(); |
||||
ldapInfo.setLdapPassportEntity(this.ldapEntity); |
||||
ldapInfo.setDatas(); |
||||
ldapInfo.setUserDN(tempUsername); |
||||
ldapInfo.setPassword(inputPassword); |
||||
ldapInfo.createConnection(); |
||||
return true; |
||||
} catch (Exception e) { |
||||
LogKit.info("ldap ticket error"); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public LdapPassportEntity getLdapEntity() { |
||||
return ldapEntity; |
||||
} |
||||
|
||||
public void setLdapEntity(LdapPassportEntity ldapEntity) { |
||||
this.ldapEntity = ldapEntity; |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.db; |
||||
|
||||
import com.fr.db.fun.impl.AbstractDBAccessProvider; |
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.LdapPassportDAO; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.stable.db.accessor.DBAccessor; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.dao.DAOProvider; |
||||
|
||||
@EnableMetrics |
||||
public class MultiLdapDBAccessBridge extends AbstractDBAccessProvider { |
||||
private static DBAccessor dbAccessor = null; |
||||
|
||||
@Focus(id = "com.fr.plugin.third.party.jsd8176", text = "plugin-jsd-8176", source = Original.PLUGIN) |
||||
public static DBAccessor getDbAccessor() { |
||||
return dbAccessor; |
||||
} |
||||
|
||||
public DAOProvider[] registerDAO() { |
||||
return new DAOProvider[] { new DAOProvider() { |
||||
public Class getEntityClass() { |
||||
return LdapPassportEntity.class; |
||||
} |
||||
|
||||
public Class<? extends BaseDAO> getDAOClass() { |
||||
return (Class) LdapPassportDAO.class; |
||||
} |
||||
} }; |
||||
} |
||||
|
||||
public void onDBAvailable(DBAccessor paramDBAccessor) { |
||||
dbAccessor = paramDBAccessor; |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.db.fun; |
||||
|
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.stable.db.dao.BaseDAO; |
||||
import com.fr.stable.db.session.DAOSession; |
||||
|
||||
public class LdapPassportDAO extends BaseDAO<LdapPassportEntity> { |
||||
public LdapPassportDAO(DAOSession paramDAOSession) { |
||||
super(paramDAOSession); |
||||
} |
||||
|
||||
protected Class<LdapPassportEntity> getEntityClass() { |
||||
return LdapPassportEntity.class; |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,73 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.db.fun; |
||||
|
||||
import com.fr.plugin.third.party.jsdibhg.db.MultiLdapDBAccessBridge; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
|
||||
import javax.naming.ldap.Control; |
||||
import javax.naming.ldap.InitialLdapContext; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Properties; |
||||
|
||||
public class MultiLdapService { |
||||
private static Control[] connCtls = null; |
||||
|
||||
public static void testConnection(LdapPassportEntity paramLdapPassportEntity) throws Exception { |
||||
Properties properties = new Properties(); |
||||
properties.put("java.naming.factory.initial", paramLdapPassportEntity.getContextFactory()); |
||||
String str = paramLdapPassportEntity.getUrl(); |
||||
if (StringUtils.isNotBlank(str) && !str.endsWith("/")) |
||||
str = str + "/"; |
||||
if (paramLdapPassportEntity.isRetrieveLocAsBaseDN()) |
||||
str = str + paramLdapPassportEntity.getSearchBase(); |
||||
properties.put("java.naming.provider.url", str); |
||||
properties.put("java.naming.security.authentication", paramLdapPassportEntity.getAuthentication()); |
||||
properties.put("java.naming.referral", paramLdapPassportEntity.getReferral()); |
||||
if (StringUtils.isNotBlank(paramLdapPassportEntity.getSystemName()) && StringUtils.isNotBlank(paramLdapPassportEntity.getSystemPassword())) { |
||||
properties.put("java.naming.security.principal", paramLdapPassportEntity.getSystemName()); |
||||
properties.put("java.naming.security.credentials", paramLdapPassportEntity.getSystemPassword()); |
||||
} |
||||
new InitialLdapContext(properties, connCtls); |
||||
} |
||||
|
||||
public static void addLdap(LdapPassportEntity ldapPassportEntity) throws Exception { |
||||
ldapPassportEntity.setCreateTime(new Date()); |
||||
MultiLdapDBAccessBridge.getDbAccessor().runDMLAction(paramDAOContext -> { |
||||
((LdapPassportDAO) paramDAOContext.getDAO(LdapPassportDAO.class)).add(ldapPassportEntity); |
||||
return null; |
||||
}); |
||||
} |
||||
|
||||
public static List<LdapPassportEntity> getLdap(QueryCondition paramQueryCondition) throws Exception { |
||||
return (List<LdapPassportEntity>) MultiLdapDBAccessBridge.getDbAccessor().runQueryAction(paramDAOContext -> ((LdapPassportDAO) paramDAOContext.getDAO(LdapPassportDAO.class)).find(paramQueryCondition)); |
||||
} |
||||
|
||||
public static LdapPassportEntity getById(String paramString) throws Exception { |
||||
return (LdapPassportEntity) MultiLdapDBAccessBridge.getDbAccessor().runQueryAction(paramDAOContext -> (LdapPassportEntity) ((LdapPassportDAO) paramDAOContext.getDAO(LdapPassportDAO.class)).getById(paramString)); |
||||
} |
||||
|
||||
public static void removeLdap(String paramString) throws Exception { |
||||
MultiLdapDBAccessBridge.getDbAccessor().runDMLAction(paramDAOContext -> { |
||||
((LdapPassportDAO) paramDAOContext.getDAO(LdapPassportDAO.class)).remove(paramString); |
||||
return null; |
||||
}); |
||||
} |
||||
|
||||
public static void removeLdap(QueryCondition paramQueryCondition) throws Exception { |
||||
MultiLdapDBAccessBridge.getDbAccessor().runDMLAction(paramDAOContext -> { |
||||
((LdapPassportDAO) paramDAOContext.getDAO(LdapPassportDAO.class)).remove(paramQueryCondition); |
||||
return null; |
||||
}); |
||||
} |
||||
|
||||
public static void update(LdapPassportEntity ldapPassportEntity) throws Exception { |
||||
MultiLdapDBAccessBridge.getDbAccessor().runDMLAction(paramDAOContext -> { |
||||
((LdapPassportDAO) paramDAOContext.getDAO(LdapPassportDAO.class)).update(ldapPassportEntity); |
||||
return null; |
||||
}); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,406 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.db.fun.entity; |
||||
|
||||
import com.fr.decision.authorize.impl.LdapPassport; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.db.entity.BaseEntity; |
||||
import com.fr.third.javax.persistence.Column; |
||||
import com.fr.third.javax.persistence.Entity; |
||||
import com.fr.third.javax.persistence.Table; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Entity |
||||
@Table(name = "jsd8176_multi_ldap_user_sync") |
||||
public class LdapPassportEntity extends BaseEntity { |
||||
public static final String COLUMN_URL = "url"; |
||||
|
||||
public static final String COLUMN_SEARCH_BASE = "searchBase"; |
||||
|
||||
public static final String COLUMN_RETRIEVE_LOC_AS_BASE_DN = "retrieveLocAsBaseDN"; |
||||
|
||||
public static final String COLUMN_AUTHENTICATION = "authentication"; |
||||
|
||||
public static final String COLUMN_CONTEXT_FACTORY = "contextFactory"; |
||||
|
||||
public static final String COLUMN_REFERRAL = "referral"; |
||||
|
||||
public static final String COLUMN_PRINCIPAL_SUFFIX = "principalSuffix"; |
||||
|
||||
public static final String COLUMN_SYSTEM_NAME = "systemName"; |
||||
|
||||
public static final String COLUMN_SYSTEM_PASSWORD = "systemPassword"; |
||||
|
||||
public static final String COLUMN_CREATION_TYPE = "creationType"; |
||||
|
||||
public static final String COLUMN_CREATE_TIME = "createTime"; |
||||
|
||||
private static final String AUTH_SIMPLE = "simple"; |
||||
|
||||
private static final String REFERRAL_FOLLOW = "follow"; |
||||
|
||||
private static final String SUN_DEFAULT_CONTEXT_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory"; |
||||
|
||||
@Column(name = "url") |
||||
private String url; |
||||
|
||||
@Column(name = "searchBase") |
||||
private String searchBase; |
||||
|
||||
@Column(name = "retrieveLocAsBaseDN") |
||||
private boolean retrieveLocAsBaseDN = true; |
||||
|
||||
@Column(name = "authentication") |
||||
private String authentication = "simple"; |
||||
|
||||
@Column(name = "contextFactory") |
||||
private String contextFactory = "com.sun.jndi.ldap.LdapCtxFactory"; |
||||
|
||||
@Column(name = "referral") |
||||
private String referral = "follow"; |
||||
|
||||
@Column(name = "principalSuffix") |
||||
private String principalSuffix; |
||||
|
||||
@Column(name = "systemName") |
||||
private String systemName; |
||||
|
||||
@Column(name = "systemPassword", length = 1000) |
||||
private String systemPassword; |
||||
|
||||
@Column(name = "creationType") |
||||
private int creationType = 0; |
||||
|
||||
@Column(name = "createTime") |
||||
private Date createTime; |
||||
|
||||
@Column(name = "userIdColumnName") |
||||
private String userIdColumnName; |
||||
|
||||
@Column(name = "userNameColumnName") |
||||
private String userNameColumnName; |
||||
|
||||
@Column(name = "userEmailColumnName") |
||||
private String userEmailColumnName; |
||||
|
||||
@Column(name = "userMobileColumnName") |
||||
private String userMobileColumnName; |
||||
|
||||
@Column(name = "userDeptColumnName") |
||||
private String userDeptColumnName; |
||||
|
||||
@Column(name = "userTitleColumnName") |
||||
private String userTitleColumnName; |
||||
|
||||
@Column(name = "userDescColumnName") |
||||
private String userDescColumnName; |
||||
|
||||
@Column(name = "userPrefix") |
||||
private String userPrefix; |
||||
|
||||
public String getUrl() { |
||||
return this.url; |
||||
} |
||||
|
||||
public void setUrl(String paramString) { |
||||
this.url = paramString; |
||||
} |
||||
|
||||
public String getSearchBase() { |
||||
return this.searchBase; |
||||
} |
||||
|
||||
public void setSearchBase(String paramString) { |
||||
this.searchBase = paramString; |
||||
} |
||||
|
||||
public boolean isRetrieveLocAsBaseDN() { |
||||
return this.retrieveLocAsBaseDN; |
||||
} |
||||
|
||||
public void setRetrieveLocAsBaseDN(boolean paramBoolean) { |
||||
this.retrieveLocAsBaseDN = paramBoolean; |
||||
} |
||||
|
||||
public String getAuthentication() { |
||||
return this.authentication; |
||||
} |
||||
|
||||
public void setAuthentication(String paramString) { |
||||
this.authentication = paramString; |
||||
} |
||||
|
||||
public String getContextFactory() { |
||||
return this.contextFactory; |
||||
} |
||||
|
||||
public void setContextFactory(String paramString) { |
||||
this.contextFactory = paramString; |
||||
} |
||||
|
||||
public String getReferral() { |
||||
return this.referral; |
||||
} |
||||
|
||||
public void setReferral(String paramString) { |
||||
this.referral = paramString; |
||||
} |
||||
|
||||
public String getPrincipalSuffix() { |
||||
return this.principalSuffix; |
||||
} |
||||
|
||||
public void setPrincipalSuffix(String paramString) { |
||||
this.principalSuffix = paramString; |
||||
} |
||||
|
||||
public String getSystemName() { |
||||
return this.systemName; |
||||
} |
||||
|
||||
public void setSystemName(String paramString) { |
||||
this.systemName = paramString; |
||||
} |
||||
|
||||
public String getSystemPassword() { |
||||
return this.systemPassword; |
||||
} |
||||
|
||||
public void setSystemPassword(String paramString) { |
||||
this.systemPassword = paramString; |
||||
} |
||||
|
||||
public int getCreationType() { |
||||
return this.creationType; |
||||
} |
||||
|
||||
public void setCreationType(int paramInt) { |
||||
this.creationType = paramInt; |
||||
} |
||||
|
||||
public Date getCreatTime() { |
||||
return this.createTime; |
||||
} |
||||
|
||||
public void setCreateTime(Date paramDate) { |
||||
this.createTime = paramDate; |
||||
} |
||||
|
||||
public String getUserIdColumnName() { |
||||
return userIdColumnName; |
||||
} |
||||
|
||||
public void setUserIdColumnName(String userIdColumnName) { |
||||
this.userIdColumnName = userIdColumnName; |
||||
} |
||||
|
||||
public String getUserNameColumnName() { |
||||
return userNameColumnName; |
||||
} |
||||
|
||||
public void setUserNameColumnName(String userNameColumnName) { |
||||
this.userNameColumnName = userNameColumnName; |
||||
} |
||||
|
||||
public String getUserEmailColumnName() { |
||||
return userEmailColumnName; |
||||
} |
||||
|
||||
public void setUserEmailColumnName(String userEmailColumnName) { |
||||
this.userEmailColumnName = userEmailColumnName; |
||||
} |
||||
|
||||
public String getUserMobileColumnName() { |
||||
return userMobileColumnName; |
||||
} |
||||
|
||||
public void setUserMobileColumnName(String userMobileColumnName) { |
||||
this.userMobileColumnName = userMobileColumnName; |
||||
} |
||||
|
||||
public String getUserDeptColumnName() { |
||||
return userDeptColumnName; |
||||
} |
||||
|
||||
public void setUserDeptColumnName(String userDeptColumnName) { |
||||
this.userDeptColumnName = userDeptColumnName; |
||||
} |
||||
|
||||
public String getUserTitleColumnName() { |
||||
return userTitleColumnName; |
||||
} |
||||
|
||||
public void setUserTitleColumnName(String userTitleColumnName) { |
||||
this.userTitleColumnName = userTitleColumnName; |
||||
} |
||||
|
||||
public String getUserDescColumnName() { |
||||
return userDescColumnName; |
||||
} |
||||
|
||||
public void setUserDescColumnName(String userDescColumnName) { |
||||
this.userDescColumnName = userDescColumnName; |
||||
} |
||||
|
||||
public String getUserPrefix() { |
||||
return userPrefix; |
||||
} |
||||
|
||||
public void setUserPrefix(String userPrefix) { |
||||
this.userPrefix = userPrefix; |
||||
} |
||||
|
||||
public LdapPassportEntity url(String paramString) { |
||||
setUrl(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity searchBase(String paramString) { |
||||
setSearchBase(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity retrieveLocAsBaseDN(boolean paramBoolean) { |
||||
setRetrieveLocAsBaseDN(paramBoolean); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity authentication(String paramString) { |
||||
setAuthentication(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity contextFactory(String paramString) { |
||||
setContextFactory(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity referral(String paramString) { |
||||
setReferral(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity principalSuffix(String paramString) { |
||||
setPrincipalSuffix(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity systemName(String paramString) { |
||||
setSystemName(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity systemPassword(String paramString) { |
||||
setSystemPassword(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity creationType(int paramInt) { |
||||
setCreationType(paramInt); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity createTime(Date paramDate) { |
||||
setCreateTime(paramDate); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity userIdColumnName(String paramString) { |
||||
setUserIdColumnName(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity userNameColumnName(String paramString) { |
||||
setUserNameColumnName(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity userEmailColumnName(String paramString) { |
||||
setUserEmailColumnName(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity userMobileColumnName(String paramString) { |
||||
setUserMobileColumnName(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity userDeptColumnName(String paramString) { |
||||
setUserDeptColumnName(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity userTitleColumnName(String paramString) { |
||||
setUserTitleColumnName(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity userDescColumnName(String paramString) { |
||||
setUserDescColumnName(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public LdapPassportEntity userPrefix(String paramString) { |
||||
setUserPrefix(paramString); |
||||
return this; |
||||
} |
||||
|
||||
public static LdapPassportEntity creatLdapEntity(LdapPassport paramLdapPassport) { |
||||
return (new LdapPassportEntity()) |
||||
.url(paramLdapPassport.getLdapUrl()) |
||||
.searchBase(paramLdapPassport.getLdapSearchBase()) |
||||
.retrieveLocAsBaseDN(paramLdapPassport.isRetrieveLocAsBaseDN()) |
||||
.authentication(paramLdapPassport.getAuthentication()) |
||||
.contextFactory(paramLdapPassport.getContextFactory()) |
||||
.referral(paramLdapPassport.getReferral()) |
||||
.principalSuffix(paramLdapPassport.getPrincipalSuffix()) |
||||
.systemName(paramLdapPassport.getLdapSystemName()) |
||||
.systemPassword(paramLdapPassport.getEncryptedLdapSystemPassword()); |
||||
|
||||
} |
||||
|
||||
public LdapPassport createPassport() { |
||||
LdapPassport ldapPassport = new LdapPassport(); |
||||
ldapPassport.setLdapUrl(getUrl()); |
||||
ldapPassport.setLdapSearchBase(getSearchBase()); |
||||
ldapPassport.setRetrieveLocAsBaseDN(isRetrieveLocAsBaseDN()); |
||||
ldapPassport.setReferral(getReferral()); |
||||
ldapPassport.setAuthentication(getAuthentication()); |
||||
ldapPassport.setPrincipalSuffix(getPrincipalSuffix()); |
||||
ldapPassport.setContextFactory(getContextFactory()); |
||||
ldapPassport.setLdapSystemName(getSystemName()); |
||||
ldapPassport.setEncryptedLdapSystemPassword(getSystemPassword()); |
||||
ldapPassport.setLdapSystemName(getSystemName()); |
||||
ldapPassport.setEncryptedLdapSystemPassword(getSystemPassword()); |
||||
return ldapPassport; |
||||
} |
||||
|
||||
public JSONObject toJson() { |
||||
JSONObject jSONObject = JSONObject.create(); |
||||
jSONObject.put("userIdColumnName", getUserIdColumnName()); |
||||
jSONObject.put("userNameColumnName", getUserNameColumnName()); |
||||
jSONObject.put("userEmailColumnName", getUserEmailColumnName()); |
||||
|
||||
jSONObject.put("userMobileColumnName", getUserMobileColumnName()); |
||||
jSONObject.put("userDeptColumnName", getUserDeptColumnName()); |
||||
jSONObject.put("userTitleColumnName", getUserTitleColumnName()); |
||||
|
||||
jSONObject.put("userDescColumnName", getUserDescColumnName()); |
||||
jSONObject.put("userPrefix", getUserPrefix()); |
||||
|
||||
jSONObject.put("id", getId()); |
||||
jSONObject.put("url", getUrl()); |
||||
jSONObject.put("searchBase", getSearchBase()); |
||||
jSONObject.put("retrieveLocAsBaseDN", isRetrieveLocAsBaseDN()); |
||||
jSONObject.put("referral", getReferral()); |
||||
jSONObject.put("authentication", getAuthentication()); |
||||
jSONObject.put("principalSuffix", getPrincipalSuffix()); |
||||
jSONObject.put("contextFactory", getContextFactory()); |
||||
jSONObject.put("systemName", getSystemName()); |
||||
jSONObject.put("creationType", getCreationType()); |
||||
jSONObject.put("createTime", getCreatTime()); |
||||
if (StringUtils.isNotEmpty(getSystemPassword())) |
||||
jSONObject.put("systemPassword", "********"); |
||||
return jSONObject; |
||||
} |
||||
} |
@ -0,0 +1,58 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.db.fun.http; |
||||
|
||||
import com.fr.base.Utils; |
||||
import com.fr.decision.base.util.UUIDUtil; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.privilege.TransmissionTool; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.MultiLdapService; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.security.encryption.storage.StorageEncryptors; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.InputStream; |
||||
|
||||
public class AddMultiLdapAction extends BaseHttpHandler { |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
public boolean needAdmin() { |
||||
return true; |
||||
} |
||||
|
||||
public String getPath() { |
||||
return "/multi/ldap"; |
||||
} |
||||
|
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
public void handle(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws Exception { |
||||
String str = Utils.inputStream2String((InputStream)paramHttpServletRequest.getInputStream(), "UTF-8"); |
||||
JSONObject jSONObject1 = new JSONObject(str); |
||||
jSONObject1.put("systemPassword", TransmissionTool.decrypt(jSONObject1.optString("systemPassword"))); |
||||
LdapPassportEntity ldapPassportEntity = (LdapPassportEntity)jSONObject1.mapTo(LdapPassportEntity.class); |
||||
try { |
||||
MultiLdapService.testConnection(ldapPassportEntity); |
||||
} catch (Exception exception) { |
||||
FineLoggerFactory.getLogger().error("Test connecting failed, ldap url is {}, and the error message is: {}", new Object[] { ldapPassportEntity.getUrl(), exception.toString() }); |
||||
throw exception; |
||||
} |
||||
if (StringUtils.isEmpty(ldapPassportEntity.getId())) |
||||
ldapPassportEntity.setId(UUIDUtil.generate()); |
||||
ldapPassportEntity.setSystemPassword(StorageEncryptors.getInstance().encrypt(ldapPassportEntity.getSystemPassword())); |
||||
MultiLdapService.addLdap(ldapPassportEntity); |
||||
JSONObject jSONObject2 = JSONObject.create(); |
||||
jSONObject2.put("data", "success"); |
||||
WebUtils.printAsJSON(paramHttpServletResponse, jSONObject2); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,45 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.db.fun.http; |
||||
|
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.MultiLdapService; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.stable.query.QueryFactory; |
||||
import com.fr.stable.query.condition.QueryCondition; |
||||
import com.fr.stable.query.restriction.RestrictionFactory; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
public class GetMultiLdapAction extends BaseHttpHandler { |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.GET; |
||||
} |
||||
|
||||
public boolean needAdmin() { |
||||
return true; |
||||
} |
||||
|
||||
public String getPath() { |
||||
return "/multi/ldap"; |
||||
} |
||||
|
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
public void handle(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws Exception { |
||||
QueryCondition queryCondition = QueryFactory.create().addRestriction(RestrictionFactory.eq("creationType", Integer.valueOf(Integer.parseInt(paramHttpServletRequest.getParameter("creationType"))))).addSort("createTime", true); |
||||
List<LdapPassportEntity> list1 = MultiLdapService.getLdap(queryCondition); |
||||
List<JSONObject> list2 = (List) list1.stream().map(LdapPassportEntity::toJson).collect(Collectors.toList()); |
||||
JSONObject jSONObject = JSONObject.create(); |
||||
jSONObject.put("data", list2); |
||||
WebUtils.printAsJSON(paramHttpServletResponse, jSONObject); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,41 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.db.fun.http; |
||||
|
||||
import com.fr.base.Utils; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.MultiLdapService; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.InputStream; |
||||
|
||||
public class RemoveMultiLdapAction extends BaseHttpHandler { |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.DELETE; |
||||
} |
||||
|
||||
public boolean needAdmin() { |
||||
return true; |
||||
} |
||||
|
||||
public String getPath() { |
||||
return "/multi/ldap"; |
||||
} |
||||
|
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
public void handle(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws Exception { |
||||
String str = Utils.inputStream2String((InputStream)paramHttpServletRequest.getInputStream(), "UTF-8"); |
||||
JSONObject jSONObject1 = new JSONObject(str); |
||||
MultiLdapService.removeLdap(jSONObject1.optString("id")); |
||||
JSONObject jSONObject2 = JSONObject.create(); |
||||
jSONObject2.put("data", "success"); |
||||
WebUtils.printAsJSON(paramHttpServletResponse, jSONObject2); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.db.fun.http; |
||||
|
||||
import com.fr.base.Utils; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.third.party.jsdibhg.data.ldap.LdapTicket; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.MultiLdapService; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.security.encryption.storage.StorageEncryptors; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.InputStream; |
||||
|
||||
public class TestConnectionAction extends BaseHttpHandler { |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.POST; |
||||
} |
||||
|
||||
public boolean needAdmin() { |
||||
return true; |
||||
} |
||||
|
||||
public String getPath() { |
||||
return "/ldap/test"; |
||||
} |
||||
|
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
public void handle(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws Exception { |
||||
String str = Utils.inputStream2String((InputStream) paramHttpServletRequest.getInputStream(), "UTF-8"); |
||||
JSONObject jSONObject1 = new JSONObject(str); |
||||
LdapPassportEntity ldapPassportEntity = MultiLdapService.getById(jSONObject1.optString("id")); |
||||
ldapPassportEntity.setSystemPassword(StorageEncryptors.getInstance().decrypt(ldapPassportEntity.getSystemPassword())); |
||||
try { |
||||
//MultiLdapService.testConnection(ldapPassportEntity);
|
||||
LdapTicket ldapTicket = new LdapTicket(ldapPassportEntity); |
||||
boolean option = ldapTicket.checkTicket(ldapPassportEntity.getSystemName(), ldapPassportEntity.getSystemPassword(), "", ""); |
||||
if (!option) { |
||||
throw new Exception("test connect ldap server fail"); |
||||
} |
||||
} catch (Exception exception) { |
||||
FineLoggerFactory.getLogger().error("Test connecting failed, ldap url is {}, and the error message is: {}", new Object[]{ldapPassportEntity.getUrl(), exception.toString()}); |
||||
throw exception; |
||||
} |
||||
JSONObject jSONObject2 = JSONObject.create(); |
||||
jSONObject2.put("data", "success"); |
||||
WebUtils.printAsJSON(paramHttpServletResponse, jSONObject2); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,80 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.db.fun.http; |
||||
|
||||
import com.fr.base.Utils; |
||||
import com.fr.decision.fun.impl.BaseHttpHandler; |
||||
import com.fr.decision.privilege.TransmissionTool; |
||||
import com.fr.decision.webservice.utils.WebServiceUtils; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.MultiLdapService; |
||||
import com.fr.plugin.third.party.jsdibhg.db.fun.entity.LdapPassportEntity; |
||||
import com.fr.security.encryption.storage.StorageEncryptors; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.InputStream; |
||||
|
||||
public class UpdateMultiLdapAction extends BaseHttpHandler { |
||||
public RequestMethod getMethod() { |
||||
return RequestMethod.PUT; |
||||
} |
||||
|
||||
public boolean needAdmin() { |
||||
return true; |
||||
} |
||||
|
||||
public String getPath() { |
||||
return "/multi/ldap"; |
||||
} |
||||
|
||||
public boolean isPublic() { |
||||
return false; |
||||
} |
||||
|
||||
public void handle(HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse) throws Exception { |
||||
String str = Utils.inputStream2String((InputStream)paramHttpServletRequest.getInputStream(), "UTF-8"); |
||||
JSONObject jSONObject1 = new JSONObject(str); |
||||
if (StringUtils.isEmpty(jSONObject1.optString("id"))) |
||||
throw new Exception("The config is not exist in database!"); |
||||
LdapPassportEntity ldapPassportEntity1 = MultiLdapService.getById(jSONObject1.optString("id")); |
||||
if (WebServiceUtils.isDefaultPassword(jSONObject1.optString("systemPassword"))) { |
||||
jSONObject1.put("systemPassword", StorageEncryptors.getInstance().decrypt(ldapPassportEntity1.getSystemPassword())); |
||||
} else { |
||||
jSONObject1.put("systemPassword", TransmissionTool.decrypt(jSONObject1.optString("systemPassword"))); |
||||
} |
||||
LdapPassportEntity ldapPassportEntity2 = (LdapPassportEntity)jSONObject1.mapTo(LdapPassportEntity.class); |
||||
try { |
||||
MultiLdapService.testConnection(ldapPassportEntity2); |
||||
} catch (Exception exception) { |
||||
FineLoggerFactory.getLogger().error("AuthenticationException,ldap url is {}, and the error message is: {}", new Object[] { ldapPassportEntity2.getUrl(), exception.toString() }); |
||||
throw exception; |
||||
} |
||||
ldapPassportEntity1.url(ldapPassportEntity2.getUrl()) |
||||
.searchBase(StringUtils.isNotEmpty(ldapPassportEntity2.getSearchBase()) ? ldapPassportEntity2.getSearchBase() : ldapPassportEntity1.getSearchBase()) |
||||
.retrieveLocAsBaseDN(ldapPassportEntity2.isRetrieveLocAsBaseDN()) |
||||
.authentication(ldapPassportEntity2.getAuthentication()) |
||||
.contextFactory(ldapPassportEntity2.getContextFactory()) |
||||
.referral(ldapPassportEntity2.getReferral()) |
||||
.principalSuffix(ldapPassportEntity2.getPrincipalSuffix()) |
||||
.systemName(ldapPassportEntity2.getSystemName()) |
||||
.systemPassword(StorageEncryptors.getInstance().encrypt(ldapPassportEntity2.getSystemPassword())) |
||||
.creationType(ldapPassportEntity2.getCreationType()) |
||||
.userIdColumnName(ldapPassportEntity2.getUserIdColumnName()) |
||||
.userNameColumnName(ldapPassportEntity2.getUserNameColumnName()) |
||||
.userEmailColumnName(ldapPassportEntity2.getUserEmailColumnName()) |
||||
.userMobileColumnName(ldapPassportEntity2.getUserMobileColumnName()) |
||||
.userDeptColumnName(ldapPassportEntity2.getUserDeptColumnName()) |
||||
.userTitleColumnName(ldapPassportEntity2.getUserTitleColumnName()) |
||||
.userDescColumnName(ldapPassportEntity2.getUserDescColumnName()) |
||||
.userPrefix(ldapPassportEntity2.getUserPrefix()); |
||||
MultiLdapService.update(ldapPassportEntity1); |
||||
JSONObject jSONObject2 = JSONObject.create(); |
||||
jSONObject2.put("data", "success"); |
||||
WebUtils.printAsJSON(paramHttpServletResponse, jSONObject2); |
||||
} |
||||
} |
||||
|
||||
|
@ -0,0 +1,620 @@
|
||||
package com.fr.plugin.third.party.jsdibhg.test; |
||||
/* ************************************************************************** |
||||
|
||||
* $Novell: VLVControl.java,v 1.19 2005/07/07 09:45:12 $ |
||||
|
||||
* |
||||
|
||||
* Copyright (C) 2001 Novell, Inc. All Rights Reserved. |
||||
|
||||
* |
||||
|
||||
** THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND |
||||
|
||||
* TREATIES. USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE LICENSE |
||||
|
||||
* AGREEMENT ACCOMPANYING THE SOFTWARE DEVELOPMENT KIT (SDK) THAT CONTAINS |
||||
|
||||
* THIS WORK. PURSUANT TO THE SDK LICENSE AGREEMENT, NOVELL HEREBY GRANTS TO |
||||
|
||||
* DEVELOPER A ROYALTY-FREE, NON-EXCLUSIVE LICENSE TO INCLUDE NOVELL'S SAMPLE |
||||
|
||||
* CODE IN ITS PRODUCT. NOVELL GRANTS DEVELOPER WORLDWIDE DISTRIBUTION RIGHTS |
||||
|
||||
* TO MARKET, DISTRIBUTE, OR SELL NOVELL'S SAMPLE CODE AS A COMPONENT OF |
||||
|
||||
* DEVELOPER'S PRODUCTS. NOVELL SHALL HAVE NO OBLIGATIONS TO DEVELOPER OR |
||||
|
||||
* DEVELOPER'S CUSTOMERS WITH RESPECT TO THIS CODE. |
||||
|
||||
***************************************************************************/ |
||||
|
||||
import java.util.Enumeration; |
||||
|
||||
import java.util.Iterator; |
||||
|
||||
import com.novell.ldap.*; |
||||
|
||||
import com.novell.ldap.controls.*; |
||||
|
||||
import java.io.UnsupportedEncodingException; |
||||
|
||||
|
||||
/** |
||||
* The following sample demonstrates how to use the VLV |
||||
* <p> |
||||
* control with Synchronous search requests. As required a |
||||
* <p> |
||||
* Server Side Sort Control is also included in the request. |
||||
* <p> |
||||
* <p> |
||||
* <p> |
||||
* The program is hard coded to sort based on the common name |
||||
* <p> |
||||
* attribute, and it searches for all objects at the specified |
||||
* <p> |
||||
* searchBase. |
||||
* <p> |
||||
* <p> |
||||
* <p> |
||||
* Usage: Usage: java VLVControl <host name> <login dn> <password> |
||||
* |
||||
* <searchBase> |
||||
*/ |
||||
public class VLVControl { |
||||
|
||||
|
||||
public static void main(String[] args) { |
||||
|
||||
|
||||
|
||||
/* Check if we have the correct number of command line arguments */ |
||||
|
||||
if (args.length != 4) { |
||||
|
||||
System.err.println("Usage: java VLVControl <host name> <login dn>" |
||||
|
||||
+ " <password> <container>"); |
||||
|
||||
System.err.println( |
||||
|
||||
"Example: java VLVControl Acme.com \"cn=admin,o=Acme\" secret" |
||||
|
||||
+ " \"ou=Sales,o=Acme\""); |
||||
|
||||
System.exit(1); |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
/* Parse the command line arguments */ |
||||
|
||||
String ldapHost = args[0]; |
||||
|
||||
String loginDN = args[1]; |
||||
|
||||
String password = args[2]; |
||||
|
||||
String searchBase = args[3]; |
||||
|
||||
String returnedAttributes[] = {"*", "+"}; |
||||
|
||||
String oid; |
||||
|
||||
boolean attributeOnly = false; |
||||
|
||||
boolean isSupported = false; |
||||
|
||||
int ldapPort = LDAPConnection.DEFAULT_PORT; |
||||
|
||||
int ldapVersion = LDAPConnection.LDAP_V3; |
||||
|
||||
LDAPConnection lc = new LDAPConnection(); |
||||
|
||||
|
||||
try { |
||||
|
||||
// connect to the server
|
||||
|
||||
|
||||
lc.connect(ldapHost, ldapPort); |
||||
|
||||
// bind to the server
|
||||
|
||||
|
||||
lc.bind(ldapVersion, loginDN, password.getBytes("UTF8")); |
||||
|
||||
System.out.println("Succesfully logged in to server: " + ldapHost); |
||||
|
||||
|
||||
|
||||
/* To search for root DSE, |
||||
|
||||
* 1. Set LDAP version to LDAP_V3 before binding |
||||
|
||||
* 2. Set the search base to an empty string |
||||
|
||||
* 3. Set the search filter to (objectclass=*) |
||||
|
||||
* 4. Set the search scope to LDAP_SCOPE_BASE |
||||
|
||||
*/ |
||||
|
||||
|
||||
LDAPSearchResults searchResults = lc.search( |
||||
|
||||
"", |
||||
|
||||
LDAPConnection.SCOPE_BASE, |
||||
|
||||
"(objectclass=*)", |
||||
|
||||
returnedAttributes, |
||||
|
||||
attributeOnly); |
||||
|
||||
|
||||
|
||||
/* The search returns one entry in the search results, and |
||||
|
||||
* it is the root DSE. |
||||
|
||||
*/ |
||||
|
||||
|
||||
LDAPEntry entry = null; |
||||
|
||||
|
||||
try { |
||||
|
||||
entry = searchResults.next(); |
||||
|
||||
} catch (LDAPException e) { |
||||
|
||||
System.out.println("Error: " + e.toString()); |
||||
|
||||
} |
||||
|
||||
|
||||
LDAPAttributeSet attributeSet = entry.getAttributeSet(); |
||||
|
||||
Iterator allAttributes = attributeSet.iterator(); |
||||
|
||||
|
||||
while (allAttributes.hasNext()) { |
||||
|
||||
LDAPAttribute attribute = (LDAPAttribute) allAttributes.next(); |
||||
|
||||
String attrName = attribute.getName(); |
||||
|
||||
Enumeration allValues = attribute.getStringValues(); |
||||
|
||||
|
||||
if (allValues != null) { |
||||
|
||||
while (allValues.hasMoreElements()) { |
||||
|
||||
if (attrName.equalsIgnoreCase("supportedControl")) { |
||||
|
||||
oid = (String) allValues.nextElement(); |
||||
|
||||
|
||||
// Check whether the requested server supports the VLV Control
|
||||
|
||||
|
||||
// Set to true if it is supported.
|
||||
|
||||
|
||||
if (oid.equalsIgnoreCase("2.16.840.1.113730.3.4.9") |
||||
|
||||
|| oid.equalsIgnoreCase("2.16.840.1.113730.3.4.10")) |
||||
|
||||
isSupported = true; |
||||
|
||||
} else |
||||
|
||||
allValues.nextElement(); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
// Proceed if the Sort Control is supported.
|
||||
|
||||
|
||||
if (isSupported == true) { |
||||
|
||||
|
||||
|
||||
/* Set default filter - Change this line if you need a different set |
||||
|
||||
* of search restrictions. Read the "NDS and LDAP Integration Guide" |
||||
|
||||
* for information on support by Novell eDirectory of this |
||||
|
||||
* functionaliry. |
||||
|
||||
*/ |
||||
|
||||
String MY_FILTER = "cn=*"; |
||||
|
||||
|
||||
|
||||
/* We are requesting that the givenname and cn fields for each |
||||
|
||||
* object be returned |
||||
|
||||
*/ |
||||
|
||||
String[] attrs = new String[2]; |
||||
|
||||
attrs[0] = "givenname"; |
||||
|
||||
attrs[1] = "cn"; |
||||
|
||||
|
||||
// We will be sending two controls to the server
|
||||
|
||||
|
||||
LDAPControl requestControls[] = new LDAPControl[2]; |
||||
|
||||
|
||||
|
||||
/* Create the sort key to be used by the sort control |
||||
|
||||
* Results should be sorted based on the cn attribute. |
||||
|
||||
* See the "NDS and LDAP Integration Guide" for information on |
||||
|
||||
* Novell eDirectory support of this functionaliry. |
||||
|
||||
*/ |
||||
|
||||
LDAPSortKey[] keys = new LDAPSortKey[1]; |
||||
|
||||
keys[0] = new LDAPSortKey("cn"); |
||||
|
||||
|
||||
// Create the sort control
|
||||
|
||||
|
||||
requestControls[0] = new LDAPSortControl(keys, true); |
||||
|
||||
|
||||
|
||||
/* Create the VLV Control. |
||||
|
||||
* These two fields in the VLV Control identify the before and |
||||
|
||||
* after count of entries to be returned |
||||
|
||||
*/ |
||||
|
||||
int beforeCount = 0; |
||||
|
||||
int afterCount = 2; |
||||
|
||||
|
||||
|
||||
/* The VLV control request can specify the index |
||||
|
||||
* using one of the two methods described below: |
||||
|
||||
* |
||||
|
||||
* TYPED INDEX: Here we request all objects that have cn greater |
||||
|
||||
* than or equal to the letter "a" |
||||
|
||||
*/ |
||||
|
||||
requestControls[1] = |
||||
|
||||
new LDAPVirtualListControl("a", beforeCount, afterCount); |
||||
|
||||
|
||||
|
||||
/* The following code needs to be enabled to specify the index |
||||
|
||||
* directly |
||||
|
||||
* int offset = 0; - offset of the index |
||||
|
||||
* int contentCount = 3; - our estimate of the search result size |
||||
|
||||
* requestControls[1] = new LDAPVirtualListControl(offset, |
||||
|
||||
* beforeCount, afterCount, contentCount); |
||||
|
||||
*/ |
||||
|
||||
|
||||
// Set the controls to be sent as part of search request
|
||||
|
||||
|
||||
LDAPSearchConstraints cons = lc.getSearchConstraints(); |
||||
|
||||
cons.setControls(requestControls); |
||||
|
||||
lc.setConstraints(cons); |
||||
|
||||
|
||||
// Send the search request - Synchronous Search is being used here
|
||||
|
||||
|
||||
System.out.println("Calling Asynchronous Search..."); |
||||
|
||||
LDAPSearchResults res = lc.search(searchBase, |
||||
|
||||
LDAPConnection.SCOPE_SUB, |
||||
|
||||
MY_FILTER, |
||||
|
||||
attrs, |
||||
|
||||
false, |
||||
|
||||
(LDAPSearchConstraints) null); |
||||
|
||||
|
||||
// Loop through the results and print them out
|
||||
|
||||
|
||||
while (res.hasMore()) { |
||||
/* Get next returned entry. Note that we should expect a LDAP- |
||||
*Exception object as well just in case something goes wrong |
||||
*/ |
||||
LDAPEntry nextEntry; |
||||
try { |
||||
nextEntry = res.next(); |
||||
} catch (LDAPException e) { |
||||
if (e instanceof LDAPReferralException) |
||||
continue; |
||||
else { |
||||
System.out.println("Search stopped with exception " + e.toString()); |
||||
break; |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
/* Print out the returned Entries distinguished name. */ |
||||
|
||||
System.out.println(); |
||||
System.out.println(nextEntry.getDN()); |
||||
|
||||
|
||||
|
||||
/* Get the list of attributes for the current entry */ |
||||
|
||||
LDAPAttributeSet findAttrs = nextEntry.getAttributeSet(); |
||||
|
||||
|
||||
|
||||
/* Convert attribute list to Enumeration */ |
||||
|
||||
Iterator enumAttrs = findAttrs.iterator(); |
||||
|
||||
System.out.println("Attributes: "); |
||||
|
||||
|
||||
|
||||
/* Loop through all attributes in the enumeration */ |
||||
|
||||
while (enumAttrs.hasNext()) { |
||||
|
||||
|
||||
LDAPAttribute anAttr = |
||||
|
||||
(LDAPAttribute) enumAttrs.next(); |
||||
|
||||
|
||||
|
||||
/* Print out the attribute name */ |
||||
|
||||
String attrName = anAttr.getName(); |
||||
|
||||
System.out.println("" + attrName); |
||||
|
||||
|
||||
// Loop through all values for this attribute and print them
|
||||
|
||||
|
||||
Enumeration enumVals = anAttr.getStringValues(); |
||||
|
||||
while (enumVals.hasMoreElements()) { |
||||
|
||||
String aVal = (String) enumVals.nextElement(); |
||||
|
||||
System.out.println("" + aVal); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
// Server should send back a control irrespective of the
|
||||
|
||||
|
||||
// status of the search request
|
||||
|
||||
|
||||
LDAPControl[] controls = res.getResponseControls(); |
||||
|
||||
if (controls == null) { |
||||
|
||||
System.out.println("No controls returned"); |
||||
|
||||
} else { |
||||
|
||||
|
||||
// We are likely to have multiple controls returned
|
||||
|
||||
|
||||
for (int i = 0; i < controls.length; i++) { |
||||
|
||||
|
||||
|
||||
/* Is this the Sort Response Control. */ |
||||
|
||||
if (controls[i] instanceof LDAPSortResponse) { |
||||
|
||||
|
||||
System.out.println("Received LDAP Sort Control from " |
||||
|
||||
+ "Server"); |
||||
|
||||
|
||||
|
||||
/* We could have an error code and maybe a string |
||||
|
||||
* identifying erring attribute in the response control. |
||||
|
||||
*/ |
||||
|
||||
String bad = |
||||
|
||||
((LDAPSortResponse) controls[i]).getFailedAttribute(); |
||||
|
||||
int result = |
||||
|
||||
((LDAPSortResponse) controls[i]).getResultCode(); |
||||
|
||||
|
||||
// Print out error code (0 if no error) and any
|
||||
|
||||
|
||||
// returned attribute
|
||||
|
||||
|
||||
System.out.println("Error code: " + result); |
||||
|
||||
if (bad != null) |
||||
|
||||
System.out.println("Offending " + "attribute: " |
||||
|
||||
+ bad); |
||||
|
||||
else |
||||
|
||||
System.out.println("No offending " + "attribute " |
||||
|
||||
+ "returned"); |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
/* Is this a VLV Response Control */ |
||||
|
||||
if (controls[i] instanceof LDAPVirtualListResponse) { |
||||
|
||||
|
||||
System.out.println("Received VLV Response Control from " |
||||
|
||||
+ "Server..."); |
||||
|
||||
|
||||
|
||||
/* Get all returned fields */ |
||||
|
||||
int firstPosition = ((LDAPVirtualListResponse) |
||||
|
||||
controls[i]).getFirstPosition(); |
||||
|
||||
int ContentCount = ((LDAPVirtualListResponse) |
||||
|
||||
controls[i]).getContentCount(); |
||||
|
||||
int resultCode = ((LDAPVirtualListResponse) |
||||
|
||||
controls[i]).getResultCode(); |
||||
|
||||
String context = ((LDAPVirtualListResponse) |
||||
|
||||
controls[i]).getContext(); |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Print out the returned fields. Typically you would |
||||
|
||||
* have used these fields to reissue another VLV request |
||||
|
||||
* or to display the list on a GUI |
||||
|
||||
*/ |
||||
|
||||
System.out.println("Result Code => " |
||||
|
||||
+ resultCode); |
||||
|
||||
System.out.println("First Position => " |
||||
|
||||
+ firstPosition); |
||||
|
||||
System.out.println("Content Count => " |
||||
|
||||
+ ContentCount); |
||||
|
||||
if (context != null) |
||||
|
||||
System.out.println("Context String => " + context); |
||||
|
||||
else |
||||
|
||||
System.out.println("No Context String in returned" |
||||
|
||||
+ " control"); |
||||
|
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
/* We are done - disconnect */ |
||||
|
||||
if (lc.isConnected()) |
||||
|
||||
lc.disconnect(); |
||||
|
||||
} |
||||
|
||||
// Print message if the Sort Control is not supported.
|
||||
|
||||
|
||||
else { |
||||
|
||||
System.out.println("The Requested Server does not support the VLV Control."); |
||||
|
||||
lc.disconnect(); |
||||
|
||||
System.exit(1); |
||||
|
||||
} |
||||
|
||||
} catch (LDAPException e) { |
||||
|
||||
System.out.println(e.toString()); |
||||
|
||||
} catch (UnsupportedEncodingException e) { |
||||
|
||||
System.out.println("Error: " + e.toString()); |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,12 @@
|
||||
/* fine-multi-ldap 20-12-25 15:56:09 */ |
||||
.dec-plugin-user-setting-multi-ldap .ldap-table { |
||||
max-height: 165px |
||||
} |
||||
|
||||
.dec-plugin-user-setting-multi-ldap .ldap-table .dec-page-table-row .operations-group { |
||||
visibility: hidden |
||||
} |
||||
|
||||
.dec-plugin-user-setting-multi-ldap .ldap-table .dec-page-table-row:hover .operations-group { |
||||
visibility: visible |
||||
} |
@ -0,0 +1,577 @@
|
||||
/** fine-multi-ldap 20-12-25 15:56:09 */ |
||||
!function () { |
||||
var t = BI.inherit(BI.Widget, { |
||||
props: {baseCls: "dec-page-table-row", height: 32, odd: !0, text: ""}, |
||||
render: function () { |
||||
var t = this, e = this.options; |
||||
return { |
||||
type: "bi.htape", |
||||
height: e.height, |
||||
cls: e.odd ? "row-odd" : "row-even", |
||||
items: [{ |
||||
el: { |
||||
type: "bi.label", |
||||
hgap: 10, |
||||
height: e.height, |
||||
textAlign: "left", |
||||
text: e.text, |
||||
title: e.text |
||||
} |
||||
}, { |
||||
type: "bi.horizontal", |
||||
cls: "operations-group", |
||||
items: [{ |
||||
type: "bi.icon_button", |
||||
$value: "connect", |
||||
cls: "test-connect-font", |
||||
width: 30, |
||||
height: e.height, |
||||
title: BI.i18nText("Dec-Test_Connection"), |
||||
handler: function () { |
||||
t.fireEvent("EVENT_TEST") |
||||
} |
||||
}, { |
||||
type: "bi.icon_button", |
||||
$value: "edit", |
||||
cls: "normal-edit-font", |
||||
width: 30, |
||||
height: e.height, |
||||
title: BI.i18nText("Dec-Basic_Edit"), |
||||
handler: function () { |
||||
t.fireEvent("EVENT_EDIT") |
||||
} |
||||
}, { |
||||
type: "dec.bubble.combo", |
||||
width: 30, |
||||
el: { |
||||
type: "bi.icon_button", |
||||
$value: "delete", |
||||
cls: "default-delete-font", |
||||
height: e.height, |
||||
title: BI.i18nText("Dec-Basic_Delete") |
||||
}, |
||||
text: BI.i18nText("Dec-Plugin_Multi_LDAP_Delete_Confirm"), |
||||
onClickConfirm: function () { |
||||
t.fireEvent("EVENT_DELETE") |
||||
} |
||||
}] |
||||
}] |
||||
} |
||||
} |
||||
}); |
||||
BI.shortcut("dec.plugin.user.setting.multi.ldap.item", t) |
||||
}(), function () { |
||||
var t = BI.inherit(BI.Widget, { |
||||
props: {baseCls: "dec-plugin-user-setting-multi-ldap", creationType: DecCst.User.CreationType.MANUAL}, |
||||
_store: function () { |
||||
return BI.Models.getModel("dec.model.plugin.user.setting.multi.ldap", { |
||||
creationType: this.options.creationType, |
||||
configs: this.options.configs |
||||
}) |
||||
}, |
||||
watch: { |
||||
ldaps: function (t) { |
||||
this.ldapGroup.populate(this._createItems(t)) |
||||
}, testResult: function (t) { |
||||
this.testMasker.setStatus(t) |
||||
} |
||||
}, |
||||
render: function () { |
||||
var e = this; |
||||
return { |
||||
type: "bi.vertical", |
||||
bgap: 15, |
||||
items: [{ |
||||
type: "bi.label", |
||||
cls: "bi-tips", |
||||
textAlign: "left", |
||||
text: BI.i18nText("Dec-User_Authentication_Tip") |
||||
}, { |
||||
type: "bi.vertical_adapt", |
||||
items: [{ |
||||
type: "bi.icon_text_item", |
||||
cls: "plus-font", |
||||
logic: {dynamic: !0}, |
||||
height: 16, |
||||
textLgap: 5, |
||||
text: BI.i18nText("Dec-Basic_Add"), |
||||
handler: function () { |
||||
e._editLDAP() |
||||
} |
||||
}] |
||||
}, { |
||||
el: { |
||||
type: "bi.label", |
||||
cls: "dec-page-table-header", |
||||
text: BI.i18nText("URL"), |
||||
height: 32, |
||||
textAlign: "left", |
||||
lgap: 10 |
||||
}, bgap: -15 |
||||
}, { |
||||
type: "bi.button_group", |
||||
cls: "ldap-table", |
||||
layouts: [{type: "bi.vertical"}], |
||||
items: this._createItems(this.model.ldaps), |
||||
ref: function (t) { |
||||
e.ldapGroup = t |
||||
} |
||||
}] |
||||
} |
||||
}, |
||||
mounted: function () { |
||||
this.store.initData() |
||||
}, |
||||
getValue: function () { |
||||
return {} |
||||
}, |
||||
_editLDAP: function (t) { |
||||
var e = this, i = BI.UUID(); |
||||
BI.Popovers.create(i, { |
||||
type: "bi.popover", |
||||
header: BI.i18nText("Dec-Plugin_Multi_LDAP_Setting"), |
||||
body: { |
||||
type: "dec.plugin.user.setting.multi.ldap.popover", |
||||
creationType: this.options.creationType, |
||||
configs: t, |
||||
listeners: [{ |
||||
eventName: "EVENT_CANCEL", action: function () { |
||||
BI.Popovers.remove(i) |
||||
} |
||||
}, { |
||||
eventName: "EVENT_CHANGE", action: function (t) { |
||||
e._testConnection(t, function () { |
||||
e.store.changeLDAP(), BI.Popovers.remove(i) |
||||
}, !1) |
||||
} |
||||
}] |
||||
}, |
||||
listeners: [{ |
||||
eventName: "EVENT_CLOSE", action: function () { |
||||
BI.Popovers.remove(i) |
||||
} |
||||
}] |
||||
}, this).open(i) |
||||
}, |
||||
_createItems: function (t) { |
||||
var i = this; |
||||
return BI.map(t, function (t, e) { |
||||
return { |
||||
type: "dec.plugin.user.setting.multi.ldap.item", |
||||
text: e.url, |
||||
odd: BI.isOdd(t), |
||||
listeners: [{ |
||||
eventName: "EVENT_TEST", action: function () { |
||||
i._testConnection(e, BI.emptyFn, !0) |
||||
} |
||||
}, { |
||||
eventName: "EVENT_DELETE", action: function () { |
||||
i.store.removeLDAP(e.id) |
||||
} |
||||
}, { |
||||
eventName: "EVENT_EDIT", action: function () { |
||||
i._editLDAP(e) |
||||
} |
||||
}] |
||||
} |
||||
}) |
||||
}, |
||||
_testConnection: function (t, e, i) { |
||||
var n = this, l = BI.UUID(); |
||||
BI.Maskers.create(l, null, { |
||||
render: { |
||||
type: "dec.test.status.reload", |
||||
waitingText: BI.i18nText("Dec-Connection_Test_Waiting"), |
||||
successText: BI.i18nText("Dec-Connection_Test_Success"), |
||||
failText: BI.i18nText("Dec-Plugin_Multi_LDAP_Setting_Fail"), |
||||
reloadText: BI.i18nText("Dec-Basic_Reload"), |
||||
listeners: [{ |
||||
eventName: "EVENT_CLOSE", action: function () { |
||||
BI.Maskers.remove(l) |
||||
} |
||||
}, { |
||||
eventName: "EVENT_RELOAD", action: function () { |
||||
i ? n.store.startTest(t, e) : n.store.testAndSave(t, e) |
||||
} |
||||
}], |
||||
ref: function (t) { |
||||
n.testMasker = t |
||||
} |
||||
} |
||||
}), BI.Maskers.show(l), i ? this.store.startTest(t, e) : this.store.testAndSave(t, e) |
||||
} |
||||
}); |
||||
BI.shortcut("dec.plugin.user.setting.multi.ldap", t) |
||||
}(), function () { |
||||
var t = BI.inherit(Fix.Model, { |
||||
state: function () { |
||||
return {ldaps: [], testResult: {}} |
||||
}, computed: {}, actions: { |
||||
initData: function () { |
||||
var e = this; |
||||
Dec.Utils.getPluginMultiLDAP(this.options.creationType, function (t) { |
||||
e.model.ldaps = t |
||||
}) |
||||
}, changeLDAP: function () { |
||||
this.initData() |
||||
}, removeLDAP: function (i) { |
||||
var t = this; |
||||
Dec.Utils.delPluginMultiLDAP({id: i}, function () { |
||||
BI.remove(t.model.ldaps, function (t, e) { |
||||
return e.id === i |
||||
}) |
||||
}) |
||||
}, testAndSave: function (t, e) { |
||||
var i = this; |
||||
this.model.testResult = {status: DecCst.TestStatus.WAITING}, t.id ? Dec.Utils.updatePluginMultiLDAP(t, function (t) { |
||||
(i.model.testResult = t).data && BI.isFunction(e) && e() |
||||
}) : Dec.Utils.addPluginMultiLDAP(t, function (t) { |
||||
(i.model.testResult = t).data && BI.isFunction(e) && e() |
||||
}) |
||||
}, startTest: function (t, e) { |
||||
var i = this; |
||||
this.model.testResult = {status: DecCst.TestStatus.WAITING}, Dec.Utils.testPluginMultiLDAP(t, function (t) { |
||||
(i.model.testResult = t).data && BI.isFunction(e) && e() |
||||
}) |
||||
} |
||||
} |
||||
}); |
||||
BI.model("dec.model.plugin.user.setting.multi.ldap", t) |
||||
}(), Dec.Utils = Dec.Utils || {}, BI.extend(Dec.Utils, { |
||||
getPluginMultiLDAP: function (t, e) { |
||||
Dec.reqGetHandle(Dec.Utils.getEncodeURL("/url/multi/ldap", "", {creationType: t}), "", e) |
||||
}, addPluginMultiLDAP: function (t, e) { |
||||
Dec.reqPost("/url/multi/ldap", t, e) |
||||
}, updatePluginMultiLDAP: function (t, e) { |
||||
Dec.reqPut("/url/multi/ldap", t, e) |
||||
}, testPluginMultiLDAP: function (t, e) { |
||||
Dec.reqPost("/url/ldap/test", t, e) |
||||
}, delPluginMultiLDAP: function (t, e) { |
||||
Dec.reqDelete("/url/multi/ldap", t, e) |
||||
} |
||||
}), function () { |
||||
var i = 90, n = 420, t = BI.inherit(BI.Widget, { |
||||
props: {baseCls: "", configs: {}}, _store: function () { |
||||
return BI.Models.getModel("dec.model.plugin.user.setting.multi.ldap.popover") |
||||
}, watch: {}, render: function () { |
||||
var e = this, t = this.options.configs; |
||||
return { |
||||
type: "bi.vtape", items: [{ |
||||
el: { |
||||
type: "bi.vertical", |
||||
bgap: 10, |
||||
items: [{ |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("URL"), |
||||
value: t.url, |
||||
ref: function (t) { |
||||
e.urlRow = t |
||||
} |
||||
}, { |
||||
el: { |
||||
type: "bi.label", |
||||
cls: "bi-tips", |
||||
textAlign: "left", |
||||
text: BI.i18nText("Dec-Example_URL"), |
||||
title: BI.i18nText("Dec-Example_URL") |
||||
}, lgap: i |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-Retrieve_Location"), |
||||
value: t.searchBase, |
||||
ref: function (t) { |
||||
e.searchBaseRow = t |
||||
} |
||||
}, { |
||||
el: { |
||||
type: "bi.label", |
||||
cls: "bi-tips", |
||||
textAlign: "left", |
||||
text: BI.i18nText("Dec-Example_Retrieve_Location"), |
||||
title: BI.i18nText("Dec-Example_Retrieve_Location") |
||||
}, lgap: i |
||||
}, { |
||||
el: { |
||||
type: "bi.multi_select_item", |
||||
$value: "retrieve", |
||||
text: BI.i18nText("DEC-No_Retrieve_Location_As_BaseDN"), |
||||
selected: t.retrieveLocAsBaseDN, |
||||
ref: function (t) { |
||||
e.asBaseDNRow = t |
||||
} |
||||
}, lgap: 85 |
||||
}, { |
||||
type: "bi.vertical_adapt", |
||||
items: [{ |
||||
type: "bi.label", |
||||
cls: "dec-font-weight-bold", |
||||
width: i, |
||||
textAlign: "left", |
||||
text: BI.i18nText("Dec-Authentication_Mode"), |
||||
title: BI.i18nText("Dec-Authentication_Mode") |
||||
}, { |
||||
type: "bi.text_value_check_combo", |
||||
$value: "authentication", |
||||
width: n, |
||||
text: BI.i18nText("Dec-Please_Select_One"), |
||||
items: BI.Constants.getConstant("dec.constant.ldap.ldapAuth"), |
||||
value: t.authentication, |
||||
ref: function (t) { |
||||
e.ldapAuthRow = t |
||||
} |
||||
}] |
||||
}, { |
||||
type: "bi.vertical_adapt", |
||||
items: [{ |
||||
type: "bi.label", |
||||
width: i, |
||||
textAlign: "left", |
||||
cls: "dec-font-weight-bold", |
||||
text: BI.i18nText("Dec-LDAP_Context"), |
||||
title: BI.i18nText("Dec-LDAP_Context") |
||||
}, { |
||||
type: "bi.text_value_check_combo", |
||||
$value: "context-factory", |
||||
width: n, |
||||
text: BI.i18nText("Dec-Please_Select_One"), |
||||
items: BI.Constants.getConstant("dec.constant.ldap.contextFactory"), |
||||
value: t.contextFactory, |
||||
ref: function (t) { |
||||
e.contextFactoryRow = t |
||||
} |
||||
}] |
||||
}, { |
||||
type: "bi.vertical_adapt", |
||||
items: [{ |
||||
type: "bi.label", |
||||
width: i, |
||||
textAlign: "left", |
||||
cls: "dec-font-weight-bold", |
||||
text: BI.i18nText("Dec-LDAP_Referral"), |
||||
title: BI.i18nText("Dec-LDAP_Referral") |
||||
}, { |
||||
type: "bi.text_value_check_combo", |
||||
$value: "referral", |
||||
width: n, |
||||
text: BI.i18nText("Dec-Please_Select_One"), |
||||
items: BI.Constants.getConstant("dec.constant.ldap.referral"), |
||||
value: t.referral, |
||||
ref: function (t) { |
||||
e.referralRow = t |
||||
} |
||||
}] |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
$value: "principal-suffix", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-LDAP_User_Suffix"), |
||||
value: t.principalSuffix, |
||||
ref: function (t) { |
||||
e.principalSuffixRow = t |
||||
} |
||||
}, { |
||||
el: { |
||||
type: "bi.label", |
||||
textAlign: "left", |
||||
cls: "bi-tips", |
||||
text: BI.i18nText("Dec-Example_User_Suffix"), |
||||
title: BI.i18nText("Dec-Example_User_Suffix") |
||||
}, lgap: i |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
$value: "principal-suffix", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-LDAP_Admin_Name"), |
||||
value: t.systemName, |
||||
ref: function (t) { |
||||
e.systemNameRow = t |
||||
} |
||||
}, { |
||||
el: { |
||||
type: "dec.common.cipher.editor", |
||||
$value: "system-password", |
||||
textCls: "dec-font-weight-bold", |
||||
textWidth: i, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-LDAP_Admin_Password"), |
||||
editorWidth: n, |
||||
value: t.systemPassword, |
||||
ref: function (t) { |
||||
e.systemPasswordRow = t |
||||
} |
||||
} |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
$value: "principal-suffix", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-Plugin_Multi_LDAP_User_Id_Column_Name"), |
||||
value: t.userIdColumnName, |
||||
ref: function (t) { |
||||
e.userIdColumnNameRow = t |
||||
} |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
$value: "principal-suffix", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-Plugin_Multi_LDAP_User_Name_Column_Name"), |
||||
value: t.userNameColumnName, |
||||
ref: function (t) { |
||||
e.userNameColumnNameRow = t |
||||
} |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
$value: "principal-suffix", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-Plugin_Multi_LDAP_User_Email_Column_Name"), |
||||
value: t.userEmailColumnName, |
||||
ref: function (t) { |
||||
e.userEmailColumnNameRow = t |
||||
} |
||||
} |
||||
|
||||
, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
$value: "principal-suffix", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-Plugin_Multi_LDAP_User_Mobile_Column_Name"), |
||||
value: t.userMobileColumnName, |
||||
ref: function (t) { |
||||
e.userMobileColumnNameRow = t |
||||
} |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
$value: "principal-suffix", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-Plugin_Multi_LDAP_User_Dept_Column_Name"), |
||||
value: t.userDeptColumnName, |
||||
ref: function (t) { |
||||
e.userDeptColumnNameRow = t |
||||
} |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
$value: "principal-suffix", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-Plugin_Multi_LDAP_User_Title_Column_Name"), |
||||
value: t.userTitleColumnName, |
||||
ref: function (t) { |
||||
e.userTitleColumnNameRow = t |
||||
} |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
$value: "principal-suffix", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-Plugin_Multi_LDAP_User_Desc_Column_Name"), |
||||
value: t.userDescColumnName, |
||||
ref: function (t) { |
||||
e.userDescColumnNameRow = t |
||||
} |
||||
}, { |
||||
type: "dec.label.editor.item", |
||||
textCls: "dec-font-weight-bold", |
||||
$value: "principal-suffix", |
||||
textWidth: i, |
||||
editorWidth: n, |
||||
watermark: BI.i18nText("Dec-Please_Input"), |
||||
text: BI.i18nText("Dec-Plugin_Multi_LDAP_User_Prefix"), |
||||
value: t.userPrefix, |
||||
ref: function (t) { |
||||
e.userPrefixRow = t |
||||
} |
||||
} |
||||
] |
||||
} |
||||
}, { |
||||
type: "bi.right_vertical_adapt", |
||||
lgap: 10, |
||||
height: 40, |
||||
items: [{ |
||||
type: "bi.button", |
||||
text: BI.i18nText("BI-Basic_Cancel"), |
||||
level: "ignore", |
||||
handler: function () { |
||||
e.fireEvent("EVENT_CANCEL") |
||||
} |
||||
}, { |
||||
type: "bi.button", text: BI.i18nText("Dec-Cluster_Test_And_Save"), handler: function () { |
||||
e.fireEvent("EVENT_CHANGE", e.getValue()) |
||||
} |
||||
}] |
||||
}] |
||||
} |
||||
}, getValue: function () { |
||||
return { |
||||
creationType: this.options.creationType, |
||||
id: this.options.configs.id, |
||||
url: this.urlRow.getValue(), |
||||
searchBase: this.searchBaseRow.getValue(), |
||||
retrieveLocAsBaseDN: this.asBaseDNRow.isSelected(), |
||||
authentication: this.ldapAuthRow.getValue()[0], |
||||
contextFactory: this.contextFactoryRow.getValue()[0], |
||||
referral: this.referralRow.getValue()[0], |
||||
principalSuffix: this.principalSuffixRow.getValue(), |
||||
systemName: this.systemNameRow.getValue(), |
||||
systemPassword: this.systemPasswordRow.getCipher(), |
||||
userIdColumnName: this.userIdColumnNameRow.getValue(), |
||||
userNameColumnName: this.userNameColumnNameRow.getValue(), |
||||
userEmailColumnName: this.userEmailColumnNameRow.getValue(), |
||||
|
||||
userMobileColumnName: this.userMobileColumnNameRow.getValue(), |
||||
userDeptColumnName: this.userDeptColumnNameRow.getValue(), |
||||
userTitleColumnName: this.userTitleColumnNameRow.getValue(), |
||||
|
||||
userDescColumnName: this.userDescColumnNameRow.getValue(), |
||||
userPrefix: this.userPrefixRow.getValue() |
||||
} |
||||
} |
||||
}); |
||||
BI.shortcut("dec.plugin.user.setting.multi.ldap.popover", t) |
||||
}(), function () { |
||||
var t = BI.inherit(Fix.Model, { |
||||
state: function () { |
||||
return {} |
||||
}, computed: {}, actions: {} |
||||
}); |
||||
BI.model("dec.model.plugin.user.setting.multi.ldap.popover", t) |
||||
}(), BI.config("dec.provider.user", function (t) { |
||||
t.registerAuthenticationMethod({ |
||||
value: "multiLdap", |
||||
text: BI.i18nText("Dec-Plugin_Multi_LDAP_Authentication"), |
||||
"@class": "com.fr.plugin.third.party.jsdibhg.MultiLdapAuthenticBean", |
||||
component: {type: "dec.plugin.user.setting.multi.ldap"} |
||||
}) |
||||
}); |
@ -0,0 +1,12 @@
|
||||
Dec-Plugin_Multi_LDAP_Setting= |
||||
Dec-Plugin_Multi_LDAP_Setting_Fail= |
||||
Dec-Plugin_Multi_LDAP_Delete_Confirm= |
||||
Dec-Plugin_Multi_LDAP_Authentication= |
||||
Dec-Plugin_Multi_LDAP_User_Id_Column_Name= |
||||
Dec-Plugin_Multi_LDAP_User_Name_Column_Name= |
||||
Dec-Plugin_Multi_LDAP_User_Email_Column_Name= |
||||
Dec-Plugin_Multi_LDAP_User_Mobile_Column_Name= |
||||
Dec-Plugin_Multi_LDAP_User_Dept_Column_Name= |
||||
Dec-Plugin_Multi_LDAP_User_Title_Column_Name= |
||||
Dec-Plugin_Multi_LDAP_User_Desc_Column_Name= |
||||
Dec-Plugin_Multi_LDAP_User_Prefix= |
@ -0,0 +1,4 @@
|
||||
Dec-Plugin_Multi_LDAP_Authentication=Multi-domain LDAP authentication |
||||
Dec-Plugin_Multi_LDAP_Delete_Confirm=Are you sure to delete the LDAP configuration? |
||||
Dec-Plugin_Multi_LDAP_Setting=LDAP Settings |
||||
Dec-Plugin_Multi_LDAP_Setting_Fail=Unsuccessful connection to LDAP authentication, please confirm the relevant configuration is accurate and save again |
@ -0,0 +1,4 @@
|
||||
Dec-Plugin_Multi_LDAP_Authentication= |
||||
Dec-Plugin_Multi_LDAP_Delete_Confirm= |
||||
Dec-Plugin_Multi_LDAP_Setting= |
||||
Dec-Plugin_Multi_LDAP_Setting_Fail= |
@ -0,0 +1,4 @@
|
||||
Dec-Plugin_Multi_LDAP_Authentication= |
||||
Dec-Plugin_Multi_LDAP_Delete_Confirm= |
||||
Dec-Plugin_Multi_LDAP_Setting= |
||||
Dec-Plugin_Multi_LDAP_Setting_Fail= |
@ -0,0 +1,12 @@
|
||||
Dec-Plugin_Multi_LDAP_Authentication=\u591A\u57DFLDAP\u8BA4\u8BC1 |
||||
Dec-Plugin_Multi_LDAP_Delete_Confirm=\u786E\u8BA4\u5220\u9664\u8BE5\u5957LDAP\u914D\u7F6E\uFF1F |
||||
Dec-Plugin_Multi_LDAP_Setting=LDAP\u8BBE\u7F6E |
||||
Dec-Plugin_Multi_LDAP_Setting_Fail=\u672A\u80FD\u6210\u529F\u8FDE\u63A5LDAP\u8BA4\u8BC1\uFF0C\u8BF7\u786E\u8BA4\u76F8\u5173\u914D\u7F6E\u51C6\u786E\u540E\u518D\u6B21\u4FDD\u5B58 |
||||
Dec-Plugin_Multi_LDAP_User_Id_Column_Name=\u7528\u6237\u540D\u5217\u540D |
||||
Dec-Plugin_Multi_LDAP_User_Name_Column_Name=\u7528\u6237\u59D3\u540D\u5217\u540D |
||||
Dec-Plugin_Multi_LDAP_User_Email_Column_Name=\u7528\u6237\u90AE\u7BB1\u5217\u540D |
||||
Dec-Plugin_Multi_LDAP_User_Mobile_Column_Name=\u7528\u6237\u53F7\u7801\u5217\u540D |
||||
Dec-Plugin_Multi_LDAP_User_Dept_Column_Name=\u7528\u6237\u90E8\u95E8\u5217\u540D |
||||
Dec-Plugin_Multi_LDAP_User_Title_Column_Name=\u7528\u6237\u5C97\u4F4D\u5217\u540D |
||||
Dec-Plugin_Multi_LDAP_User_Desc_Column_Name=\u7528\u6237\u63CF\u8FF0\u5217\u540D |
||||
Dec-Plugin_Multi_LDAP_User_Prefix=\u7528\u6237\u524D\u7F00 |
@ -0,0 +1,4 @@
|
||||
Dec-Plugin_Multi_LDAP_Authentication=\u591A\u57DFLDAP\u8A8D\u8B49 |
||||
Dec-Plugin_Multi_LDAP_Delete_Confirm=\u78BA\u8A8D\u522A\u9664\u8A72\u5957LDAP\u914D\u7F6E\uFF1F |
||||
Dec-Plugin_Multi_LDAP_Setting=LDAP\u8A2D\u5B9A |
||||
Dec-Plugin_Multi_LDAP_Setting_Fail=\u672A\u80FD\u6210\u529F\u9023\u7DDALDAP\u8A8D\u8B49\uFF0C\u8ACB\u78BA\u8A8D\u76F8\u95DC\u914D\u7F6E\u6E96\u78BA\u5F8C\u518D\u6B21\u5132\u5B58 |
Binary file not shown.
Loading…
Reference in new issue