mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-20 17:48:10 +08:00
v2.9.0
This commit is contained in:
@@ -29,6 +29,10 @@ public class ChangePassword extends JpaBaseEntity{
|
||||
private String id;
|
||||
private String uid;
|
||||
private String username;
|
||||
private String email;
|
||||
private String mobile;
|
||||
private String windowsAccount;
|
||||
private String employeeNumber;
|
||||
private String displayName;
|
||||
private String oldPassword;
|
||||
private String password;
|
||||
@@ -155,6 +159,16 @@ public class ChangePassword extends JpaBaseEntity{
|
||||
}
|
||||
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
@@ -165,6 +179,36 @@ public class ChangePassword extends JpaBaseEntity{
|
||||
}
|
||||
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
public String getWindowsAccount() {
|
||||
return windowsAccount;
|
||||
}
|
||||
|
||||
|
||||
public void setWindowsAccount(String windowsAccount) {
|
||||
this.windowsAccount = windowsAccount;
|
||||
}
|
||||
|
||||
|
||||
public String getEmployeeNumber() {
|
||||
return employeeNumber;
|
||||
}
|
||||
|
||||
|
||||
public void setEmployeeNumber(String employeeNumber) {
|
||||
this.employeeNumber = employeeNumber;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -32,6 +32,9 @@ public class HistoryConnector extends JpaBaseEntity implements Serializable{
|
||||
@Column
|
||||
String conType;
|
||||
|
||||
@Column
|
||||
String conAction;
|
||||
|
||||
@Column
|
||||
String sourceId;
|
||||
|
||||
@@ -178,36 +181,48 @@ public class HistoryConnector extends JpaBaseEntity implements Serializable{
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("HistoryConnector [id=");
|
||||
builder.append(id);
|
||||
builder.append(", conName=");
|
||||
builder.append(conName);
|
||||
builder.append(", conType=");
|
||||
builder.append(conType);
|
||||
builder.append(", sourceId=");
|
||||
builder.append(sourceId);
|
||||
builder.append(", sourceName=");
|
||||
builder.append(sourceName);
|
||||
builder.append(", objectId=");
|
||||
builder.append(objectId);
|
||||
builder.append(", objectName=");
|
||||
builder.append(objectName);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append(", syncTime=");
|
||||
builder.append(syncTime);
|
||||
builder.append(", result=");
|
||||
builder.append(result);
|
||||
builder.append(", startDate=");
|
||||
builder.append(startDate);
|
||||
builder.append(", endDate=");
|
||||
builder.append(endDate);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
public String getConAction() {
|
||||
return conAction;
|
||||
}
|
||||
|
||||
|
||||
public void setConAction(String conAction) {
|
||||
this.conAction = conAction;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("HistoryConnector [id=");
|
||||
builder.append(id);
|
||||
builder.append(", conName=");
|
||||
builder.append(conName);
|
||||
builder.append(", conType=");
|
||||
builder.append(conType);
|
||||
builder.append(", conAction=");
|
||||
builder.append(conAction);
|
||||
builder.append(", sourceId=");
|
||||
builder.append(sourceId);
|
||||
builder.append(", sourceName=");
|
||||
builder.append(sourceName);
|
||||
builder.append(", objectId=");
|
||||
builder.append(objectId);
|
||||
builder.append(", objectName=");
|
||||
builder.append(objectName);
|
||||
builder.append(", description=");
|
||||
builder.append(description);
|
||||
builder.append(", syncTime=");
|
||||
builder.append(syncTime);
|
||||
builder.append(", result=");
|
||||
builder.append(result);
|
||||
builder.append(", startDate=");
|
||||
builder.append(startDate);
|
||||
builder.append(", endDate=");
|
||||
builder.append(endDate);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -65,42 +65,41 @@ public class ActiveDirectoryUtils extends LdapUtils {
|
||||
this.ctx = dirContext;
|
||||
}
|
||||
|
||||
// connect to ActiveDirectory server
|
||||
@Override
|
||||
public DirContext openConnection() {
|
||||
_logger.info("PROVIDER_URL:" + providerUrl);
|
||||
_logger.info("SECURITY_PRINCIPAL:" + principal);
|
||||
_logger.info("SECURITY_CREDENTIALS:" + credentials);
|
||||
// LDAP
|
||||
Properties props = new Properties();
|
||||
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||
props.setProperty(Context.URL_PKG_PREFIXES, "com.sun.jndi.url");
|
||||
props.setProperty(Context.REFERRAL, referral);
|
||||
props.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
|
||||
|
||||
props.setProperty(Context.PROVIDER_URL, providerUrl);
|
||||
|
||||
if (activeDirectoryDomain == null && domain.indexOf(".") > -1) {
|
||||
activeDirectoryDomain = domain.substring(0, domain.indexOf("."));
|
||||
}else {
|
||||
activeDirectoryDomain = domain;
|
||||
}
|
||||
|
||||
_logger.info("PROVIDER_DOMAIN:" + activeDirectoryDomain + " for " + domain);
|
||||
String activeDirectoryPrincipal = activeDirectoryDomain + "\\" + principal;
|
||||
_logger.debug("Active Directory SECURITY_PRINCIPAL : " + activeDirectoryPrincipal);
|
||||
props.setProperty(Context.SECURITY_PRINCIPAL, activeDirectoryPrincipal);
|
||||
props.setProperty(Context.SECURITY_CREDENTIALS, credentials);
|
||||
|
||||
if (ssl && providerUrl.toLowerCase().startsWith("ldaps")) {
|
||||
_logger.info("ldaps security protocol.");
|
||||
System.setProperty("javax.net.ssl.trustStore", trustStore);
|
||||
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
|
||||
props.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
}
|
||||
props.put(Context.REFERRAL, "follow");
|
||||
|
||||
return InitialDirContext(props);
|
||||
protected void initEnvironment() {
|
||||
if(props == null) {
|
||||
_logger.info("PROVIDER_URL:" + providerUrl);
|
||||
_logger.info("SECURITY_PRINCIPAL:" + principal);
|
||||
_logger.info("SECURITY_CREDENTIALS:" + credentials);
|
||||
// LDAP
|
||||
props = new Properties();
|
||||
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||
props.setProperty(Context.URL_PKG_PREFIXES, "com.sun.jndi.url");
|
||||
props.setProperty(Context.REFERRAL, referral);
|
||||
props.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
|
||||
|
||||
props.setProperty(Context.PROVIDER_URL, providerUrl);
|
||||
|
||||
if (domain.indexOf(".") > -1) {
|
||||
activeDirectoryDomain = domain.substring(0, domain.indexOf("."));
|
||||
}else {
|
||||
activeDirectoryDomain = domain;
|
||||
}
|
||||
|
||||
_logger.info("PROVIDER_DOMAIN:" + activeDirectoryDomain + " for " + domain);
|
||||
String activeDirectoryPrincipal = activeDirectoryDomain + "\\" + principal;
|
||||
_logger.debug("Active Directory SECURITY_PRINCIPAL : " + activeDirectoryPrincipal);
|
||||
props.setProperty(Context.SECURITY_PRINCIPAL, activeDirectoryPrincipal);
|
||||
props.setProperty(Context.SECURITY_CREDENTIALS, credentials);
|
||||
|
||||
if (ssl && providerUrl.toLowerCase().startsWith("ldaps")) {
|
||||
_logger.info("ldaps security protocol.");
|
||||
System.setProperty("javax.net.ssl.trustStore", trustStore);
|
||||
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
|
||||
props.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
}
|
||||
props.put(Context.REFERRAL, "follow");
|
||||
}
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
|
||||
@@ -53,6 +53,7 @@ public class LdapUtils {
|
||||
protected String trustStorePassword;
|
||||
protected boolean ssl;
|
||||
protected int searchScope;
|
||||
protected Properties props;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -90,42 +91,60 @@ public class LdapUtils {
|
||||
}
|
||||
|
||||
protected DirContext InitialDirContext(Properties properties) {
|
||||
if(ctx == null) {
|
||||
ctx =createDirContext(properties);
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
protected DirContext createDirContext(Properties properties) {
|
||||
DirContext ctx = null;
|
||||
try {
|
||||
ctx = new InitialDirContext(properties);
|
||||
ctx = new InitialDirContext(properties);
|
||||
_logger.info("connect to ldap " + providerUrl + " seccessful.");
|
||||
} catch (NamingException e) {
|
||||
_logger.error("connect to ldap " + providerUrl + " fail.");
|
||||
e.printStackTrace();
|
||||
_logger.error(e.getMessage());
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
protected void initEnvironment() {
|
||||
// LDAP
|
||||
if(props == null) {
|
||||
_logger.debug("PROVIDER_URL:" + providerUrl);
|
||||
_logger.debug("SECURITY_PRINCIPAL:" + principal);
|
||||
_logger.trace("SECURITY_CREDENTIALS:" + credentials);
|
||||
props = new Properties();
|
||||
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||
props.setProperty(Context.URL_PKG_PREFIXES, "com.sun.jndi.url");
|
||||
props.setProperty(Context.REFERRAL, referral);
|
||||
props.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
|
||||
|
||||
props.setProperty(Context.PROVIDER_URL, providerUrl);
|
||||
props.setProperty(Context.SECURITY_PRINCIPAL, principal);
|
||||
props.setProperty(Context.SECURITY_CREDENTIALS, credentials);
|
||||
|
||||
if (ssl && providerUrl.toLowerCase().startsWith("ldaps")) {
|
||||
System.setProperty("javax.net.ssl.trustStore", trustStore);
|
||||
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
|
||||
props.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
props.put(Context.REFERRAL, "follow");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// connect to ldap server
|
||||
public DirContext openConnection() {
|
||||
_logger.debug("PROVIDER_URL:" + providerUrl);
|
||||
_logger.debug("SECURITY_PRINCIPAL:" + principal);
|
||||
_logger.trace("SECURITY_CREDENTIALS:" + credentials);
|
||||
// LDAP
|
||||
Properties props = new Properties();
|
||||
props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||
props.setProperty(Context.URL_PKG_PREFIXES, "com.sun.jndi.url");
|
||||
props.setProperty(Context.REFERRAL, referral);
|
||||
props.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
|
||||
|
||||
props.setProperty(Context.PROVIDER_URL, providerUrl);
|
||||
props.setProperty(Context.SECURITY_PRINCIPAL, principal);
|
||||
props.setProperty(Context.SECURITY_CREDENTIALS, credentials);
|
||||
|
||||
if (ssl && providerUrl.toLowerCase().startsWith("ldaps")) {
|
||||
System.setProperty("javax.net.ssl.trustStore", trustStore);
|
||||
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
|
||||
props.put(Context.SECURITY_PROTOCOL, "ssl");
|
||||
props.put(Context.REFERRAL, "follow");
|
||||
}
|
||||
|
||||
initEnvironment();
|
||||
return InitialDirContext(props);
|
||||
}
|
||||
|
||||
// connect to ldap server
|
||||
public DirContext createConnection() {
|
||||
initEnvironment();
|
||||
return createDirContext(props);
|
||||
}
|
||||
|
||||
public boolean authenticate() {
|
||||
openConnection();
|
||||
|
||||
Reference in New Issue
Block a user