...
 
Commits (2)
    https://gitcode.net/fujieid/jap/-/commit/b59537c0624315f2396f9965eaf19e1ed6d8a1a0 :sparkles: change: Format maven dependencies 2021-10-21T22:16:21+08:00 yadong.zhang yadong.zhang0415@gmail.com https://gitcode.net/fujieid/jap/-/commit/213b617605fc88bb47fc0c9adc3a2bc5e5ac16e7 :zap: change: Optimize the code 2021-10-22T10:39:11+08:00 yadong.zhang yadong.zhang0415@gmail.com
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.fujieid</groupId>
......@@ -27,12 +27,11 @@
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
......@@ -27,7 +27,6 @@ import com.fujieid.jap.core.store.JapUserStore;
import com.fujieid.jap.core.strategy.AbstractJapStrategy;
import com.fujieid.jap.http.JapHttpRequest;
import com.fujieid.jap.http.JapHttpResponse;
import com.fujieid.jap.ldap.exception.LdapPasswordException;
import com.fujieid.jap.ldap.model.LdapPerson;
import com.fujieid.jap.ldap.template.LdapDefaultTemplate;
import com.fujieid.jap.ldap.template.LdapTemplate;
......@@ -68,9 +67,14 @@ public class LdapStrategy extends AbstractJapStrategy {
String username = request.getParameter(ldapConfig.getUsernameField());
String password = request.getParameter(ldapConfig.getPasswordField());
LdapTemplate ldapTemplate = new LdapDefaultTemplate(new LdapDataSource(ldapConfig));
LdapPerson ldapPerson = ldapTemplate.login(username, password);
LdapPerson ldapPerson = null;
try {
ldapPerson = ldapTemplate.login(username, password);
} catch (JapException e) {
return JapResponse.error(e.getErrorCode(), e.getErrorMessage());
}
if (null == ldapPerson) {
throw new LdapPasswordException(JapErrorCode.INVALID_PASSWORD);
return JapResponse.error(JapErrorCode.INVALID_PASSWORD);
}
JapUser japUser = this.japUserService.createAndGetLdapUser(ldapPerson);
if (null == japUser) {
......
......@@ -89,6 +89,8 @@
<jap-http-jakarta-adapter.version>1.0.2</jap-http-jakarta-adapter.version>
<!-- Only for jap-mfa -->
<httpclient.version>4.5.13</httpclient.version>
<!-- Only for jap-ldap -->
<commons-codec.version>1.15</commons-codec.version>
</properties>
<dependencies>
......@@ -267,6 +269,11 @@
<artifactId>jap-http-jakarta-adapter</artifactId>
<version>${jap-http-jakarta-adapter.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
......