diff --git a/common/src/main/java/org/apache/seata/common/ConfigurationKeys.java b/common/src/main/java/org/apache/seata/common/ConfigurationKeys.java index ff8436b6dc9..a46c31358ef 100644 --- a/common/src/main/java/org/apache/seata/common/ConfigurationKeys.java +++ b/common/src/main/java/org/apache/seata/common/ConfigurationKeys.java @@ -68,6 +68,11 @@ public interface ConfigurationKeys { */ String SEATA_PREFIX = SEATA_FILE_ROOT_CONFIG + "."; + /** + * The constant SECURITY_PREFIX + */ + String SECURITY_PREFIX = "security."; + /** * The constant SERVICE_PREFIX. */ @@ -1014,6 +1019,31 @@ public interface ConfigurationKeys { */ String SERVER_APPLICATION_DATA_SIZE_CHECK = SERVER_PREFIX + "applicationDataLimitCheck"; + /** + * The constant SECURITY_USERNAME; + */ + String SECURITY_USERNME = SECURITY_PREFIX + "username"; + + /** + * The constant SECURITY_PASSWORD; + */ + String SECURITY_PASSWORD = SECURITY_PREFIX + "password"; + + /** + * The constant SECURITY_SECRET_KEY; + */ + String SECURITY_SECRET_KEY = SECURITY_PREFIX + "secretKey"; + + /** + * The constant SECURITY_ACCESS_TOKEN_VALID_TIME; + */ + String SECURITY_ACCESS_TOKEN_VALID_TIME = SECURITY_PREFIX + "accessTokenValidityInMilliseconds"; + + /** + * The constant SECURITY_REFRESH_TOKEN_VALID_TIME; + */ + String SECURITY_REFRESH_TOKEN_VALID_TIME = SECURITY_PREFIX + "refreshTokenValidityInMilliseconds"; + /** * The constant ROCKET_MQ_MSG_TIMEOUT */ diff --git a/common/src/main/java/org/apache/seata/common/result/Code.java b/common/src/main/java/org/apache/seata/common/result/Code.java index 18756e3f0b0..abce5fc4271 100644 --- a/common/src/main/java/org/apache/seata/common/result/Code.java +++ b/common/src/main/java/org/apache/seata/common/result/Code.java @@ -16,12 +16,19 @@ */ package org.apache.seata.common.result; - +/** + * The Code for the response of message + * + */ public enum Code { /** * response success */ SUCCESS("200", "ok"), + /** + * the custom error + */ + ACCESS_TOKEN_NEAR_EXPIRATION("200", "Access token is near expiration"), /** * server error */ @@ -29,17 +36,29 @@ public enum Code { /** * the custom error */ - LOGIN_FAILED("401", "Login failed"); + LOGIN_FAILED("401", "Login failed"), + /** + * the custom error + */ + CHECK_TOKEN_FAILED("401", "Check token failed"), + /** + * the custom error + */ + ACCESS_TOKEN_EXPIRED("401", "Access token expired"), + /** + * the custom error + */ + REFRESH_TOKEN_EXPIRED("401", "Refresh token expired"); /** * The Code. */ - public String code; + private String code; /** * The Msg. */ - public String msg; + private String msg; private Code(String code, String msg) { this.code = code; @@ -98,4 +117,3 @@ public static String getErrorMsg(String code) { return null; } } - diff --git a/common/src/main/java/org/apache/seata/common/result/SingleResult.java b/common/src/main/java/org/apache/seata/common/result/SingleResult.java index 97394053fab..82218984aa0 100644 --- a/common/src/main/java/org/apache/seata/common/result/SingleResult.java +++ b/common/src/main/java/org/apache/seata/common/result/SingleResult.java @@ -18,11 +18,10 @@ import java.io.Serializable; - /** * The single result */ -public class SingleResult extends Result implements Serializable { +public class SingleResult extends Result implements Serializable { private static final long serialVersionUID = 77612626624298767L; /** @@ -33,22 +32,18 @@ public class SingleResult extends Result implements Serializable { public SingleResult(String code, String message) { super(code, message); } + public SingleResult(Code code) { + super(code.getCode(), code.getMsg()); + } public SingleResult(String code, String message, T data) { super(code, message); this.data = data; } - public static SingleResult failure(String code, String msg) { - return new SingleResult<>(code, msg); - } - - public static SingleResult failure(Code errorCode) { - return new SingleResult(errorCode.getCode(), errorCode.getMsg()); - } - - public static SingleResult success(T data) { - return new SingleResult<>(SUCCESS_CODE, SUCCESS_MSG,data); + public SingleResult(Code code, T data) { + super(code.getCode(), code.getMsg()); + this.data = data; } public T getData() { diff --git a/console/pom.xml b/console/pom.xml index 16fba6a55ee..7e168de9502 100644 --- a/console/pom.xml +++ b/console/pom.xml @@ -142,6 +142,19 @@ javax.servlet javax.servlet-api + + + + io.springfox + springfox-swagger2 + 2.7.0 + + + io.springfox + springfox-swagger-ui + 2.7.0 + +