提交 d68b0c97 authored 作者: 1239068511@qq.com's avatar 1239068511@qq.com

[代码更新] 完善了这个系统 到目前位置2021.09.15 基础功能大体完成,开始对接其他系统

上级 5b3474bf
......@@ -15,6 +15,7 @@
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
......@@ -222,30 +223,47 @@
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<resources>
<!-- <resource>-->
<!-- <directory>src/main/java</directory>-->
<!-- <includes>-->
<!-- <include>**/*</include>-->
<!-- </includes>-->
<!-- <excludes>-->
<!-- <exclude>**/.svn/*</exclude>-->
<!-- </excludes>-->
<!-- <filtering>false</filtering>-->
<!-- </resource>-->
<!-- <resource>-->
<!-- <directory>${project.basedir}/src/main/resources</directory>-->
<!-- <targetPath>META-INF/resources/</targetPath>-->
<!-- </resource>-->
<!-- <resource>-->
<!-- <directory>src/main/java</directory>-->
<!-- <includes>-->
<!-- <include>**/*</include>-->
<!-- </includes>-->
<!-- <excludes>-->
<!-- <exclude>**/.svn/*</exclude>-->
<!-- </excludes>-->
<!-- <filtering>false</filtering>-->
<!-- </resource>-->
<!-- <resource>-->
<!-- <directory>${project.basedir}/src/main/resources</directory>-->
<!-- <targetPath>META-INF/resources/</targetPath>-->
<!-- </resource>-->
</resources>
<plugins>
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- </plugin>-->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
......
package com.tykj.workflowcore.base.util;
import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.user.util.SpringUtils;
import org.apache.http.HttpHeaders;
import org.apache.http.NameValuePair;
import org.apache.http.client.CookieStore;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
/**
* HttpClient调用封装
*
* @author HuangXiahao
* @version V1.0
* @class AuthenticationUtils
* @packageName com.example.personnelmanager.common.utils
**/
@SuppressWarnings("ALL")
@Component
public class HttpClientUtil {
@Autowired
CookieStore cookieStore;
private CloseableHttpClient getClient() {
return SpringUtils.getBean("client");
}
public String post(String url, List<NameValuePair> param, String encode) {
HttpPost post = new HttpPost(url);
String result = null;
CloseableHttpResponse response = null;
try {
if (param != null) {
try {
post.setEntity(new UrlEncodedFormEntity(param));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
response = getClient().execute(post);
result = ResponseEntityUtil.entityToString(response, encode);
} catch (IOException e) {
throw new ApiException("请求接口出现错误");
} finally {
try {
if (post != null) {
post.abort();
post.releaseConnection();
}
if (response != null) {
if (response.getEntity() != null) {
EntityUtils.consumeQuietly(response.getEntity());
}
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
public String delete(String url, List<NameValuePair> param, String encode) {
HttpDeleteWithBody deleteWithBody = new HttpDeleteWithBody(url);
String result = null;
CloseableHttpResponse response = null;
try {
if (param != null) {
try {
deleteWithBody.setEntity(new UrlEncodedFormEntity(param));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
response = getClient().execute(deleteWithBody);
result = ResponseEntityUtil.entityToString(response, encode);
} catch (IOException e) {
throw new ApiException("请求接口出现错误");
} finally {
try {
if (deleteWithBody != null) {
deleteWithBody.abort();
deleteWithBody.releaseConnection();
}
if (response != null) {
if (response.getEntity() != null) {
EntityUtils.consumeQuietly(response.getEntity());
}
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
public String post(String url, String param, String encode) {
String result = null;
HttpPost post = new HttpPost(url);
CloseableHttpResponse response = null;
try {
if (!StringUtils.isEmpty(param)) {
StringEntity stringEntity = new StringEntity(param, "utf-8");
if (post.getHeaders(HttpHeaders.CONTENT_TYPE).length < 1) {
post.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
}
post.setEntity(stringEntity);
}
response = getClient().execute(post);
result = ResponseEntityUtil.entityToString(response, encode);
} catch (IOException e) {
throw new ApiException("请求接口出现错误");
} finally {
try {
if (post != null) {
post.abort();
post.releaseConnection();
}
if (response != null) {
if (response.getEntity() != null) {
EntityUtils.consumeQuietly(response.getEntity());
}
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
public String put(String url, String param, String encode) {
String result = null;
HttpPut post = new HttpPut(url);
CloseableHttpResponse response = null;
try {
if (!StringUtils.isEmpty(param)) {
StringEntity stringEntity = new StringEntity(param, "utf-8");
if (post.getHeaders(HttpHeaders.CONTENT_TYPE).length < 1) {
post.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
}
post.setEntity(stringEntity);
}
response = getClient().execute(post);
result = ResponseEntityUtil.entityToString(response, encode);
} catch (IOException e) {
throw new ApiException("请求接口出现错误");
} finally {
try {
if (post != null) {
post.abort();
post.releaseConnection();
}
if (response != null) {
if (response.getEntity() != null) {
EntityUtils.consumeQuietly(response.getEntity());
}
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
public String get(String url, String encode) {
HttpGet get = new HttpGet(url);
String result = null;
CloseableHttpResponse response = null;
try {
response = getClient().execute(get);
result = ResponseEntityUtil.entityToString(response, encode);
} catch (IOException e) {
throw new ApiException("请求接口出现错误");
} finally {
try {
if (get != null) {
get.abort();
get.releaseConnection();
}
if (response != null) {
if (response.getEntity() != null) {
EntityUtils.consumeQuietly(response.getEntity());
}
response.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
}
package com.tykj.workflowcore.base.util;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import java.net.URI;
/**
* @author HuangXiahao
* @version V1.0
* @class HttpDeleteWithBody
* @packageName com.example.personnelmanager.common.utils
* @data 2020/6/19
**/
public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
public static final String METHOD_NAME = "DELETE";
/**
* 获取方法(必须重载)
*
* @return
*/
@Override
public String getMethod() {
return METHOD_NAME;
}
public HttpDeleteWithBody(final String uri) {
super();
setURI(URI.create(uri));
}
public HttpDeleteWithBody(final URI uri) {
super();
setURI(uri);
}
public HttpDeleteWithBody() {
super();
}
}
\ No newline at end of file
package com.tykj.workflowcore.base.util;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import java.io.IOException;
import java.io.InputStream;
public class ResponseEntityUtil {
public static String entityToString(CloseableHttpResponse response,String encode) {
EntityThread entityThread = new EntityThread(response,encode);
entityThread.start();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
String result = null;
result = entityThread.result;
if (result == null) {
entityThread.interrupt();
}
return result;
}
static class EntityThread extends Thread{
CloseableHttpResponse response;
String encode;
String result;
EntityThread( CloseableHttpResponse response,String encode){
this.response = response;
this.encode = encode;
}
@Override
public void run() {
try {
InputStream responseStream = response.getEntity().getContent();
result = IOUtils.toString(responseStream,encode);
responseStream.close();
} catch (IOException e) {
e.printStackTrace();
}
super.run();
}
}
}
......@@ -2,8 +2,10 @@ package com.tykj.workflowcore.user.authencation;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tykj.workflowcore.user.authencation.filter.CustomJwtAuthenticationFilter;
import com.tykj.workflowcore.user.authencation.filter.CustomUsernamePasswordAuthenticationFilter;
import com.tykj.workflowcore.user.authencation.filter.SuccessHandler;
import com.tykj.workflowcore.user.authencation.provider.JwtAuthenticationProvider;
import com.tykj.workflowcore.user.authencation.provider.UsernamePasswordAuthenticationProvider;
import com.tykj.workflowcore.user.service.CenterUserService;
import com.tykj.workflowcore.user.util.AuthenticationUtils;
......@@ -69,11 +71,19 @@ public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
final JwtTokenUtils jwtTokenUtils;
public SecurityWebConfig(UsernamePasswordAuthenticationProvider usernamePasswordAuthenticationProvider, CenterUserService centerUserService, AuthenticationUtils authenticationUtils, JwtTokenUtils jwtTokenUtils) {
/**
*自定义Jwt用户验证类
**/
final
JwtAuthenticationProvider jwtAuthenticationProvider;
public SecurityWebConfig(UsernamePasswordAuthenticationProvider usernamePasswordAuthenticationProvider, CenterUserService centerUserService, AuthenticationUtils authenticationUtils, JwtTokenUtils jwtTokenUtils, JwtAuthenticationProvider jwtAuthenticationProvider) {
this.usernamePasswordAuthenticationProvider = usernamePasswordAuthenticationProvider;
this.centerUserService = centerUserService;
this.authenticationUtils = authenticationUtils;
this.jwtTokenUtils = jwtTokenUtils;
this.jwtAuthenticationProvider = jwtAuthenticationProvider;
}
/**
......@@ -137,7 +147,9 @@ public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
out.close();
}), ConcurrentSessionFilter.class)
.addFilterAt(customUsernamePasswordAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
// .addFilterAt(new JwtAuthenticationTokenFilter(jwtTokenUtils), BasicAuthenticationFilter.class);
http.addFilterAt(customJwtUsernamePasswordAuthenticationFilter(),UsernamePasswordAuthenticationFilter.class);
// .addFilterAt(new JwtAuthenticationTokenFilter(jwtTokenUtils), BasicAuthenticationFilter.class);
}
/***
......@@ -156,8 +168,12 @@ public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
}
@Bean
public SessionRegistryImpl sessionRegistry() {
return new SessionRegistryImpl();
CustomJwtAuthenticationFilter customJwtUsernamePasswordAuthenticationFilter() throws Exception {
CustomJwtAuthenticationFilter filter = new CustomJwtAuthenticationFilter();
filter.setAuthenticationManager(authenticationManager());
filter.setAuthenticationSuccessHandler(new CustomAuthenticationSuccessHandler());
filter.setAuthenticationFailureHandler(new CustomAuthenticationFailureHandler());
return filter;
}
/***
......@@ -168,9 +184,16 @@ public class SecurityWebConfig extends WebSecurityConfigurerAdapter {
*/
@Override
protected void configure(AuthenticationManagerBuilder auth) {
auth.authenticationProvider(jwtAuthenticationProvider);
auth.authenticationProvider(usernamePasswordAuthenticationProvider);
}
@Bean
public SessionRegistryImpl sessionRegistry() {
return new SessionRegistryImpl();
}
/***
* 登录成功后干些啥
*/
......
/*
* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tykj.workflowcore.user.authencation.filter;
import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.user.authencation.token.JwtAuthencationToken;
import com.tykj.workflowcore.user.pojo.StorageKey;
import com.tykj.workflowcore.user.pojo.User;
import com.tykj.workflowcore.user.util.CipherUtil;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;
import io.jsonwebtoken.Jwts;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Jwt凭证验证拦截器
*
* @author HuangXiahao
* @version V1.0
* @class CustomJWTAuthenticationFilter
* @packageName com.example.personnelmanager.common.authencation.filter
* @data 2020/6/13
**/
public class CustomJwtAuthenticationFilter extends
AbstractAuthenticationProcessingFilter {
public static final String JWT_KEY = "jwt";
/**
* Jwt公钥路径
*/
String jwtFilePath;
public CustomJwtAuthenticationFilter() {
//设置用户接口的路径以及访问方式
super(new AntPathRequestMatcher("/user/login", "GET"));
}
/***
* 在这个方法中执行验证操作
* @param request
* @param response
* @Return : org.springframework.security.core.Authentication
*/
@Override
public Authentication attemptAuthentication(HttpServletRequest request,
HttpServletResponse response) throws AuthenticationException {
JwtAuthencationToken authRequest ;
User userByJwt;
//如果请求头中没有jwt凭证的话说明不应该使用该类进行验证,直接报错
if (!StringUtils.isEmpty(request.getHeader(JWT_KEY))) {
//通过请求头获取jwt凭证中的用户信息
userByJwt = getuserbyjwt(request);
authRequest = new JwtAuthencationToken(
userByJwt);
//为用于验证的用户注入session信息
setDetails(request, authRequest);
//进行验证
return getAuthenticationManager().authenticate(authRequest);
} else {
throw new ApiException("未设置token");
}
}
/***
* 为用户注入session信息
* @param request
* @param authRequest
* @Return : void
*/
protected void setDetails(HttpServletRequest request,
JwtAuthencationToken authRequest) {
authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
}
/***
* 通过请求头获取请求头中的用户信息
*
* @param request
* @Return : com.example.personnelmanager.entity.User
*/
public User getuserbyjwt(HttpServletRequest request) {
StorageKey storageKey = new StorageKey();
String rsaPrivateKey = storageKey.getRsaPrivateKey();
String signPublicKey = storageKey.getSignPublicKey();
String jwt = request.getHeader("jwt");
try {
String decrypt = CipherUtil.decrypt(jwt, CipherUtil.string2PrivateKey(rsaPrivateKey));
Jws<Claims> claimsJws = Jwts.parser().setSigningKey(CipherUtil.string2PublicKey(signPublicKey)).parseClaimsJws(decrypt);
logger.info("接收到的用户信息为:"+claimsJws.getBody());
User userRight = new User();
Claims body = claimsJws.getBody();
userRight.setUsername((String) body.get("username"));
userRight.setPhone((String) body.get("phone"));
return userRight;
}catch (Exception e){
logger.error("用户凭证无效");
throw new UsernameNotFoundException("用户凭证无效");
}
}
}
package com.tykj.workflowcore.user.authencation.provider;
import com.tykj.workflowcore.user.authencation.checks.DefaultPreAuthenticationChecks;
import com.tykj.workflowcore.user.authencation.token.JwtAuthencationToken;
import com.tykj.workflowcore.user.pojo.User;
import com.tykj.workflowcore.user.service.CenterUserService;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.InternalAuthenticationServiceException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsChecker;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
/**
* 自定义SpringSecurity的用户处理类类
* 当用户通过统一登录平台访问本系统时由该类进行用户验证
*
* @author HuangXiahao
* @version V1.0
* @class JWTAuthenticationProvider
* @packageName com.example.personnelmanager.common.SpringSecurityProvider
* @data 2020/6/13
**/
@Component
public class JwtAuthenticationProvider implements AuthenticationProvider {
private final CenterUserService userDetailsService;
/**
* 用户可用性检查类
*/
private final UserDetailsChecker preAuthenticationChecks = new DefaultPreAuthenticationChecks();
public JwtAuthenticationProvider(CenterUserService centerUserService) {
this.userDetailsService = centerUserService;
}
/***
* 验证用户
*
* @param authentication
* @Return : org.springframework.security.core.Authentication
*/
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
Assert.isInstanceOf(JwtAuthencationToken.class, authentication,
"错误的凭证");
String username = (authentication.getPrincipal() == null) ? "NONE_PROVIDED"
: ((User)authentication.getPrincipal()).getUsername();
UserDetails user = retrieveUser(username);
preAuthenticationChecks.check(user);
return createSuccessAuthentication(user,authentication,user);
}
/***
* 返回True则由该对象进行用户验证
*
* @param authentication
* @Return : boolean
*/
@Override
public boolean supports(Class<?> authentication) {
return (JwtAuthencationToken.class.isAssignableFrom(authentication));
}
/***
* 通过用户名获取对应的用户
*
* @param username
* @Return : org.springframework.security.core.userdetails.UserDetails
*/
protected final UserDetails retrieveUser(String username) {
UserDetails loadedUser = userDetailsService.selectByUserName(username);
if (loadedUser == null) {
throw new InternalAuthenticationServiceException(
"UserDetailsService returned null, which is an interface contract violation");
}
return loadedUser;
}
/***
* 创建一个已经通过验证的用户实例
* 该方法由SpringSecurity源码魔改得到
* @param principal
* @param authentication
* @param user
* @Return : org.springframework.security.core.Authentication
*/
protected Authentication createSuccessAuthentication(Object principal,
Authentication authentication, UserDetails user) {
JwtAuthencationToken result = new JwtAuthencationToken(principal,
user.getAuthorities());
result.setDetails(authentication.getDetails());
return result;
}
}
package com.tykj.workflowcore.user.authencation.provider;
import com.tykj.workflowcore.user.pojo.vo.JwtSecurityProperties;
import com.tykj.workflowcore.user.util.JwtTokenUtils;
import com.tykj.workflowcore.user.util.SpringContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Slf4j
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
private final JwtTokenUtils jwtTokenUtils;
public JwtAuthenticationTokenFilter(JwtTokenUtils jwtTokenUtils) {
this.jwtTokenUtils = jwtTokenUtils;
}
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
JwtSecurityProperties jwtSecurityProperties = SpringContextHolder.getBean(JwtSecurityProperties.class);
String requestRri = request.getRequestURI();
//获取request token
String token = null;
String bearerToken = request.getHeader(jwtSecurityProperties.getHeader());
if (StringUtils.hasText(bearerToken) && bearerToken.startsWith(jwtSecurityProperties.getTokenStartWith())) {
token = bearerToken.substring(jwtSecurityProperties.getTokenStartWith().length());
}
if (StringUtils.hasText(token) && jwtTokenUtils.validateToken(token)) {
Authentication authentication = jwtTokenUtils.getAuthentication(token);
SecurityContextHolder.getContext().setAuthentication(authentication);
log.debug("set Authentication to security context for '{}', uri: {}", authentication.getName(), requestRri);
} else {
log.debug("no valid JWT token found, uri: {}", requestRri);
}
filterChain.doFilter(request, response);
}
}
\ No newline at end of file
package com.tykj.workflowcore.user.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tykj.workflowcore.user.util.HttpUtil;
import io.swagger.annotations.Api;
import liquibase.pro.packaged.J;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "同步数据")
@RestController
@RequestMapping("/syn")
public class synchronizationDataController {
@Autowired
HttpUtil httpUtil;
@GetMapping("/test")
public void test(){
CloseableHttpResponse response = httpUtil.request(HttpUtil.HttpMethodName.GET, "http://192.168.102.171:8880/organization/all", null, null);
String s = httpUtil.closeableHttpResponse2String(response);
//开始解析json
JSONObject responseJson = JSONObject.parseObject(s);
JSONArray dataArray = responseJson.getJSONArray("data");
System.out.println("s");
}
}
......@@ -22,17 +22,22 @@ public class StorageKey {
@Lob
@ApiModelProperty(value = "应用签名公钥,由系统生成。公钥发放给应用的负责人,用于对JWT验签")
private String signPublicKey ;
private String signPublicKey
= "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApAISjKVxv1SSFmORcTebj+y0aiuItJeDhyA8Vz4KUirMLb/+qR5khlGnv2bd8SCrHSZdGrAXZBj1F3pCWNPoKPOp3+e2IudEhzGq4fPgwbkD1EjmHoSsENXpzuk/OUMAIZKb2c0t+mlIrc8El6g18crWvPlv43h+wryyHxy9gMs2+Oj+MBSrPgeiX/Sj12mlBdX6bhSMWGllnRyo6ABA9D/RzypvfiMM8a8SmKzkNqYU4K4JFjAaH0pa44dMdupCExi3Feq3Q0Bg0APe4EqRy8Et4lf58hG0Khy8R0arLh69VAkFgXlrMMtW3tLTBQZVIMIPBgqt+ajeVGc2ue+DYQIDAQAB";
@Lob
@ApiModelProperty(value = "应用签名私钥,由系统生成。私钥用于对JWT进行签名")
private String signPrivateKey ;
private String signPrivateKey
= "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCkAhKMpXG/VJIWY5FxN5uP7LRqK4i0l4OHIDxXPgpSKswtv/6pHmSGUae/Zt3xIKsdJl0asBdkGPUXekJY0+go86nf57Yi50SHMarh8+DBuQPUSOYehKwQ1enO6T85QwAhkpvZzS36aUitzwSXqDXxyta8+W/jeH7CvLIfHL2Ayzb46P4wFKs+B6Jf9KPXaaUF1fpuFIxYaWWdHKjoAED0P9HPKm9+IwzxrxKYrOQ2phTgrgkWMBofSlrjh0x26kITGLcV6rdDQGDQA97gSpHLwS3iV/nyEbQqHLxHRqsuHr1UCQWBeWswy1be0tMFBlUgwg8GCq35qN5UZza574NhAgMBAAECggEBAJ8yv8y0P5CIR/Hhnmk2oBL5ojq4nU8nD24X1VqeByixEFaMWmbQ8KUNF/aLpH4NxutZtOBV866fJzEt5L8SmvU9aDTGV57TvEo65PPFZfLFY7kpNe6Du/3vlq/Y6xzrM3JjPFMTfkDm97x3Ca8ogYx95ymyOnCkIu9meMQIgs5DYsmGzTrl1YYVryJ0BeVFRBQkbfZRQ46rraYZL1flcYJBG8GcRo+kZNwKA9IHLt7khYvFpxjEF6Ppem3X3X/3CIC32q6wjeY50u8w87XGR8XVVRIqIorBpXtODjvYYqeBsofYYSZ/hh/+WFgoCoGSk+nDcaGO/hnGQ61jscUSaz0CgYEA6K/uJNb8WYYbuaJyoYb53LHcp334uLvLXW5QoZ3J/g+t/D0nvz7Pk3W81dv6NpQBCGT7qN5e0ip+an1fj5/LbljgOhW6DpYF5Ggo5Lf5AXkD8iDgTspd76AUFyaRYLJtS0+SPtPLv1tQ3ek7uXdDfopL9yjM1WnWfZe2MUtQtX8CgYEAtHCgxrFo9nAKT6ehsbpvAzNW7j/NnuMKPdvMYX4AFv1twdc+K2qor2UNkwMNnRuL5ESh+1RXH+Y1WhC+hwJYqDXsYob99qy9FkNfU2MqJgHXEbiLglR2dT0ELQ3Iql5QpJVdLqDUljrYqGDrGC3U6LQO05C7F74ouTb3LsH09x8CgYBgNe5H+USaV6M7HHo9Y6wIntpXvvSKncu2tBhO2wlcLWuJMlgu8W+uzy3nV2+cBZJvwCF2b4vRZpSiv3g10KKy27jLC5TE1y9Ug+T0vUUOYNVK1mEo8u/oVs43zFCsJNqgGySjKbvDQaSsPPXe9/tGZTSH26zmST7Q61wAAd47TQKBgDPmGThNGuWXAEA89PMLrpZ7E8vfKiNDJlT4fWalOR1js0gHwuf1+6LHLApW3HmNzMTRQM3rSkvwiPPo0QRAFoP7ToxgS3fB43kd07NGWH8qFFQSgn3wEUpTTHow9sCZ9BQCqhSZScwUDPERP01rEUwFTiZoAIgpt8jeGGaofu79AoGASFnAKGxDY41J6Wq9+BQBW0nk34TZo7Fz+cKIpQ5/zw2iVbUF3x1hCBn5CMn3mJHBCS4L7A/mTYN34VvfUDWbqxoRJAz5qNNuA5Ljko2cdZjNjZGFovfqnvo7I1zdoM5DnO1SMEgP+nxy4hzpmo990jkQcbAHaIesgT93Sl2MZo4=";
@Lob
@ApiModelProperty(value = "应用jwt加密公钥,由系统生成。用于对JWT加密")
private String rsaPublicKey ;
private String rsaPublicKey
= "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjVT15mHtFXaYc7xsTtkXJPxVlN5JhRBdP0XwNQ5m9sJdgTLyz1mesBPc3r0K7ZPphdszlSBb3OdCKFafUILS8jiBDo4DHZ2CNpyqBODgJIE46PN+DfcJWfHA4BZHiqQNL1q6SJufr2fmKm57uZGdNhdNstzWtXkt3NPyaEr4HaI8hPbntIVybJD5F6HeTuXf0inikdMwzj/sAQguJmmv23be/NrUELH4JwEm9Kse+yFzXtSi61s71XJMvizSlcRW2m9IzhVRBjVFt509b+ptTjxgrNL4QuAA8WY/B/mJZZ0mAFcAwkLCILwlfhQmPBO3Tw7mj9QeTebml2vt/fjjIwIDAQAB";
@Lob
@ApiModelProperty(value = "应用jwt解密私钥,由系统生成。私钥发放给应用的负责人,用于对JWT解密")
private String rsaPrivateKey ;
private String rsaPrivateKey
= "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCNVPXmYe0VdphzvGxO2Rck/FWU3kmFEF0/RfA1Dmb2wl2BMvLPWZ6wE9zevQrtk+mF2zOVIFvc50IoVp9QgtLyOIEOjgMdnYI2nKoE4OAkgTjo834N9wlZ8cDgFkeKpA0vWrpIm5+vZ+Yqbnu5kZ02F02y3Na1eS3c0/JoSvgdojyE9ue0hXJskPkXod5O5d/SKeKR0zDOP+wBCC4maa/bdt782tQQsfgnASb0qx77IXNe1KLrWzvVcky+LNKVxFbab0jOFVEGNUW3nT1v6m1OPGCs0vhC4ADxZj8H+YllnSYAVwDCQsIgvCV+FCY8E7dPDuaP1B5N5uaXa+39+OMjAgMBAAECggEAVYKmFPIC5A2RR9UlIr+uhS43CY9EpEG2aWYDY9aG7Z3DvTv6NQJgROB/rjRqvDvV+qsZloyxiAJTwNxIIApHX05Yp1m9ANofwrMfGzyD4RJeQHOyPPjOq6DdtbdFKdkAMTqPowaloxcV525ZZXl4yRVoaWO8dKgQ259Q91EEtchf+v3FSlrAuH9K6RLRnpNqO9ryNlIES6nipKjqUu2p2f65f94s8eQtAt/JDGq16+xs8lDxRLahpFJSYdMFBS5wzLQGAJ7MiVD6VDNBkFM8dDEdaqRuVO3xBcRLx4EM0FFN5TmzC7d8hfNX771vM7iEZlcT6xfTWIeFdfD0Yhz5QQKBgQDQaSrNlnLZlSgS90TGmsgRfpmCsX5J6nRFZ4an+Zg3EnRsTVSkSHxLWGmml4Jxa92OL2gaMOdhUuPtd34B8brgFwoae0sAHBGfMoK1khWJV9t4Uh4uLRivH7nBm4+mwj0QKq5VW0ABrS+gPf4+XyPT0/86Ilm7863++/Uh8A1bSQKBgQCtmqMDXXjRK36sRtto1fCowZhkhD1IAW2btgTtN26pXRWjlLHGAPcOqa7mKdjJgsA8RjBqvDWTNv5N/5q0fZZm9s6N0aLL/ofuEo+bwRVlPpL/QysCKuAmfLO8l4kUV4O8IRHMz3SIooz5Ia5bCJvAQ2L4KEugM0KaGRXjTXc/CwKBgEYizkPHmLj+iDDxw9RubFvu1ex0nQJ1A1IEB/3pcj8+V63GzHBI8INOqqdkn4JaAYKDE66UvJk1Ev1sVByFZBVby4uj6FaOG6QOlIxUMCk7RuGUCRITHRZ6P8IW/t3oyjHxmx+giMbHqJptom0NCXqVAnRm8PnehLSlyBX2uhf5AoGAQvMRzqhrgW8eqN2im+l1p/8RACKnZ291j8lAWSM5gAMv5yfe7xdML9Fsa8LTodLUw+nlniP7HUzmAbqDNPwB1q9ztOmVuMnuLffmfhCWabcaBWsn2OwkCXOp9R8TdE7TtOej77JJpK/bYfCFRwIo3pqePkl78MoT802dTU2AoUUCgYAj0YsmkhgwPCgW15uFVpS8AFyBmbBopM9JuBf7hLYKTeMNgYghiL+ziYPrX9pFvcCV4OGkUnUf+HicF0KmL4Hj+w5kfmsx7+vtInKSoQnBEC2mbitxzGBtsIFVGYdaBqo6bfTYoWs4sy0TU8cfkJQKqVgodLJFkU1hMoQYDuQVgw==";
}
......@@ -43,7 +43,7 @@ public class User {
private Integer locked = 0;
@ApiModelProperty(value = "用户的性别")
private char sex ;
private String sex ;
@ApiModelProperty(value = "身份证号")
private String idCardNumber;
......
package com.tykj.workflowcore.workflow_editer.controller;
import com.tykj.workflowcore.base.result.ResultUtil;
import com.tykj.workflowcore.user.pojo.UserDetail;
import com.tykj.workflowcore.user.util.AuthenticationUtils;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowRole;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowRoleType;
import com.tykj.workflowcore.workflow_editer.entity.WorkFlowUser;
......@@ -7,6 +10,7 @@ import com.tykj.workflowcore.workflow_editer.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -29,6 +33,9 @@ public class UserController {
@Autowired
private UserService userService;
@Autowired
AuthenticationUtils authenticationUtils;
@GetMapping("/getAllUsers")
@ApiOperation(value = "查询所有用户")
public List<WorkFlowUser> getAllUsers(){
......@@ -49,4 +56,11 @@ public class UserController {
List<WorkFlowRole> allRole = userService.getAllRole(roleType);
return allRole;
}
@GetMapping("/getCurrentUser")
@ApiOperation(value = "查询当前登录用户")
public ResponseEntity getCurrentUser(String roleType){
UserDetail authentication = authenticationUtils.getAuthentication();
return ResultUtil.success(authentication,"查询成功");
}
}
......@@ -23,6 +23,15 @@ spring:
physical-strategy: com.tykj.workflow2.base.config.ToUpperCase
ddl-auto: update
database-platform: org.hibernate.dialect.MySQL8Dialect
application:
name: test
server:
port: 8088
\ No newline at end of file
port: 8088
eureka:
instance:
prefer-ip-address: true
lease-expiration-duration-in-seconds: 3
lease-renewal-interval-in-seconds: 7
client:
service-url:
defaultZone: http://192.168.100.248:1111/eureka/
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论