Commit 9d6894b9 by zhaoxiaolei

ldap

parent 84654aa2
...@@ -78,6 +78,8 @@ ...@@ -78,6 +78,8 @@
<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: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: 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: 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" 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: 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" /> <orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" />
...@@ -124,26 +126,6 @@ ...@@ -124,26 +126,6 @@
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" 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" 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" /> <orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.8" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.1.5.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.1.5.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.5.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.11.1" level="project" />
<orderEntry type="library" scope="TEST" 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" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.9.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" 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" scope="TEST" name="Maven: org.springframework:spring-test:5.1.7.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.5.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.5.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.8" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.8" level="project" />
...@@ -174,6 +156,7 @@ ...@@ -174,6 +156,7 @@
<orderEntry type="library" name="Maven: jakarta.persistence:jakarta.persistence-api:2.2.3" level="project" /> <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.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: 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: 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.jboss:jandex:2.0.5.Final" level="project" />
<orderEntry type="library" name="Maven: org.dom4j:dom4j:2.1.1" level="project" /> <orderEntry type="library" name="Maven: org.dom4j:dom4j:2.1.1" level="project" />
...@@ -208,9 +191,12 @@ ...@@ -208,9 +191,12 @@
<orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.woodstox:woodstox-core-asl:4.2.0" level="project" /> <orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.woodstox:woodstox-core-asl:4.2.0" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.woodstox:stax2-api:3.1.1" level="project" /> <orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.woodstox:stax2-api:3.1.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.0.2" level="project" /> <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-activation_1.1_spec:1.0.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.axis2:axis2-transport-http:1.7.7" level="project" />
<orderEntry type="library" name="Maven: commons-httpclient:commons-httpclient:3.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:2.1.0.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:2.1.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.1.5.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-ldap:2.1.5.RELEASE" level="project" />
<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> </component>
</module> </module>
\ No newline at end of file
...@@ -162,11 +162,6 @@ ...@@ -162,11 +162,6 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -234,15 +229,19 @@ ...@@ -234,15 +229,19 @@
<version>1.7.7</version> <version>1.7.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId> <artifactId>spring-cloud-context</artifactId>
<version>2.1.0.RELEASE</version> <version>2.1.0.RELEASE</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-ldap</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -5,6 +5,7 @@ import org.springframework.boot.SpringApplication; ...@@ -5,6 +5,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.ldap.repository.config.EnableLdapRepositories;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
......
...@@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSON; ...@@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
...@@ -20,7 +21,6 @@ import org.springframework.http.HttpMethod; ...@@ -20,7 +21,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -349,5 +349,12 @@ public class IntegrateController { ...@@ -349,5 +349,12 @@ public class IntegrateController {
return ResultGenerator.genSuccessResult(integrateService.getUserDimension(userinfo)); return ResultGenerator.genSuccessResult(integrateService.getUserDimension(userinfo));
} }
@PostMapping("/checkToken")
@ApiOperation(value = "检查token是否过期", notes = "checkToken", httpMethod = "POST")
public CrmResponseEntity<?> checkToken(@RequestBody UserInfo userinfo) {
return ResultGenerator.genSuccessResult(integrateService.checkToken(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
...@@ -6,6 +6,7 @@ import lombok.experimental.Accessors; ...@@ -6,6 +6,7 @@ import lombok.experimental.Accessors;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient;
@Accessors(chain = true) @Accessors(chain = true)
@NoArgsConstructor @NoArgsConstructor
...@@ -25,4 +26,6 @@ public class UserInfo { ...@@ -25,4 +26,6 @@ public class UserInfo {
private String userName; private String userName;
@Column(name = "user_dimension") @Column(name = "user_dimension")
private String userDimension; private String userDimension;
@Transient
private String token;
} }
...@@ -46,4 +46,8 @@ public interface IntegrateService { ...@@ -46,4 +46,8 @@ public interface IntegrateService {
Object getToken(UserInfo userinfo); Object getToken(UserInfo userinfo);
Object getUserDimension(UserInfo userinfo); Object getUserDimension(UserInfo userinfo);
Object checkToken(UserInfo userinfo);
boolean ldapAuth(String username, String passWord);
} }
...@@ -19,6 +19,8 @@ import org.springframework.http.HttpEntity; ...@@ -19,6 +19,8 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.filter.EqualsFilter;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -70,7 +72,19 @@ public class IntegrateServiceImpl implements IntegrateService { ...@@ -70,7 +72,19 @@ public class IntegrateServiceImpl implements IntegrateService {
private String content_type_msg; private String content_type_msg;
@Value("${plm.header_Authorization}") @Value("${plm.header_Authorization}")
private String headerAuthorization; private String headerAuthorization;
@Value("${spring.ldap.base}")
private String base;
@Autowired
private LdapTemplate ldapTemplate;
@Override
public boolean ldapAuth(String username, String passWord) {
EqualsFilter filter = new EqualsFilter("sAMAccountName", username);
return ldapTemplate.authenticate(base, filter.toString(), passWord);
}
@Override @Override
public GetProductOutDto setSuperBOMInfo(List<SaveSuperBomInputDto> saveSuperBomInputDtos) { public GetProductOutDto setSuperBOMInfo(List<SaveSuperBomInputDto> saveSuperBomInputDtos) {
...@@ -647,6 +661,12 @@ public class IntegrateServiceImpl implements IntegrateService { ...@@ -647,6 +661,12 @@ public class IntegrateServiceImpl implements IntegrateService {
return result; return result;
} }
@Override
public Object checkToken(UserInfo userinfo) {
return null;
}
/** /**
* @return Configid, SKUCode,SKUCode,产品型号,产品小型好,69码 * @return Configid, SKUCode,SKUCode,产品型号,产品小型好,69码
......
package cn.com.uitech.authorization.utils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
@Configuration
public class LdapConfig {
@Value("${spring.ldap.urls}")
private String ldapUrl;
@Value("${spring.ldap.username}")
private String userName;
@Value("${spring.ldap.password}")
private String passWord;
@Value("${spring.ldap.base}")
private String base;
@Bean
public LdapContextSource ldapContextSource(){
LdapContextSource source = new LdapContextSource();
source.setBase(base);
source.setUrl(ldapUrl);
source.setPassword(passWord);
source.setUserDn(userName);
return source;
}
@Bean
public LdapTemplate ldapTemplate(){
return new LdapTemplate(ldapContextSource());
}
}
...@@ -36,6 +36,11 @@ spring: ...@@ -36,6 +36,11 @@ spring:
sleuth: sleuth:
sampler: sampler:
probability: 1.0 probability: 1.0
ldap:
urls: ldap://10.0.2.3:389
base: OU=紫光计算机,DC=unispc,DC=com
username: ldapupdate
password: 6KRutglNdiXp
selector: selector:
url: http://10.0.4.24:8080/api/v1/selector url: http://10.0.4.24:8080/api/v1/selector
......
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