diff --git a/src/main/java/com/xit/biz/cmm/entity/AddressType.java b/src/main/java/com/xit/biz/cmm/entity/AddressType.java new file mode 100644 index 0000000..edd0351 --- /dev/null +++ b/src/main/java/com/xit/biz/cmm/entity/AddressType.java @@ -0,0 +1,44 @@ +package com.xit.biz.cmm.entity; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.AllArgsConstructor; + +import java.util.Map; +import java.util.Objects; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toMap; + +@AllArgsConstructor +public enum AddressType { + STREET("STREET"), // 도로명 + LOT("LOT"); + // 지번 + private final String code; + + /** + * Serialization을 위해 반드시 필요 + * 미정의시 JSON parser 에러 발생 - throw HttpMessageNotReadableException + * @param symbol String + * @return RoleType + */ + @JsonCreator + public static AddressType fromString(String symbol){ + return stringToEnum.get(symbol); + } + + /** + * Deserialization을 위해 반드시 필요 + * 미정의시 JSON parser 에러 발생 - throw HttpMessageNotReadableException + * @return String + */ + @JsonValue + public String getCode(){ + return code; + } + + private static final Map stringToEnum = Stream.of(values()) + .collect(toMap(Objects::toString, e -> e)); + +} \ No newline at end of file diff --git a/src/main/java/com/xit/biz/cmm/entity/CmmAddress.java b/src/main/java/com/xit/biz/cmm/entity/CmmAddress.java index 858baae..0b7b185 100644 --- a/src/main/java/com/xit/biz/cmm/entity/CmmAddress.java +++ b/src/main/java/com/xit/biz/cmm/entity/CmmAddress.java @@ -2,7 +2,10 @@ package com.xit.biz.cmm.entity; import com.xit.biz.cmm.entity.ids.CmmAddressIds; import com.xit.core.constant.XitConstants; +import com.xit.core.oauth2.oauth.entity.ProviderType; import com.xit.core.support.jpa.AuditEntity; +import com.xit.core.support.valid.EnumNamePattern; +import com.xit.core.support.valid.Enums; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import org.hibernate.Hibernate; @@ -42,7 +45,8 @@ public class CmmAddress extends AuditEntity implements Serializable { @Schema(required = true, title = "주소 구분", example = "STREET", description = "지번 / 도로명") @Column(nullable = false, length = 10) @Enumerated(EnumType.STRING) - private XitConstants.AddressType addressType; + @EnumNamePattern(regexp = "STREET|LOT", message = "{auth.user.address.pattern.AddressType}") + private AddressType addressType; @Schema(required = true, title = "우편번호", example = "03001", description = "우편번호") @Column(nullable = false, length = 6) diff --git a/src/main/java/com/xit/biz/sample/ignore/FluxCmmUserController.java b/src/main/java/com/xit/biz/sample/_ignore/FluxCmmUserController.java similarity index 100% rename from src/main/java/com/xit/biz/sample/ignore/FluxCmmUserController.java rename to src/main/java/com/xit/biz/sample/_ignore/FluxCmmUserController.java diff --git a/src/main/java/com/xit/biz/sample/ignore/FluxSampleController.java b/src/main/java/com/xit/biz/sample/_ignore/FluxSampleController.java similarity index 97% rename from src/main/java/com/xit/biz/sample/ignore/FluxSampleController.java rename to src/main/java/com/xit/biz/sample/_ignore/FluxSampleController.java index dea0bc3..7bdfcfa 100644 --- a/src/main/java/com/xit/biz/sample/ignore/FluxSampleController.java +++ b/src/main/java/com/xit/biz/sample/_ignore/FluxSampleController.java @@ -1,4 +1,4 @@ -package com.xit.biz.sample.ignore; +package com.xit.biz.sample._ignore; import com.xit.biz.sample.Greeting; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/xit/biz/sample/dto/DefaultDto.java b/src/main/java/com/xit/biz/sample/dto/DefaultDto.java deleted file mode 100644 index 6c1e8a2..0000000 --- a/src/main/java/com/xit/biz/sample/dto/DefaultDto.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.xit.biz.sample.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.util.List; - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -public class DefaultDto { - private String msg; - private boolean result; - private List stringFlux; -} diff --git a/src/main/java/com/xit/biz/sample/dto/PersonDto.java b/src/main/java/com/xit/biz/sample/dto/PersonDto.java deleted file mode 100644 index 6be9a3b..0000000 --- a/src/main/java/com/xit/biz/sample/dto/PersonDto.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.xit.biz.sample.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Setter -@AllArgsConstructor -public class PersonDto { - String name; - int age; -} \ No newline at end of file diff --git a/src/main/java/com/xit/core/annotation/Permission.java b/src/main/java/com/xit/core/annotation/Permission.java index 0bdb297..bb82b31 100644 --- a/src/main/java/com/xit/core/annotation/Permission.java +++ b/src/main/java/com/xit/core/annotation/Permission.java @@ -5,6 +5,9 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * 권한 타입 체크 annotation + */ @Retention(value = RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE, ElementType.METHOD }) public @interface Permission { diff --git a/src/main/java/com/xit/core/annotation/Secured.java b/src/main/java/com/xit/core/annotation/Secured.java index 0f2958f..763283c 100644 --- a/src/main/java/com/xit/core/annotation/Secured.java +++ b/src/main/java/com/xit/core/annotation/Secured.java @@ -5,6 +5,9 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * 인증 타입 정의 annotation + */ @Retention(value = RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE, ElementType.METHOD }) public @interface Secured { diff --git a/src/main/java/com/xit/core/oauth2/config/security/SecurityConfig.java b/src/main/java/com/xit/core/config/SecurityConfig.java similarity index 97% rename from src/main/java/com/xit/core/oauth2/config/security/SecurityConfig.java rename to src/main/java/com/xit/core/config/SecurityConfig.java index 691accf..c82cd1d 100644 --- a/src/main/java/com/xit/core/oauth2/config/security/SecurityConfig.java +++ b/src/main/java/com/xit/core/config/SecurityConfig.java @@ -1,18 +1,17 @@ -package com.xit.core.oauth2.config.security; +package com.xit.core.config; import com.xit.core.oauth2.api.repository.RefreshTokenRepository; import com.xit.core.oauth2.config.properties.AppProperties; import com.xit.core.oauth2.config.properties.CorsProperties; -import com.xit.core.oauth2.oauth.entity.RoleType; import com.xit.core.oauth2.oauth.exception.RestAuthenticationEntryPoint; -import com.xit.core.oauth2.oauth.filter.TokenAuthenticationFilter; +import com.xit.core.oauth2.oauth.TokenAuthenticationFilter; import com.xit.core.oauth2.oauth.handler.OAuth2AuthenticationFailureHandler; import com.xit.core.oauth2.oauth.handler.OAuth2AuthenticationSuccessHandler; import com.xit.core.oauth2.oauth.handler.TokenAccessDeniedHandler; import com.xit.core.oauth2.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; import com.xit.core.oauth2.oauth.service.CustomOAuth2UserService; import com.xit.core.oauth2.oauth.service.CustomUserDetailsService; -import com.xit.core.oauth2.oauth.token.JwtTokenProvider; +import com.xit.core.oauth2.oauth.JwtTokenProvider; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -26,7 +25,6 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; -import org.springframework.security.web.util.matcher.AntPathRequestMatcher; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsUtils; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; @@ -34,6 +32,7 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import java.util.Arrays; /** + *
  * WebSecurityConfigurerAdapter 상속 Override
  *
  * 1. configure( WebSecurity) : 서비스 전체에 영향을 미치는 설정
@@ -64,6 +63,7 @@ import java.util.Arrays;
  *                      LogoutSuccessfulUrl()
  *   - ExceptionHandlingConfigurer : 에러에 대한 리다이렉트 url 을 설정
  *   - OAuth2LoginConfigurer : 소셜 로그인 기능을 활성화
+ *   
*/ @Configuration @RequiredArgsConstructor diff --git a/src/main/java/com/xit/core/config/WebCommonConfig.java b/src/main/java/com/xit/core/config/WebCommonConfig.java index 46d95c5..89ac4f2 100644 --- a/src/main/java/com/xit/core/config/WebCommonConfig.java +++ b/src/main/java/com/xit/core/config/WebCommonConfig.java @@ -1,7 +1,7 @@ package com.xit.core.config; import com.xit.core.constant.XitConstants; -import com.xit.core.oauth2.oauth.interceptor.AuthInterceptor; +import com.xit.core.oauth2.oauth.AuthInterceptor; import com.xit.core.support.RestTemplateLoggingRequestInterceptor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; diff --git a/src/main/java/com/xit/core/constant/XitConstants.java b/src/main/java/com/xit/core/constant/XitConstants.java index 4fe039f..d783b77 100644 --- a/src/main/java/com/xit/core/constant/XitConstants.java +++ b/src/main/java/com/xit/core/constant/XitConstants.java @@ -1,17 +1,21 @@ package com.xit.core.constant; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.xit.core.support.mybatis.paging.domain.PageList; +import com.xit.core.support.mybatis.paging.domain.Paginator; +import org.apache.ibatis.plugin.Invocation; + import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; public class XitConstants { - public static final String JPA_VERSION = "2.4"; - public static final String UNIT_NAME = "jpaPersistenceUnit"; - // RestTemplate 상수 - public static final int CONNECT_TIMEOUT = 30 * 1000; // 30초 - public static final int READ_TIMEOUT = 60 * 1000 * 3; // 3분 - public static final Charset CHARSET = StandardCharsets.UTF_8; + public static final int CONNECT_TIMEOUT = 30 * 1000; // 30초 + public static final int READ_TIMEOUT = 60 * 1000 * 3; // 3분 + public static final Charset CHARSET = StandardCharsets.UTF_8; + public static final String DEFAULT_VIEW = ViewName.JSON_VIEW.getValue(); /** * CustomCommonsRequestLoggingFilter에서 로깅을 제외할 url 패턴 정의 @@ -79,135 +83,7 @@ public class XitConstants { DTO } - public enum AddressType { - STREET("STREET"), // 도로명 - LOT("LOT"); // 지번 - private final String value; - public String getValue() { - return this.value; - } - private AddressType(String value) { - this.value = value; - } - - } - - - - - - - - - - - - - - - - - - - - - - - /** - * spring.profiles.active 에 따라 log / cache / db 결정 - * local / dev / qa / product - * local - jdbc, 그외는 jndi - */ - public static final String KEY_OP_MODE = "spring.profiles.active"; - public static final String OP_MODE_DEFAULT = "local"; - - public static final String DEFAULT_VIEW = ViewName.JSON_VIEW.getValue(); - public static final int BIZ_EXCEPTION_CODE = 999; - public static final String BIZ_EXCEPTION_CODE_STR = "999"; - public static final String SESSION_TIMEOUT_MSG_CODE = "cmm.info.session.timeout"; - public static final String PROP_LOCALE = "Config.locale"; - public static final String DEFAULT_ENCODING = "UTF-8"; - - /** - * login ID 저장 여부 파라메터 : 이 값에 저장여부가 넘어온다 - * html check field name을 이값으로 할것 - */ - public static final String COOKIE_SAVE_CHECK_FIELD = "isIdSave"; - /** - * login ID 저장 여부 체크시 true 값이 넘어 온다 : html 에서 넘어오는 값이라서 문자열로 - */ - public static final String COOKIE_SAVE_NAME_TRUE = "true"; - /** - * Cookie에 저장될 key 값 - */ - public static final String COOKIE_SAVE_USER_NAME = "SAVE_USER_NAME"; - /** - * 로그인 실패시 실패한 ID를 임시로 저장하기 위한 attribute key 값 - */ - public static final String TMP_USER_ID = "tmpUserId"; - - public static final String USER_ID = "j_username"; - - /** - * return list root attribute name - */ - public static final String RSLT_ATTR_NAME = "_item_"; - - public enum Cache { - Monitoring("Config.cache.monitoring"), - Statistics("Config.cache.statistics"), - Logging("Config.cache.logging"), - UpdateCheck("Config.cache.updateCheck"), - DynamicConfig("Config.cache.dynamicConfig"), - EvictionPolicy("Config.cache.evictionPolicy"), - CodeCacheName("Config.cache.codeCache.name"), - CodeCacheMaxEntries("Config.cache.codeCache.maxEntries"), - MenuCacheName("Config.cache.menuCache.name"), - MenuCacheMaxEntries("Config.cache.menuCache.maxEntries") - ; - - private String value; - private Cache(String value) { - this.value = value; - } - public String getValue() { - return this.value; - } - - } - - public enum LoginException{ - ACCOUNT_EXISTS("Account exists"), - PWD_MISMATCH("PasswordMismatchException"), - ACCOUNT_EXPIRED("UserAccountExpiredException"), - ACCOUNT_LOCK("UserAccountLockException"), - USER_NOT_FOUND("UserNotFoundException"), - LOGIN_DUPLICATED("principal exceeded") // Maximum sessions of 1 for this principal exceeded - ; - private String value; - private LoginException(String value) { - this.value = value; - } - public String getValue() { - return this.value; - } - } - - public enum ErrorMsgLayout{ - ROOT_ATTR("error"), - CODE_ATTR("code"), - MSG_ATTR("messages") - ; - private String value; - private ErrorMsgLayout(String value) { - this.value = value; - } - public String getValue() { - return this.value; - } - } - - public enum ViewName{ + public enum ViewName{ JSON_VIEW("mappingJackson2JsonView") ; private String value; @@ -218,52 +94,19 @@ public class XitConstants { return this.value; } } - - public enum ComboList{ - CODE_LIST("code_list"), - CODE("code"), - VALUE("value"); - private String value; - private ComboList(String value) { - this.value = value; - } - public String getValue() { - return this.value; - } - } - - public enum JspViewLayout{ - PREFIX("/WEB-INF/views/"), - SUFFIX(".jsp"); - private String value; - private JspViewLayout(String value) { - this.value = value; - } - public String getValue() { - return this.value; - } - } - - public enum Const { - VALID_ERROR_ROOT_ELEMENT("validError"), - MESSAGE_CODE_ATTR("code"), - MESSAGE_ATTR("messages"), - ERROR_ROOT_ELEMENT("error"), - VALID_ERROR_FIELD("field"), - CURRENT_LOCALE("currentLocale"), - DEFAULT_SUCCESS_MSG_CODE("cmm.info.success"), - DEFAULT_FAIL_MSG_CODE("cmm.info.success"), - VALID_ERROR_MSG("cmm.error.valid") - ; - private String value; - private Const(String value) { - this.value = value; - } - public String getValue() { - return this.value; - } - } + /** + * mybatis paging 처리시 return list root attribute name + * @see com.xit.core.support.mybatis.paging.jackson2.PageListJsonSerializer#serialize(PageList, JsonGenerator, SerializerProvider) + */ + public static final String RSLT_ATTR_NAME = "_item_"; + + /** + * Maybatis / jpa 페이지 정보 저장 + * @see com.xit.core.support.mybatis.paging.OffsetLimitInterceptor#intercept(Invocation) + * @see com.xit.core.support.mybatis.paging.domain.Paginator#setSessionPagination(Paginator) + * @see com.xit.core.support.jpa.Paginator#setSessionPagination(com.xit.core.support.jpa.Paginator) + */ public enum Session { PAGE_INFO("_pageInfo_"), // DATASET_NAME("gds_pageInfo"), diff --git a/src/main/java/com/xit/core/oauth2/api/controller/OAuth2LocalController.java b/src/main/java/com/xit/core/oauth2/api/controller/OAuth2LocalController.java index 48d9b75..908c630 100644 --- a/src/main/java/com/xit/core/oauth2/api/controller/OAuth2LocalController.java +++ b/src/main/java/com/xit/core/oauth2/api/controller/OAuth2LocalController.java @@ -5,10 +5,8 @@ import com.xit.core.api.RestResponse; import com.xit.core.oauth2.api.dto.LoginRequestDto; import com.xit.core.oauth2.api.dto.TokenRequestDto; import com.xit.core.oauth2.api.service.IAuthService; -import com.xit.core.oauth2.oauth.token.JwtTokenProvider; -import com.xit.core.support.jpa.EnumFindUtils; -import com.xit.core.util.Checks; -import com.xit.core.util.AssertUtils; +import com.xit.core.oauth2.oauth.JwtTokenProvider; +//import com.xit.core.support.jpa.EnumFindUtils; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; diff --git a/src/main/java/com/xit/core/oauth2/api/controller/UserController.java b/src/main/java/com/xit/core/oauth2/api/controller/UserController.java index 1185d80..0fe28ea 100644 --- a/src/main/java/com/xit/core/oauth2/api/controller/UserController.java +++ b/src/main/java/com/xit/core/oauth2/api/controller/UserController.java @@ -9,7 +9,7 @@ import com.xit.core.api.RestResponse; import com.xit.core.oauth2.api.service.IAuthService; import com.xit.core.oauth2.api.service.IUserService; import com.xit.core.oauth2.oauth.entity.RoleType; -import com.xit.core.oauth2.oauth.token.JwtTokenProvider; +import com.xit.core.oauth2.oauth.JwtTokenProvider; import com.xit.core.oauth2.utils.HeaderUtil; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; diff --git a/src/main/java/com/xit/core/oauth2/api/service/impl/AuthService.java b/src/main/java/com/xit/core/oauth2/api/service/impl/AuthService.java index 93c5da1..fd79d5a 100644 --- a/src/main/java/com/xit/core/oauth2/api/service/impl/AuthService.java +++ b/src/main/java/com/xit/core/oauth2/api/service/impl/AuthService.java @@ -12,7 +12,7 @@ import com.xit.core.oauth2.api.dto.TokenDto; import com.xit.core.oauth2.api.dto.TokenRequestDto; import com.xit.core.oauth2.api.service.IAuthService; import com.xit.core.oauth2.config.properties.AppProperties; -import com.xit.core.oauth2.oauth.token.JwtTokenProvider; +import com.xit.core.oauth2.oauth.JwtTokenProvider; import com.xit.core.oauth2.utils.CookieUtil; import com.xit.core.oauth2.utils.HeaderUtil; import com.xit.core.util.Checks; diff --git a/src/main/java/com/xit/core/oauth2/config/security/JwtConfig.java b/src/main/java/com/xit/core/oauth2/config/security/JwtConfig.java deleted file mode 100644 index 6ca9625..0000000 --- a/src/main/java/com/xit/core/oauth2/config/security/JwtConfig.java +++ /dev/null @@ -1,16 +0,0 @@ -//package com.xit.core.oauth2.config.security; -// -//import com.xit.core.oauth2.oauth.token.JwtTokenProvider; -//import org.springframework.beans.factory.annotation.Value; -//import org.springframework.context.annotation.Bean; -// -////@Configuration -//public class JwtConfig { -// @Value("${jwt.secret}") -// private String secret; -// -// @Bean -// public JwtTokenProvider jwtProvider() { -// return new JwtTokenProvider(secret); -// } -//} diff --git a/src/main/java/com/xit/core/oauth2/oauth/interceptor/AuthInterceptor.java b/src/main/java/com/xit/core/oauth2/oauth/AuthInterceptor.java similarity index 98% rename from src/main/java/com/xit/core/oauth2/oauth/interceptor/AuthInterceptor.java rename to src/main/java/com/xit/core/oauth2/oauth/AuthInterceptor.java index 40acb5e..3b538ee 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/interceptor/AuthInterceptor.java +++ b/src/main/java/com/xit/core/oauth2/oauth/AuthInterceptor.java @@ -1,4 +1,4 @@ -package com.xit.core.oauth2.oauth.interceptor; +package com.xit.core.oauth2.oauth; import com.xit.core.annotation.Secured; import com.xit.core.annotation.SecurityPolicy; diff --git a/src/main/java/com/xit/core/oauth2/oauth/token/JwtTokenProvider.java b/src/main/java/com/xit/core/oauth2/oauth/JwtTokenProvider.java similarity index 99% rename from src/main/java/com/xit/core/oauth2/oauth/token/JwtTokenProvider.java rename to src/main/java/com/xit/core/oauth2/oauth/JwtTokenProvider.java index c0b68ca..7068ee6 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/token/JwtTokenProvider.java +++ b/src/main/java/com/xit/core/oauth2/oauth/JwtTokenProvider.java @@ -1,4 +1,4 @@ -package com.xit.core.oauth2.oauth.token; +package com.xit.core.oauth2.oauth; import com.xit.core.constant.ErrorCode; import com.xit.core.constant.XitConstants; diff --git a/src/main/java/com/xit/core/oauth2/oauth/filter/TokenAuthenticationFilter.java b/src/main/java/com/xit/core/oauth2/oauth/TokenAuthenticationFilter.java similarity index 93% rename from src/main/java/com/xit/core/oauth2/oauth/filter/TokenAuthenticationFilter.java rename to src/main/java/com/xit/core/oauth2/oauth/TokenAuthenticationFilter.java index bb76fa7..9765db5 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/filter/TokenAuthenticationFilter.java +++ b/src/main/java/com/xit/core/oauth2/oauth/TokenAuthenticationFilter.java @@ -1,7 +1,7 @@ -package com.xit.core.oauth2.oauth.filter; +package com.xit.core.oauth2.oauth; //import com.xit.core.oauth2.oauth.token.JwtToken; -import com.xit.core.oauth2.oauth.token.JwtTokenProvider; +import com.xit.core.oauth2.oauth.JwtTokenProvider; import com.xit.core.oauth2.utils.HeaderUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/xit/core/oauth2/oauth/exception/TokenValidFailedException.java b/src/main/java/com/xit/core/oauth2/oauth/exception/TokenValidFailedException.java index 084cb3d..102503c 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/exception/TokenValidFailedException.java +++ b/src/main/java/com/xit/core/oauth2/oauth/exception/TokenValidFailedException.java @@ -1,12 +1,12 @@ -package com.xit.core.oauth2.oauth.exception; - -public class TokenValidFailedException extends RuntimeException { - - public TokenValidFailedException() { - super("Failed to generate Token."); - } - - private TokenValidFailedException(String message) { - super(message); - } -} +//package com.xit.core.oauth2.oauth.exception; +// +//public class TokenValidFailedException extends RuntimeException { +// +// public TokenValidFailedException() { +// super("Failed to generate Token."); +// } +// +// private TokenValidFailedException(String message) { +// super(message); +// } +//} diff --git a/src/main/java/com/xit/core/oauth2/oauth/handler/OAuth2AuthenticationSuccessHandler.java b/src/main/java/com/xit/core/oauth2/oauth/handler/OAuth2AuthenticationSuccessHandler.java index a1c6bfa..99a1035 100644 --- a/src/main/java/com/xit/core/oauth2/oauth/handler/OAuth2AuthenticationSuccessHandler.java +++ b/src/main/java/com/xit/core/oauth2/oauth/handler/OAuth2AuthenticationSuccessHandler.java @@ -9,7 +9,7 @@ import com.xit.core.oauth2.oauth.entity.RoleType; import com.xit.core.oauth2.oauth.info.OAuth2UserInfo; import com.xit.core.oauth2.oauth.info.OAuth2UserInfoFactory; import com.xit.core.oauth2.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; -import com.xit.core.oauth2.oauth.token.JwtTokenProvider; +import com.xit.core.oauth2.oauth.JwtTokenProvider; import com.xit.core.oauth2.utils.CookieUtil; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; diff --git a/src/main/java/com/xit/core/oauth2/oauth/token/JwtToken.java b/src/main/java/com/xit/core/oauth2/oauth/token/JwtToken.java deleted file mode 100644 index f59afe5..0000000 --- a/src/main/java/com/xit/core/oauth2/oauth/token/JwtToken.java +++ /dev/null @@ -1,92 +0,0 @@ -//package com.xit.core.oauth2.oauth.token; -// -//import com.xit.core.constant.XitConstants; -//import io.jsonwebtoken.*; -//import lombok.Getter; -//import lombok.RequiredArgsConstructor; -//import lombok.extern.slf4j.Slf4j; -// -//import java.security.Key; -//import java.util.Date; -// -///** -// * Token -// * SignatureAlgorithm.HS256 -// * -// * -// * @see JwtTokenProvider -// */ -//@Slf4j -//@RequiredArgsConstructor -//public class JwtToken { -// -// @Getter -// private final String token; -// private final Key key; -// -// JwtToken(String id, Date expiry, Key key) { -// this.key = key; -// this.token = generateJwtRefreshToken(id, expiry); -// } -// -// JwtToken(String id, String role, Date expiry, Key key) { -// this.key = key; -// this.token = generateJwtAccessToken(id, role, expiry); -// } -// -// private String generateJwtRefreshToken(String id, Date expiry) { -// return Jwts.builder() -// .setSubject(id) -// .signWith(key, SignatureAlgorithm.HS256) -// .setExpiration(expiry) -// .compact(); -// } -// -// private String generateJwtAccessToken(String id, String role, Date expiry) { -// return Jwts.builder() -// .claim(XitConstants.JwtToken.AUTHORITIES_KEY.getValue(), role) -// .setSubject(id) -// .signWith(key, SignatureAlgorithm.HS256) -// .setExpiration(expiry) -// .compact(); -// } -// -// public boolean validate() { -// return this.getTokenClaims() != null; -// } -// -// public Claims getTokenClaims() { -// try { -// return Jwts.parserBuilder() -// .setSigningKey(key) -// .build() -// .parseClaimsJws(token) -// .getBody(); -// } catch (SecurityException e) { -// log.info("Invalid JWT signature."); -// } catch (MalformedJwtException e) { -// log.info("Invalid JWT token."); -// } catch (ExpiredJwtException e) { -// log.info("Expired JWT token."); -// } catch (UnsupportedJwtException e) { -// log.info("Unsupported JWT token."); -// } catch (IllegalArgumentException e) { -// log.info("JWT token compact of handler are invalid."); -// } -// return null; -// } -// -// public Claims getExpiredTokenClaims() { -// try { -// Jwts.parserBuilder() -// .setSigningKey(key) -// .build() -// .parseClaimsJws(token) -// .getBody(); -// } catch (ExpiredJwtException e) { -// log.info("Expired JWT token."); -// return e.getClaims(); -// } -// return null; -// } -//} diff --git a/src/main/java/com/xit/core/oauth2/utils/HeaderUtil.java b/src/main/java/com/xit/core/oauth2/utils/HeaderUtil.java index 0adf6f7..c5817e1 100644 --- a/src/main/java/com/xit/core/oauth2/utils/HeaderUtil.java +++ b/src/main/java/com/xit/core/oauth2/utils/HeaderUtil.java @@ -4,7 +4,7 @@ import com.xit.core.constant.XitConstants; import com.xit.core.constant.ErrorCode; import com.xit.core.exception.TokenAuthException; //import com.xit.core.oauth2.oauth.token.JwtToken; -import com.xit.core.oauth2.oauth.token.JwtTokenProvider; +import com.xit.core.oauth2.oauth.JwtTokenProvider; import com.xit.core.util.Checks; import com.xit.core.util.SpringUtils; import org.springframework.web.context.request.RequestContextHolder; diff --git a/src/main/java/com/xit/core/oauth2/utils/SecurityUtil.java b/src/main/java/com/xit/core/oauth2/utils/SecurityUtil.java index 31f7f1e..67251c6 100644 --- a/src/main/java/com/xit/core/oauth2/utils/SecurityUtil.java +++ b/src/main/java/com/xit/core/oauth2/utils/SecurityUtil.java @@ -4,6 +4,7 @@ import com.xit.core.constant.ErrorCode; import com.xit.core.constant.XitConstants.AuthSaveType; import com.xit.core.exception.UserAuthException; import com.xit.core.oauth2.api.controller.OAuth2LocalController; +import com.xit.core.oauth2.oauth.JwtTokenProvider; import com.xit.core.util.Checks; import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.Authentication; @@ -21,7 +22,7 @@ import java.util.Objects; /** * JwtFilter에서 저장한 유저정보(토큰)에서 사용자 ID를 GET * - * @see com.xit.biz.auth.jwt.JwtFilter + * @see JwtTokenProvider */ @Slf4j public class SecurityUtil { diff --git a/src/main/java/com/xit/core/support/CamelCaseLinkedMap.java b/src/main/java/com/xit/core/support/CamelCaseLinkedMap.java index 113b240..614b9c1 100644 --- a/src/main/java/com/xit/core/support/CamelCaseLinkedMap.java +++ b/src/main/java/com/xit/core/support/CamelCaseLinkedMap.java @@ -3,8 +3,9 @@ package com.xit.core.support; import org.springframework.jdbc.support.JdbcUtils; import java.util.LinkedHashMap; +import java.util.Map; -public class CamelCaseLinkedMap extends LinkedHashMap{ +public class CamelCaseLinkedMap extends LinkedHashMap { @Override public Object put(Object key, Object value){ diff --git a/src/main/java/com/xit/core/support/CamelCaseMap.java b/src/main/java/com/xit/core/support/CamelCaseMap.java index 5af1113..a6ce266 100644 --- a/src/main/java/com/xit/core/support/CamelCaseMap.java +++ b/src/main/java/com/xit/core/support/CamelCaseMap.java @@ -4,7 +4,7 @@ import org.springframework.jdbc.support.JdbcUtils; import java.util.HashMap; -public class CamelCaseMap extends HashMap{ +public class CamelCaseMap extends HashMap { @Override public Object put(Object key, Object value){ diff --git a/src/main/java/com/xit/core/support/RefreshableSqlSessionFactoryBean.java b/src/main/java/com/xit/core/support/RefreshableSqlSessionFactoryBean.java index 73cec09..94ccee2 100644 --- a/src/main/java/com/xit/core/support/RefreshableSqlSessionFactoryBean.java +++ b/src/main/java/com/xit/core/support/RefreshableSqlSessionFactoryBean.java @@ -73,7 +73,7 @@ public class RefreshableSqlSessionFactoryBean extends SqlSessionFactoryBean impl } }); task = new TimerTask() { - private Map map = new HashMap(); + private final Map map = new HashMap<>(); public void run() { if (isModified()) { @@ -102,14 +102,14 @@ public class RefreshableSqlSessionFactoryBean extends SqlSessionFactoryBean impl try { long modified = resource.lastModified(); if (map.containsKey(resource)) { - long lastModified = ((Long) map.get(resource)).longValue(); + long lastModified = (Long) map.get(resource); if (lastModified != modified) { - map.put(resource, new Long(modified)); + map.put(resource, modified); modifiedResources.add(resource.getDescription()); retVal = true; } } else { - map.put(resource, new Long(modified)); + map.put(resource, modified); } } catch (IOException e) { log.error("caught exception", e); diff --git a/src/main/java/com/xit/core/support/hateoas/CustomPagedResourceAssembler.java b/src/main/java/com/xit/core/support/hateoas/CustomPagedResourceAssembler.java index 3bfdfac..82d66e9 100644 --- a/src/main/java/com/xit/core/support/hateoas/CustomPagedResourceAssembler.java +++ b/src/main/java/com/xit/core/support/hateoas/CustomPagedResourceAssembler.java @@ -88,7 +88,7 @@ public class CustomPagedResourceAssembler extends PagedResourcesAssembler resources.add(createLink(base, PageRequest.of(0, size, sort), IanaLinkRelations.FIRST)); } - Link selfLink = link.map(it -> it.withSelfRel()).orElseGet(() -> createLink(base, page.getPageable(), IanaLinkRelations.SELF)); + Link selfLink = link.map(Link::withSelfRel).orElseGet(() -> createLink(base, page.getPageable(), IanaLinkRelations.SELF)); resources.add(selfLink); diff --git a/src/main/java/com/xit/core/support/jpa/EnumFindUtils.java b/src/main/java/com/xit/core/support/jpa/EnumFindUtils.java deleted file mode 100644 index 236e959..0000000 --- a/src/main/java/com/xit/core/support/jpa/EnumFindUtils.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.xit.core.support.jpa; - -import com.xit.core.oauth2.oauth.entity.ProviderType; - -import java.util.Arrays; -import java.util.Objects; - -public class EnumFindUtils { - - public static ProviderType fromProviderType(String code) { - return Arrays.stream(ProviderType.values()) - .filter(r -> Objects.equals(r.name(), code)) - .findAny() - .orElse(null); - } -} diff --git a/src/main/java/com/xit/core/support/jpa/Paginator.java b/src/main/java/com/xit/core/support/jpa/Paginator.java index ab02d04..626436e 100644 --- a/src/main/java/com/xit/core/support/jpa/Paginator.java +++ b/src/main/java/com/xit/core/support/jpa/Paginator.java @@ -9,9 +9,9 @@ import java.io.Serializable; public class Paginator implements Serializable { private static final long serialVersionUID = 1L; - private int limit; + private final int limit; private int page = 1; - private int totalCount; + private final int totalCount; public Paginator(int page, int limit, int totalCount) { super(); diff --git a/src/main/java/com/xit/core/support/listener/SessionListener.java b/src/main/java/com/xit/core/support/listener/SessionListener.java index 84cc73c..dc4efcf 100644 --- a/src/main/java/com/xit/core/support/listener/SessionListener.java +++ b/src/main/java/com/xit/core/support/listener/SessionListener.java @@ -65,14 +65,8 @@ public class SessionListener implements HttpSessionListener { * @return boolean boolean */ public boolean isMaxLoginSessions() { - boolean retVal = false; - - if(maxSessionValidCount <= getActiveLoginSessionCount()) { - retVal = true; - } - - return retVal; - } + return maxSessionValidCount <= getActiveLoginSessionCount(); +} /** 현재 활성화 된 session의 수를 반환한다. * @return int int diff --git a/src/main/java/com/xit/core/support/listener/UserDupCheckListener.java b/src/main/java/com/xit/core/support/listener/UserDupCheckListener.java index 45031bb..07a8497 100644 --- a/src/main/java/com/xit/core/support/listener/UserDupCheckListener.java +++ b/src/main/java/com/xit/core/support/listener/UserDupCheckListener.java @@ -1,11 +1,14 @@ package com.xit.core.support.listener; +import lombok.extern.slf4j.Slf4j; + import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; import java.util.HashMap; import java.util.Iterator; import java.util.Set; +@Slf4j public class UserDupCheckListener implements HttpSessionListener { private static UserDupCheckListener userDupCheckListener; private static HashMap sessionMap; @@ -57,12 +60,12 @@ log(); private void log(){ Set set = sessionMap.keySet(); Iterator it = set.iterator(); -System.out.printf("================================================\n"); +System.out.print("================================================\n"); while (it.hasNext()) { String key = it.next(); System.out.printf("%s=%s\n", key, sessionMap.get(key)); } -System.out.printf("================================================\n"); +System.out.print("================================================\n"); } } \ No newline at end of file diff --git a/src/main/java/com/xit/core/support/mybatis/paging/OffsetLimitInterceptor.java b/src/main/java/com/xit/core/support/mybatis/paging/OffsetLimitInterceptor.java index 3a778b8..21c0088 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/OffsetLimitInterceptor.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/OffsetLimitInterceptor.java @@ -39,7 +39,7 @@ public class OffsetLimitInterceptor implements Interceptor { static int MAPPED_STATEMENT_INDEX = 0; static int PARAMETER_INDEX = 1; static int ROWBOUNDS_INDEX = 2; - static int RESULT_HANDLER_INDEX = 3; + //static int RESULT_HANDLER_INDEX = 3; static ExecutorService Pool; String dialectClass; boolean asyncTotalCount = false; @@ -71,36 +71,30 @@ public class OffsetLimitInterceptor implements Interceptor { queryArgs[PARAMETER_INDEX] = dialect.getParameterObject(); queryArgs[ROWBOUNDS_INDEX] = new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT); - Boolean async = pageBounds.getAsyncTotalCount() == null ? asyncTotalCount : pageBounds.getAsyncTotalCount(); - Future listFuture = call(new Callable() { - public List call() throws Exception { - return (List) invocation.proceed(); - } - }, async); + boolean async = pageBounds.getAsyncTotalCount() == null ? asyncTotalCount : pageBounds.getAsyncTotalCount(); + Future listFuture = call((Callable) () -> (List) invocation.proceed(), async); if (pageBounds.isContainsTotalCount()) { - Callable countTask = new Callable() { - public Object call() throws Exception { - Paginator paginator = null; - Integer count; - Cache cache = ms.getCache(); - if (cache != null && ms.isUseCache() && ms.getConfiguration().isCacheEnabled()) { - CacheKey cacheKey = executor.createCacheKey( - ms, - parameter, - new PageBounds(), - copyFromBoundSql(ms, boundSql, dialect.getCountSQL(), boundSql.getParameterMappings(), boundSql.getParameterObject())); - count = (Integer) cache.getObject(cacheKey); - if (count == null) { - count = SQLHelp.getCount(ms, parameter, boundSql, dialect); - cache.putObject(cacheKey, count); - } - } else { + Callable countTask = (Callable) () -> { + Paginator paginator; + Integer count; + Cache cache = ms.getCache(); + if (cache != null && ms.isUseCache() && ms.getConfiguration().isCacheEnabled()) { + CacheKey cacheKey = executor.createCacheKey( + ms, + parameter, + new PageBounds(), + copyFromBoundSql(ms, boundSql, dialect.getCountSQL(), boundSql.getParameterMappings(), boundSql.getParameterObject())); + count = (Integer) cache.getObject(cacheKey); + if (count == null) { count = SQLHelp.getCount(ms, parameter, boundSql, dialect); + cache.putObject(cacheKey, count); } - paginator = new Paginator(pageBounds.getPage(), pageBounds.getLimit(), count); - return paginator; + } else { + count = SQLHelp.getCount(ms, parameter, boundSql, dialect); } + paginator = new Paginator(pageBounds.getPage(), pageBounds.getLimit(), count); + return paginator; }; Future countFutrue = call(countTask, async); // PageList pageList = new PageList(listFuture.get(), countFutrue.get()); @@ -150,7 +144,7 @@ public class OffsetLimitInterceptor implements Interceptor { builder.statementType(ms.getStatementType()); builder.keyGenerator(ms.getKeyGenerator()); if (Checks.isNotEmpty(ms.getKeyProperties())) { - StringBuffer keyProperties = new StringBuffer(); + StringBuilder keyProperties = new StringBuilder(); for (String keyProperty : ms.getKeyProperties()) { keyProperties.append(keyProperty).append(","); } diff --git a/src/main/java/com/xit/core/support/mybatis/paging/dialect/DB2Dialect.java b/src/main/java/com/xit/core/support/mybatis/paging/dialect/DB2Dialect.java index 443468d..baec2c0 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/dialect/DB2Dialect.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/dialect/DB2Dialect.java @@ -10,7 +10,7 @@ public class DB2Dialect extends Dialect { } private static String getRowNumber(String sql) { - StringBuffer rownumber = new StringBuffer(50) + StringBuilder rownumber = new StringBuilder(50) .append("rownumber() over("); int orderByIndex = sql.toLowerCase().indexOf("order by"); @@ -25,14 +25,14 @@ public class DB2Dialect extends Dialect { } private static boolean hasDistinct(String sql) { - return sql.toLowerCase().indexOf("select distinct") >= 0; + return sql.toLowerCase().contains("select distinct"); } protected String getLimitString(String sql, String offsetName, int offset, String limitName, int limit) { int startOfSelect = sql.toLowerCase().indexOf("select"); - StringBuffer pagingSelect = new StringBuffer(sql.length() + 100) + StringBuilder pagingSelect = new StringBuilder(sql.length() + 100) .append(sql.substring(0, startOfSelect)) // add the comment .append("select * from ( select ") // nest the main query in an // outer select diff --git a/src/main/java/com/xit/core/support/mybatis/paging/dialect/DerbyDialect.java b/src/main/java/com/xit/core/support/mybatis/paging/dialect/DerbyDialect.java index 86697de..e065739 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/dialect/DerbyDialect.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/dialect/DerbyDialect.java @@ -22,10 +22,9 @@ public class DerbyDialect extends Dialect { public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder) { - return new StringBuffer(sql.length() + 30) - .append(sql) - .append(" offset " + offsetPlaceholder + " rows fetch next " - + limitPlaceholder + " rows only").toString(); + return sql + + " offset " + offsetPlaceholder + " rows fetch next " + + limitPlaceholder + " rows only"; } diff --git a/src/main/java/com/xit/core/support/mybatis/paging/dialect/Dialect.java b/src/main/java/com/xit/core/support/mybatis/paging/dialect/Dialect.java index 505bb2c..490e2da 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/dialect/Dialect.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/dialect/Dialect.java @@ -46,7 +46,7 @@ public class Dialect { } } - StringBuffer bufferSql = new StringBuffer(boundSql.getSql().trim()); + StringBuilder bufferSql = new StringBuilder(boundSql.getSql().trim()); if (bufferSql.lastIndexOf(";") == bufferSql.length() - 1) { bufferSql.deleteCharAt(bufferSql.length() - 1); } @@ -121,7 +121,7 @@ public class Dialect { return sql; } - StringBuffer buffer = new StringBuffer("select * from (\n").append(sql).append("\n) temp_order order by "); + StringBuilder buffer = new StringBuilder("select * from (\n").append(sql).append("\n) temp_order order by "); for (Order order : orders) { if (order != null) { buffer.append(order.toString()).append(", "); diff --git a/src/main/java/com/xit/core/support/mybatis/paging/dialect/H2Dialect.java b/src/main/java/com/xit/core/support/mybatis/paging/dialect/H2Dialect.java index 7738e59..92a7fb3 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/dialect/H2Dialect.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/dialect/H2Dialect.java @@ -11,10 +11,8 @@ public class H2Dialect extends Dialect { } protected String getLimitString(String sql, String offsetName,int offset, String limitName, int limit) { - return new StringBuffer(sql.length() + 40). - append(sql). - append((offset > 0) ? " limit "+String.valueOf(limit)+" offset "+String.valueOf(offset) : " limit "+String.valueOf(limit)). - toString(); + return sql + + ((offset > 0) ? " limit " + String.valueOf(limit) + " offset " + String.valueOf(offset) : " limit " + String.valueOf(limit)); } diff --git a/src/main/java/com/xit/core/support/mybatis/paging/dialect/MySQLDialect.java b/src/main/java/com/xit/core/support/mybatis/paging/dialect/MySQLDialect.java index a2ea2ec..2531f65 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/dialect/MySQLDialect.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/dialect/MySQLDialect.java @@ -10,7 +10,7 @@ public class MySQLDialect extends Dialect { } protected String getLimitString(String sql, String offsetName, int offset, String limitName, int limit) { - StringBuffer buffer = new StringBuffer(sql.length() + 20).append(sql); + StringBuilder buffer = new StringBuilder(sql.length() + 20).append(sql); if (offset > 0) { buffer.append("\n limit ?, ?"); setPageParameter(offsetName, offset, Integer.class); diff --git a/src/main/java/com/xit/core/support/mybatis/paging/dialect/OracleDialect.java b/src/main/java/com/xit/core/support/mybatis/paging/dialect/OracleDialect.java index 4036ed4..91ed144 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/dialect/OracleDialect.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/dialect/OracleDialect.java @@ -17,7 +17,7 @@ public class OracleDialect extends Dialect { isForUpdate = true; } - StringBuffer pagingSelect = new StringBuffer(sql.length() + 100); + StringBuilder pagingSelect = new StringBuilder(sql.length() + 100); if (offset > 0) { pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( "); } else { diff --git a/src/main/java/com/xit/core/support/mybatis/paging/dialect/PostgreSQLDialect.java b/src/main/java/com/xit/core/support/mybatis/paging/dialect/PostgreSQLDialect.java index d4c980b..29cc5fd 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/dialect/PostgreSQLDialect.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/dialect/PostgreSQLDialect.java @@ -14,7 +14,7 @@ public class PostgreSQLDialect extends Dialect{ } protected String getLimitString(String sql, String offsetName,int offset, String limitName, int limit) { - StringBuffer buffer = new StringBuffer( sql.length()+20 ).append(sql); + StringBuilder buffer = new StringBuilder( sql.length()+20 ).append(sql); if(offset > 0){ buffer.append(" limit ? offset ?"); setPageParameter(limitName, limit, Integer.class); diff --git a/src/main/java/com/xit/core/support/mybatis/paging/dialect/SQLServer2005Dialect.java b/src/main/java/com/xit/core/support/mybatis/paging/dialect/SQLServer2005Dialect.java index 19f042a..ed0d36d 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/dialect/SQLServer2005Dialect.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/dialect/SQLServer2005Dialect.java @@ -24,7 +24,7 @@ public class SQLServer2005Dialect extends Dialect{ * @return A new SQL statement with the LIMIT clause applied. */ protected String getLimitString(String sql, String offsetName,int offset, String limitName, int limit) { - StringBuffer pagingBuilder = new StringBuffer(); + StringBuilder pagingBuilder = new StringBuilder(); String orderby = getOrderByPart(sql); String distinctStr = ""; @@ -45,7 +45,7 @@ public class SQLServer2005Dialect extends Dialect{ orderby = "ORDER BY CURRENT_TIMESTAMP"; } - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append("WITH query AS (SELECT ") .append(distinctStr) .append("TOP 100 PERCENT ") diff --git a/src/main/java/com/xit/core/support/mybatis/paging/domain/Order.java b/src/main/java/com/xit/core/support/mybatis/paging/domain/Order.java index 3fc55f0..7aeaf55 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/domain/Order.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/domain/Order.java @@ -46,9 +46,8 @@ public class Order implements Serializable { this.orderExpr = orderExpr; } - private static String INJECTION_REGEX = "[A-Za-z0-9\\_\\-\\+\\.]+"; - public static boolean isSQLInjection(String str) { + String INJECTION_REGEX = "[A-Za-z0-9\\_\\-\\+\\.]+"; return !Pattern.matches(INJECTION_REGEX, str); } @@ -57,7 +56,7 @@ public class Order implements Serializable { if (isSQLInjection(property)) { throw new IllegalArgumentException("SQLInjection property: " + property); } - if (orderExpr != null && orderExpr.indexOf("?") != -1) { + if (orderExpr != null && orderExpr.contains("?")) { String[] exprs = orderExpr.split("\\?"); if (exprs.length == 2) { return String.format(orderExpr.replaceAll("\\?", "%s"), property) + (direction == null ? "" : " " + direction.name()); @@ -72,12 +71,10 @@ public class Order implements Serializable { } /** - * @param orderSegment + * @param orderSegment String * ex: "id.asc,code.desc" or "code.desc" - * - * @param orderSegment orderSegment - * @param orderExpr orderExpr - * @return List List + * @param orderExpr String + * @return List List */ public static List formString(String orderSegment, String orderExpr) { if (Objects.isNull(orderSegment) || Objects.equals(StringUtils.EMPTY, orderSegment.trim())) { diff --git a/src/main/java/com/xit/core/support/mybatis/paging/domain/PageBounds.java b/src/main/java/com/xit/core/support/mybatis/paging/domain/PageBounds.java index 7fb7de3..575d481 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/domain/PageBounds.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/domain/PageBounds.java @@ -146,13 +146,11 @@ public class PageBounds extends RowBounds implements Serializable { @Override public String toString() { - final StringBuilder sb = new StringBuilder("PageBounds{"); - sb.append("page=").append(page); - sb.append(", limit=").append(limit); - sb.append(", orders=").append(orders); - sb.append(", containsTotalCount=").append(containsTotalCount); - sb.append(", asyncTotalCount=").append(asyncTotalCount); - sb.append('}'); - return sb.toString(); + return "PageBounds{" + "page=" + page + + ", limit=" + limit + + ", orders=" + orders + + ", containsTotalCount=" + containsTotalCount + + ", asyncTotalCount=" + asyncTotalCount + + '}'; } } \ No newline at end of file diff --git a/src/main/java/com/xit/core/support/mybatis/paging/domain/Paginator.java b/src/main/java/com/xit/core/support/mybatis/paging/domain/Paginator.java index b0c34ee..f02b928 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/domain/Paginator.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/domain/Paginator.java @@ -9,9 +9,9 @@ import java.io.Serializable; public class Paginator implements Serializable { private static final long serialVersionUID = 1L; - private int limit; + private final int limit; private int page = 1; - private int totalCount; + private final int totalCount; public Paginator(int page, int limit, int totalCount) { super(); @@ -133,12 +133,10 @@ public class Paginator implements Serializable { @Override public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("Paginator"); - sb.append("{page=").append(page); - sb.append(", limit=").append(limit); - sb.append(", totalCount=").append(totalCount); - sb.append('}'); - return sb.toString(); + return "Paginator" + + "{page=" + page + + ", limit=" + limit + + ", totalCount=" + totalCount + + '}'; } } diff --git a/src/main/java/com/xit/core/support/mybatis/paging/jackson2/PageListJsonMapper.java b/src/main/java/com/xit/core/support/mybatis/paging/jackson2/PageListJsonMapper.java deleted file mode 100644 index 69bf878..0000000 --- a/src/main/java/com/xit/core/support/mybatis/paging/jackson2/PageListJsonMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.xit.core.support.mybatis.paging.jackson2; - -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.module.SimpleModule; - -import com.xit.core.support.mybatis.paging.domain.PageList; - -/** - * Converter의 ObjectMapper 확장 - * ResponseBody 사용시 호출 - * Converter 실행시 Paging 정보 추가 return - * page, limit(row/page), totalCount, offset(쿼리조회시작row), startRow, prePage, nextPage, endRow, totalPages - * boolean 값 : firstPage, lastPage, hasPrePage, hasNextPage - * @author minuk - * - */ -@SuppressWarnings("serial") -public class PageListJsonMapper extends ObjectMapper{ - - public PageListJsonMapper() { - //JSON data pretty 정렬 - enable(SerializationFeature.INDENT_OUTPUT); - SimpleModule module = new SimpleModule("PageListJSONModule", new Version(1, 0, 0, null, null, null)); - //module.addSerializer(PageList.class, new PageListJsonSerializer(this)); - module.addSerializer(PageList.class, new PageListJsonSerializer()); - registerModule(module); - } -} diff --git a/src/main/java/com/xit/core/support/mybatis/paging/jackson2/PageListJsonSerializer.java b/src/main/java/com/xit/core/support/mybatis/paging/jackson2/PageListJsonSerializer.java index ad8496d..e252c43 100644 --- a/src/main/java/com/xit/core/support/mybatis/paging/jackson2/PageListJsonSerializer.java +++ b/src/main/java/com/xit/core/support/mybatis/paging/jackson2/PageListJsonSerializer.java @@ -1,7 +1,6 @@ package com.xit.core.support.mybatis.paging.jackson2; import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; import com.xit.core.constant.XitConstants; @@ -17,15 +16,15 @@ import java.util.Map; //TODO PageListJsonSerializer - Converting시 data attribute name 정의 - property에서 읽어 온다 @SuppressWarnings("rawtypes") -public class PageListJsonSerializer extends JsonSerializer{ +public class PageListJsonSerializer extends JsonSerializer{ private final Logger log = LoggerHelper.getLogger(); @SuppressWarnings("unchecked") @Override - public void serialize(PageList value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + public void serialize(PageList value, JsonGenerator jgen, SerializerProvider provider) throws IOException { Paginator paginator = value.getPaginator(); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("totalCount", paginator.getTotalCount()); map.put("totalPages", paginator.getTotalPages()); map.put("page", paginator.getPage()); diff --git a/src/main/java/com/xit/core/util/Checks.java b/src/main/java/com/xit/core/util/Checks.java index 2039d9e..759a7e7 100644 --- a/src/main/java/com/xit/core/util/Checks.java +++ b/src/main/java/com/xit/core/util/Checks.java @@ -9,12 +9,9 @@ public class Checks { /** * val이 null이 아니면 그대로 리턴, 아니면 defVal * - * @param val - * @param defVal + * @param val T + * @param defVal T * @return T - * @warning [Optional]함수의 제약사항이나 주의해야 할 점 - * @exception [Mandatory]throw하는 exception들에 대한 설명 - * @see [Optional]관련 정보(관련 함수, 관련 모듈) */ public static < T > T checkVal( T val, T defVal ) { return ( isNotNull( val ) ? val : defVal ); @@ -23,11 +20,9 @@ public class Checks { /** * val이 Empty가 아니면 그대로 리턴, 아니면 defVal (Empty는 배열이나 Map도 가능) * - * @메소드 : checkEmptyVal - * - * @param val - * @param defVal - * @return + * @param val T + * @param defVal T + * @return T */ public static < T > T checkEmptyVal( T val, T defVal ) { return ( isNotEmpty( val ) ? val : defVal ); @@ -36,13 +31,10 @@ public class Checks { /** * expression이 true이면 val, 아니면 defVal * - * @param expression - * @param tVal - * @param fVal + * @param expression boolean + * @param tVal T + * @param fVal T * @return T - * @warning [Optional]함수의 제약사항이나 주의해야 할 점 - * @exception [Mandatory]throw하는 exception들에 대한 설명 - * @see [Optional]관련 정보(관련 함수, 관련 모듈) */ public static < T > T checkVal( boolean expression, T tVal, T fVal ) { return ( expression ? tVal : fVal ); diff --git a/src/main/java/com/xit/core/util/CommUtil.java b/src/main/java/com/xit/core/util/CommUtil.java index c68c5ec..d2df5e0 100644 --- a/src/main/java/com/xit/core/util/CommUtil.java +++ b/src/main/java/com/xit/core/util/CommUtil.java @@ -28,15 +28,6 @@ import java.util.Random; @Slf4j public class CommUtil { -// /** -// * 클래스의 인스턴스 정보 생성 함수 -// * @param className String -// * @return Object -// * @throws IllegalAccessException -// * @throws ClassNotFoundException -// * @exception -// */ - /** * 클래스의 인스턴스 정보 생성 함수 * diff --git a/src/main/java/com/xit/core/util/DateUtil.java b/src/main/java/com/xit/core/util/DateUtil.java index b65d54c..d62dd5c 100644 --- a/src/main/java/com/xit/core/util/DateUtil.java +++ b/src/main/java/com/xit/core/util/DateUtil.java @@ -1,7 +1,5 @@ package com.xit.core.util; - - import org.apache.commons.lang3.StringUtils; import java.text.SimpleDateFormat; diff --git a/src/main/java/com/xit/core/util/DateUtil2.java b/src/main/java/com/xit/core/util/DateUtil2.java index 03e5226..000e30e 100644 --- a/src/main/java/com/xit/core/util/DateUtil2.java +++ b/src/main/java/com/xit/core/util/DateUtil2.java @@ -1021,18 +1021,6 @@ public class DateUtil2 { } - - - - - - - - - - - - public static void main(String args[]) throws Exception { String format = "yyyy-MM-dd HH:mm:ss"; System.out.println("Current Local Time : " +getCurrentDateTime(format)); diff --git a/src/main/java/com/xit/core/util/DeviceInfo.java b/src/main/java/com/xit/core/util/DeviceInfo.java index b640cd1..b834e45 100644 --- a/src/main/java/com/xit/core/util/DeviceInfo.java +++ b/src/main/java/com/xit/core/util/DeviceInfo.java @@ -4,18 +4,6 @@ import lombok.Data; /** * Device 정보 Class - * com.golfzon.newgm.infra.config.common.domain.device DeviceInfo.java - * @author sjisbmoc - * @since - * @version 1.0 - * @see
- * == 계정이력(Modification Infomation) ==
- * 
- * 수정일			수정자		수정내용
- * ----------------------------------------
- * 2021. 4. 6.	sjisbmoc	최초생성
- * 
- * 
*/ @Data public class DeviceInfo { diff --git a/src/main/java/com/xit/core/util/JsonUtil.java b/src/main/java/com/xit/core/util/JsonUtil.java index ba28a8f..0dd9d6b 100644 --- a/src/main/java/com/xit/core/util/JsonUtil.java +++ b/src/main/java/com/xit/core/util/JsonUtil.java @@ -12,26 +12,13 @@ import java.util.Map; /** * JSON Util Class - * com.golfzon.newgm.infra.config.common.util JsonUtil.java - * @author sjisbmoc - * @since - * @version 1.0 - * @see
- * == 계정이력(Modification Infomation) ==
- * 
- * 수정일			수정자		수정내용
- * ----------------------------------------
- * 2021. 4. 6.	sjisbmoc	최초생성
- * 
- * 
*/ public class JsonUtil { /** * Object 를 json string으로 변환 - * @return String - * @param obj - * @throws JsonProcessingException + * @return String + * @param obj Object */ public static String toJson(Object obj) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); @@ -42,10 +29,9 @@ public class JsonUtil { /** * Json string을 지정된 class로 변환 - * @return T - * @param str - * @param cls - * @throws IOException + * @return T + * @param str String + * @param cls Class */ public static T toObject(String str, Class cls) throws IOException { ObjectMapper om = new ObjectMapper(); @@ -55,10 +41,9 @@ public class JsonUtil { /** * Json string을 지정된 class로 변환 - * @return T - * @param str - * @param cls - * @throws IOException + * @param obj Object + * @param cls Class + * @return T */ public static T toObjByObj(Object obj, Class cls) throws IOException { String str = toJson(obj); @@ -86,9 +71,8 @@ public class JsonUtil { /** * JSON 문자열을 Map 구조체로 변환 - * @param String str - * @return - * @exception + * @param str String str + * @return Map */ public static Map toMap(String str) throws IOException{ Map map = null; @@ -99,14 +83,14 @@ public class JsonUtil { /** * Json 데이터 보기 좋게 변환. - * @param String json - * @return String + * @param obj Object json + * @return String */ public static String jsonEnterConvert(Object obj) { - String rltStr = ""; + String rltStr; try { - rltStr = jsonEnterConvert((JsonUtil.toJson(obj)).toString()); + rltStr = jsonEnterConvert((JsonUtil.toJson(obj))); } catch(Exception e) { rltStr = ""; } @@ -116,7 +100,7 @@ public class JsonUtil { /** * Json 데이터 보기 좋게 변환. - * @param String json + * @param json String json * @return String */ private static String jsonEnterConvert(String json) { diff --git a/src/main/java/com/xit/core/util/LogUtil.java b/src/main/java/com/xit/core/util/LogUtil.java index ac2b10d..e6d9299 100644 --- a/src/main/java/com/xit/core/util/LogUtil.java +++ b/src/main/java/com/xit/core/util/LogUtil.java @@ -2,24 +2,12 @@ package com.xit.core.util; /** * Log Util Class - * com.golfzon.newgm.infra.config.common.util LogUtil.java - * @author sjisbmoc - * @since - * @version 1.0 - * @see
- * == 계정이력(Modification Infomation) ==
- * 
- * 수정일			수정자		수정내용
- * ----------------------------------------
- * 2021. 4. 6.	sjisbmoc	최초생성
- * 
- * 
*/ public class LogUtil { /** * Json 데이터 보기 좋게 변환. - * @param Object obj + * @param obj Object obj * @return String */ public static Object toString(Object obj){ diff --git a/src/main/java/com/xit/core/util/PoiExcelView.java b/src/main/java/com/xit/core/util/PoiExcelView.java index 058e34e..71dc4b4 100644 --- a/src/main/java/com/xit/core/util/PoiExcelView.java +++ b/src/main/java/com/xit/core/util/PoiExcelView.java @@ -13,9 +13,7 @@ import java.text.SimpleDateFormat; import java.util.*; public class PoiExcelView extends AbstractXlsxView { - - - String fileName = ""; + private final String fileName; public PoiExcelView(String fileName) { this.fileName = fileName; @@ -64,6 +62,7 @@ public class PoiExcelView extends AbstractXlsxView { encodedFilename = encodedFilename1; } else if (Objects.equals("Chrome", browser)) { StringBuilder sb = new StringBuilder(); + for (int i = 0; i < filename.length(); i++) { char c = filename.charAt(i); if (c > '~') { diff --git a/src/main/java/com/xit/core/util/SpringUtils.java b/src/main/java/com/xit/core/util/SpringUtils.java index 130d424..19d3e10 100644 --- a/src/main/java/com/xit/core/util/SpringUtils.java +++ b/src/main/java/com/xit/core/util/SpringUtils.java @@ -3,7 +3,7 @@ package com.xit.core.util; import com.xit.core.config.support.ApplicationContextProvider; import com.xit.core.oauth2.api.service.IAuthService; import com.xit.core.oauth2.api.service.impl.AuthService; -import com.xit.core.oauth2.oauth.token.JwtTokenProvider; +import com.xit.core.oauth2.oauth.JwtTokenProvider; import org.springframework.context.ApplicationContext; import org.springframework.context.support.MessageSourceAccessor; diff --git a/src/main/java/com/xit/core/util/ValidationUtil.java b/src/main/java/com/xit/core/util/ValidationUtil.java index e0b1744..ce72c53 100644 --- a/src/main/java/com/xit/core/util/ValidationUtil.java +++ b/src/main/java/com/xit/core/util/ValidationUtil.java @@ -199,10 +199,7 @@ public class ValidationUtil { public static boolean isEmpty(String value) { if(value == null){ return true; - } else if(value.trim().length() == 0){ - return true; - } - return false; + } else return value.trim().length() == 0; } /** @@ -241,11 +238,7 @@ public class ValidationUtil { if(value.length() < min){ return false; } - if(value.length() > max){ - return false; - } - - return true; + return value.length() <= max; } /** @@ -356,10 +349,7 @@ public class ValidationUtil { if(byte_ < min){ return false; } - if(byte_ > max){ - return false; - } - return true; + return byte_ <= max; } /** @@ -372,10 +362,7 @@ public class ValidationUtil { return false; } int byte_ = cstrlen(value); - if(byte_ < min){ - return false; - } - return true; + return byte_ >= min; } /** @@ -388,10 +375,7 @@ public class ValidationUtil { return true; } int byte_ = cstrlen(value); - if(byte_ > max){ - return false; - } - return true; + return byte_ <= max; } /** diff --git a/src/main/java/com/xit/core/util/YamlPropertySourceFactory.java b/src/main/java/com/xit/core/util/YamlPropertySourceFactory.java index c5cdb29..82b50ae 100644 --- a/src/main/java/com/xit/core/util/YamlPropertySourceFactory.java +++ b/src/main/java/com/xit/core/util/YamlPropertySourceFactory.java @@ -9,6 +9,7 @@ import org.springframework.lang.Nullable; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.Objects; import java.util.Properties; public class YamlPropertySourceFactory implements PropertySourceFactory { @@ -16,7 +17,7 @@ public class YamlPropertySourceFactory implements PropertySourceFactory { public PropertySource createPropertySource(@Nullable String name, EncodedResource resource) throws IOException { Properties propertiesFromYaml = loadYamlIntoProperties(resource); String sourceName = name != null ? name : resource.getResource().getFilename(); - return new PropertiesPropertySource(sourceName, propertiesFromYaml); + return new PropertiesPropertySource(Objects.requireNonNull(sourceName), propertiesFromYaml); } private Properties loadYamlIntoProperties(EncodedResource resource) throws FileNotFoundException {