|
|
|
package com.fr.plugin.decision.passport.ldaps;
|
|
|
|
|
|
|
|
import com.fanruan.api.decision.CommonKit;
|
|
|
|
import com.fanruan.api.decision.auth.bean.BasePassportBean;
|
|
|
|
import com.fanruan.api.decision.login.LoginKit;
|
|
|
|
import com.fanruan.api.util.StringKit;
|
|
|
|
import com.fr.decision.authorize.Passport;
|
|
|
|
import com.fr.third.fasterxml.jackson.annotation.JsonSubTypes;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* LDAP认证方式
|
|
|
|
* Created by zhouping on 2018/3/4.
|
|
|
|
*/
|
|
|
|
@JsonSubTypes.Type(value = LdapsAuthenticBean.class, name = "LdapAuthenticBean")
|
|
|
|
public class LdapsAuthenticBean extends BasePassportBean<LdapsPassport> {
|
|
|
|
private static final long serialVersionUID = -5233155996986308766L;
|
|
|
|
|
|
|
|
//认证URL
|
|
|
|
private String url;
|
|
|
|
//检索位置
|
|
|
|
private String searchBase;
|
|
|
|
//是否将BaseDN作为检索位置,是的话就加到url中,否则加到search的参数中
|
|
|
|
private boolean retrieveLocAsBaseDN;
|
|
|
|
//LDAP认证方式种类,none,simple,strong
|
|
|
|
private String authentication;
|
|
|
|
//context初始化的Factory,一般用这个默认值
|
|
|
|
private String contextFactory;
|
|
|
|
//指定将如何处理服务提供者遇到的引用的环境属性名称,follow, ignore, throw
|
|
|
|
private String referral;
|
|
|
|
//ldap用户后缀,如@finereport.com
|
|
|
|
private String principalSuffix;
|
|
|
|
//ldap系统的管理员姓名
|
|
|
|
private String systemName;
|
|
|
|
//ldap系统的管理员密码
|
|
|
|
private String systemPassword;
|
|
|
|
//ldaps证书路径
|
|
|
|
private String certPath;
|
|
|
|
|
|
|
|
public LdapsAuthenticBean() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getAuthentication() {
|
|
|
|
return authentication;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAuthentication(String authentication) {
|
|
|
|
this.authentication = authentication;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getContextFactory() {
|
|
|
|
return contextFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setContextFactory(String contextFactory) {
|
|
|
|
this.contextFactory = contextFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getPrincipalSuffix() {
|
|
|
|
return principalSuffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPrincipalSuffix(String principalSuffix) {
|
|
|
|
this.principalSuffix = principalSuffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getReferral() {
|
|
|
|
return referral;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setReferral(String referral) {
|
|
|
|
this.referral = referral;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSearchBase() {
|
|
|
|
return searchBase;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSearchBase(String searchBase) {
|
|
|
|
this.searchBase = searchBase;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSystemPassword() {
|
|
|
|
return systemPassword;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSystemPassword(String systemPassword) {
|
|
|
|
this.systemPassword = systemPassword;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSystemName() {
|
|
|
|
return systemName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSystemName(String systemName) {
|
|
|
|
this.systemName = systemName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isRetrieveLocAsBaseDN() {
|
|
|
|
return retrieveLocAsBaseDN;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRetrieveLocAsBaseDN(boolean retrieveLocAsBaseDN) {
|
|
|
|
this.retrieveLocAsBaseDN = retrieveLocAsBaseDN;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getUrl() {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUrl(String url) {
|
|
|
|
this.url = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getCertPath() {
|
|
|
|
return certPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCertPath(String certPath) {
|
|
|
|
this.certPath = certPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String markType() {
|
|
|
|
return LdapsPassportProvider.PASSPORT_TYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public BasePassportBean<LdapsPassport> createPassportBean(LdapsPassport passport) {
|
|
|
|
this.setUrl(passport.getLdapUrl());
|
|
|
|
this.setSearchBase(passport.getLdapSearchBase());
|
|
|
|
this.setRetrieveLocAsBaseDN(passport.isRetrieveLocAsBaseDN());
|
|
|
|
this.setAuthentication(passport.getAuthentication());
|
|
|
|
this.setContextFactory(passport.getContextFactory());
|
|
|
|
this.setReferral(passport.getReferral());
|
|
|
|
this.setPrincipalSuffix(passport.getPrincipalSuffix());
|
|
|
|
this.setSystemName(passport.getLdapSystemName());
|
|
|
|
if (StringKit.isNotEmpty(passport.getLdapSystemPassword())) {
|
|
|
|
this.setSystemPassword(CommonKit.fetchDefaultPasswordHolderString());
|
|
|
|
}
|
|
|
|
this.setCertPath(passport.getCertPath());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Passport createPassport() {
|
|
|
|
LdapsPassport passport = new LdapsPassport();
|
|
|
|
passport.setLdapUrl(getUrl());
|
|
|
|
passport.setLdapSearchBase(getSearchBase());
|
|
|
|
passport.setRetrieveLocAsBaseDN(isRetrieveLocAsBaseDN());
|
|
|
|
passport.setAuthentication(getAuthentication());
|
|
|
|
passport.setContextFactory(getContextFactory());
|
|
|
|
passport.setReferral(getReferral());
|
|
|
|
passport.setPrincipalSuffix(getPrincipalSuffix());
|
|
|
|
passport.setLdapSystemName(getSystemName());
|
|
|
|
if (CommonKit.isDefaultPasswordHolderString(this.systemPassword)) {
|
|
|
|
String oldPassword = LoginKit.getPassport(LdapsPassport.class).getLdapSystemPassword();
|
|
|
|
passport.setLdapSystemPassword(oldPassword);
|
|
|
|
} else {
|
|
|
|
passport.setLdapSystemPassword(CommonKit.getBase64DecodeStr(this.systemPassword));
|
|
|
|
}
|
|
|
|
passport.setCertPath(getCertPath());
|
|
|
|
return passport;
|
|
|
|
}
|
|
|
|
}
|