Commit f9467261 by zhaoxiaolei

LDAP

parent 3ba85684
......@@ -7,6 +7,10 @@
<facet type="web" name="Web">
<configuration>
<webroots />
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>
</facet>
<facet type="kotlin-language" name="Kotlin">
......@@ -38,6 +42,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
......@@ -78,8 +83,6 @@
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.1.7.RELEASE" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" />
......@@ -123,6 +126,25 @@
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.36.Final" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.2.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-test:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
<orderEntry type="library" name="Maven: net.minidev:json-smart:2.3" level="project" />
<orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
<orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
<orderEntry type="library" name="Maven: org.assertj:assertj-core:3.11.1" level="project" />
<orderEntry type="library" name="Maven: org.mockito:mockito-core:2.23.4" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.9.12" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy-agent:1.9.12" level="project" />
<orderEntry type="library" name="Maven: org.objenesis:objenesis:2.6" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-test:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.xmlunit:xmlunit-core:2.6.2" level="project" />
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.6.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.8" level="project" />
......@@ -156,7 +178,6 @@
<orderEntry type="library" name="Maven: jakarta.persistence:jakarta.persistence-api:2.2.3" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:5.3.10.Final" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.23.2-GA" level="project" />
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.9.12" level="project" />
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.jboss:jandex:2.0.5.Final" level="project" />
<orderEntry type="library" name="Maven: org.dom4j:dom4j:2.1.1" level="project" />
......@@ -197,6 +218,5 @@
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-ldap:2.1.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.ldap:spring-ldap-core:2.3.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -19,6 +19,7 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.ldap.filter.EqualsFilter;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.Errors;
......@@ -349,12 +350,16 @@ public class IntegrateController {
return ResultGenerator.genSuccessResult(integrateService.getUserDimension(userinfo));
}
@PostMapping("/checkToken")
@PostMapping("/checkUserToken")
@ApiOperation(value = "检查token是否过期", notes = "checkToken", httpMethod = "POST")
public CrmResponseEntity<?> checkToken(@RequestBody UserInfo userinfo) {
return ResultGenerator.genSuccessResult(integrateService.checkToken(userinfo));
public CrmResponseEntity<?> checkUserToken(@RequestBody UserInfo userinfo) {
return ResultGenerator.genSuccessResult(integrateService.checkUserToken(userinfo));
}
@PostMapping("/ldapAuth")
@ApiOperation(value = "登录LDAP验证用户", notes = "ldapAuth", httpMethod = "POST")
public CrmResponseEntity<?> ldapAuth(@RequestBody UserInfo userinfo) {
return ResultGenerator.genSuccessResult(integrateService.ldapAuth(userinfo));
}
}
package cn.com.uitech.authorization.controller;
import cn.com.uitech.authorization.service.IntegrateService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@Controller
public class aquanTest {
@Autowired
IntegrateService integrateService;
@Test
public void testOne() {
System.out.println("验证结果"+integrateService.ldapAuth("ldapupdate","6KRutglNdiXp"));
}
}
\ No newline at end of file
......@@ -11,4 +11,6 @@ public interface UserInfoMapper extends IBaseMapper<UserInfo> {
UserInfo getUser(UserInfo userinfo);
List<MenuInfo> getUserDimension(String userCode);
UserInfo getUserOne(UserInfo userinfo);
}
package cn.com.uitech.authorization.pojo.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.ldap.odm.annotations.Attribute;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.annotations.Id;
import javax.naming.Name;
@Entry(objectClasses = {"person"})
public class Person {
@Id
@JsonIgnore // 必写
private Name distinguishedName;
/* 登录账号 */
@Attribute(name = "sAMAccountName")
private String loginName;
/* 用户姓名 */
@Attribute(name = "cn")
private String userName;
/* 邮箱 */
@Attribute(name = "mail")
private String email;
// gettet...setter...toString...
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ public class UserInfo {
@Column(name = "user_code")
private String userCode;
@Column(name = "pass_word")
private String password;
private String passWord;
@Column(name = "user_name")
private String userName;
@Column(name = "user_dimension")
......
......@@ -47,7 +47,7 @@ public interface IntegrateService {
Object getUserDimension(UserInfo userinfo);
Object checkToken(UserInfo userinfo);
Object checkUserToken(UserInfo userinfo);
boolean ldapAuth(String username, String passWord);
Object ldapAuth(UserInfo userinfo);
}
......@@ -120,6 +120,7 @@ public class TempServiceImpl implements TempServer {
result.setMsg(msg);
}
}
getTempList();
}else{
result.setCode(200);
result.setMsg("数据初始化完成");
......
......@@ -36,6 +36,11 @@ spring:
sleuth:
sampler:
probability: 1.0
ldap:
urls: ldap://10.0.2.3:389
base: OU=紫光计算机,DC=unispc,DC=com
username: ldapupdate
password: 6KRutglNdiXp
selector:
url: http://172.16.0.89:8080/api/v1/selector
......
......@@ -2,7 +2,7 @@ server:
port: 8081
spring:
profiles:
active: lcrx-prod
active: lcrx
application:
name: ${APPLICATION_NAME:uitech}--${SERVICE_NAME:system}
# 遇到相同名字时,是否允许覆盖注册
......
......@@ -4,7 +4,7 @@
<mapper namespace="cn.com.uitech.authorization.mapper.UserInfoMapper">
<select id="getUser" resultType="cn.com.uitech.authorization.pojo.entity.UserInfo">
select * from user_info where user_code = #{userCode} and pass_word = #{password}
select * from user_info where user_code = #{userCode} and pass_word = #{passWord}
</select>
<select id="getUserDimension" resultType="cn.com.uitech.authorization.pojo.entity.MenuInfo">
......@@ -17,4 +17,8 @@
WHERE
A.user_code = #{userCode}
</select>
<select id="getUserOne" resultType="cn.com.uitech.authorization.pojo.entity.UserInfo">
select * from user_info where user_code = #{userCode}
</select>
</mapper>
\ No newline at end of file
package cn.com.uitech.authorization.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.*;
/**
* @Author: ZXN
* @Date: 2021/12/29/11:01
* @Description:
* @version: 1.0
* This Class Created with IntelliJ IDEA 2019.1.4
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class IntegrateServiceTest {
@Autowired
private IntegrateService integrateService;
@Test
public void ldapAuth() {
System.out.println("验证结果"+integrateService.ldapAuth("ldapupdate","6KRutglNdiXp"));
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment