소스 정리

dev
Lim Jonguk 3 years ago
parent 7a16c87bc2
commit ddfbd4f5fc

@ -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<String, AddressType> stringToEnum = Stream.of(values())
.collect(toMap(Objects::toString, e -> e));
}

@ -2,7 +2,10 @@ package com.xit.biz.cmm.entity;
import com.xit.biz.cmm.entity.ids.CmmAddressIds; import com.xit.biz.cmm.entity.ids.CmmAddressIds;
import com.xit.core.constant.XitConstants; 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.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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
@ -42,7 +45,8 @@ public class CmmAddress extends AuditEntity implements Serializable {
@Schema(required = true, title = "주소 구분", example = "STREET", description = "지번 / 도로명") @Schema(required = true, title = "주소 구분", example = "STREET", description = "지번 / 도로명")
@Column(nullable = false, length = 10) @Column(nullable = false, length = 10)
@Enumerated(EnumType.STRING) @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 = "우편번호") @Schema(required = true, title = "우편번호", example = "03001", description = "우편번호")
@Column(nullable = false, length = 6) @Column(nullable = false, length = 6)

@ -1,4 +1,4 @@
package com.xit.biz.sample.ignore; package com.xit.biz.sample._ignore;
import com.xit.biz.sample.Greeting; import com.xit.biz.sample.Greeting;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;

@ -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<Integer> stringFlux;
}

@ -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;
}

@ -5,6 +5,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
/**
* annotation
*/
@Retention(value = RetentionPolicy.RUNTIME) @Retention(value = RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD }) @Target({ ElementType.TYPE, ElementType.METHOD })
public @interface Permission { public @interface Permission {

@ -5,6 +5,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
/**
* annotation
*/
@Retention(value = RetentionPolicy.RUNTIME) @Retention(value = RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD }) @Target({ ElementType.TYPE, ElementType.METHOD })
public @interface Secured { public @interface Secured {

@ -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.api.repository.RefreshTokenRepository;
import com.xit.core.oauth2.config.properties.AppProperties; import com.xit.core.oauth2.config.properties.AppProperties;
import com.xit.core.oauth2.config.properties.CorsProperties; 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.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.OAuth2AuthenticationFailureHandler;
import com.xit.core.oauth2.oauth.handler.OAuth2AuthenticationSuccessHandler; import com.xit.core.oauth2.oauth.handler.OAuth2AuthenticationSuccessHandler;
import com.xit.core.oauth2.oauth.handler.TokenAccessDeniedHandler; import com.xit.core.oauth2.oauth.handler.TokenAccessDeniedHandler;
import com.xit.core.oauth2.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; import com.xit.core.oauth2.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository;
import com.xit.core.oauth2.oauth.service.CustomOAuth2UserService; import com.xit.core.oauth2.oauth.service.CustomOAuth2UserService;
import com.xit.core.oauth2.oauth.service.CustomUserDetailsService; 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 lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; 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.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 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.CorsConfiguration;
import org.springframework.web.cors.CorsUtils; import org.springframework.web.cors.CorsUtils;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
@ -34,6 +32,7 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import java.util.Arrays; import java.util.Arrays;
/** /**
* <pre>
* WebSecurityConfigurerAdapter Override * WebSecurityConfigurerAdapter Override
* *
* 1. configure( WebSecurity) : * 1. configure( WebSecurity) :
@ -64,6 +63,7 @@ import java.util.Arrays;
* LogoutSuccessfulUrl() * LogoutSuccessfulUrl()
* - ExceptionHandlingConfigurer : url * - ExceptionHandlingConfigurer : url
* - OAuth2LoginConfigurer : * - OAuth2LoginConfigurer :
* </pre>
*/ */
@Configuration @Configuration
@RequiredArgsConstructor @RequiredArgsConstructor

@ -1,7 +1,7 @@
package com.xit.core.config; package com.xit.core.config;
import com.xit.core.constant.XitConstants; 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 com.xit.core.support.RestTemplateLoggingRequestInterceptor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;

@ -1,17 +1,21 @@
package com.xit.core.constant; 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.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
public class XitConstants { public class XitConstants {
public static final String JPA_VERSION = "2.4";
public static final String UNIT_NAME = "jpaPersistenceUnit";
// RestTemplate 상수 // RestTemplate 상수
public static final int CONNECT_TIMEOUT = 30 * 1000; // 30초 public static final int CONNECT_TIMEOUT = 30 * 1000; // 30초
public static final int READ_TIMEOUT = 60 * 1000 * 3; // 3분 public static final int READ_TIMEOUT = 60 * 1000 * 3; // 3분
public static final Charset CHARSET = StandardCharsets.UTF_8; public static final Charset CHARSET = StandardCharsets.UTF_8;
public static final String DEFAULT_VIEW = ViewName.JSON_VIEW.getValue();
/** /**
* CustomCommonsRequestLoggingFilter url * CustomCommonsRequestLoggingFilter url
@ -79,135 +83,7 @@ public class XitConstants {
DTO DTO
} }
public enum AddressType { public enum ViewName{
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{
JSON_VIEW("mappingJackson2JsonView") JSON_VIEW("mappingJackson2JsonView")
; ;
private String value; private String value;
@ -218,52 +94,19 @@ public class XitConstants {
return this.value; 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 { public enum Session {
PAGE_INFO("_pageInfo_"), PAGE_INFO("_pageInfo_"),
// DATASET_NAME("gds_pageInfo"), // DATASET_NAME("gds_pageInfo"),

@ -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.LoginRequestDto;
import com.xit.core.oauth2.api.dto.TokenRequestDto; import com.xit.core.oauth2.api.dto.TokenRequestDto;
import com.xit.core.oauth2.api.service.IAuthService; import com.xit.core.oauth2.api.service.IAuthService;
import com.xit.core.oauth2.oauth.token.JwtTokenProvider; import com.xit.core.oauth2.oauth.JwtTokenProvider;
import com.xit.core.support.jpa.EnumFindUtils; //import com.xit.core.support.jpa.EnumFindUtils;
import com.xit.core.util.Checks;
import com.xit.core.util.AssertUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.enums.ParameterIn;

@ -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.IAuthService;
import com.xit.core.oauth2.api.service.IUserService; import com.xit.core.oauth2.api.service.IUserService;
import com.xit.core.oauth2.oauth.entity.RoleType; 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 com.xit.core.oauth2.utils.HeaderUtil;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;

@ -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.dto.TokenRequestDto;
import com.xit.core.oauth2.api.service.IAuthService; import com.xit.core.oauth2.api.service.IAuthService;
import com.xit.core.oauth2.config.properties.AppProperties; 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.CookieUtil;
import com.xit.core.oauth2.utils.HeaderUtil; import com.xit.core.oauth2.utils.HeaderUtil;
import com.xit.core.util.Checks; import com.xit.core.util.Checks;

@ -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);
// }
//}

@ -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.Secured;
import com.xit.core.annotation.SecurityPolicy; import com.xit.core.annotation.SecurityPolicy;

@ -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.ErrorCode;
import com.xit.core.constant.XitConstants; import com.xit.core.constant.XitConstants;

@ -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.JwtToken;
import com.xit.core.oauth2.oauth.token.JwtTokenProvider; import com.xit.core.oauth2.oauth.JwtTokenProvider;
import com.xit.core.oauth2.utils.HeaderUtil; import com.xit.core.oauth2.utils.HeaderUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;

@ -1,12 +1,12 @@
package com.xit.core.oauth2.oauth.exception; //package com.xit.core.oauth2.oauth.exception;
//
public class TokenValidFailedException extends RuntimeException { //public class TokenValidFailedException extends RuntimeException {
//
public TokenValidFailedException() { // public TokenValidFailedException() {
super("Failed to generate Token."); // super("Failed to generate Token.");
} // }
//
private TokenValidFailedException(String message) { // private TokenValidFailedException(String message) {
super(message); // super(message);
} // }
} //}

@ -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.OAuth2UserInfo;
import com.xit.core.oauth2.oauth.info.OAuth2UserInfoFactory; import com.xit.core.oauth2.oauth.info.OAuth2UserInfoFactory;
import com.xit.core.oauth2.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; 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 com.xit.core.oauth2.utils.CookieUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;

@ -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;
// }
//}

@ -4,7 +4,7 @@ import com.xit.core.constant.XitConstants;
import com.xit.core.constant.ErrorCode; import com.xit.core.constant.ErrorCode;
import com.xit.core.exception.TokenAuthException; import com.xit.core.exception.TokenAuthException;
//import com.xit.core.oauth2.oauth.token.JwtToken; //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.Checks;
import com.xit.core.util.SpringUtils; import com.xit.core.util.SpringUtils;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;

@ -4,6 +4,7 @@ import com.xit.core.constant.ErrorCode;
import com.xit.core.constant.XitConstants.AuthSaveType; import com.xit.core.constant.XitConstants.AuthSaveType;
import com.xit.core.exception.UserAuthException; import com.xit.core.exception.UserAuthException;
import com.xit.core.oauth2.api.controller.OAuth2LocalController; import com.xit.core.oauth2.api.controller.OAuth2LocalController;
import com.xit.core.oauth2.oauth.JwtTokenProvider;
import com.xit.core.util.Checks; import com.xit.core.util.Checks;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
@ -21,7 +22,7 @@ import java.util.Objects;
/** /**
* JwtFilter () ID GET * JwtFilter () ID GET
* *
* @see com.xit.biz.auth.jwt.JwtFilter * @see JwtTokenProvider
*/ */
@Slf4j @Slf4j
public class SecurityUtil { public class SecurityUtil {

@ -3,8 +3,9 @@ package com.xit.core.support;
import org.springframework.jdbc.support.JdbcUtils; import org.springframework.jdbc.support.JdbcUtils;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map;
public class CamelCaseLinkedMap extends LinkedHashMap{ public class CamelCaseLinkedMap extends LinkedHashMap {
@Override @Override
public Object put(Object key, Object value){ public Object put(Object key, Object value){

@ -4,7 +4,7 @@ import org.springframework.jdbc.support.JdbcUtils;
import java.util.HashMap; import java.util.HashMap;
public class CamelCaseMap extends HashMap{ public class CamelCaseMap extends HashMap {
@Override @Override
public Object put(Object key, Object value){ public Object put(Object key, Object value){

@ -73,7 +73,7 @@ public class RefreshableSqlSessionFactoryBean extends SqlSessionFactoryBean impl
} }
}); });
task = new TimerTask() { task = new TimerTask() {
private Map<Resource, Long> map = new HashMap<Resource, Long>(); private final Map<Resource, Long> map = new HashMap<>();
public void run() { public void run() {
if (isModified()) { if (isModified()) {
@ -102,14 +102,14 @@ public class RefreshableSqlSessionFactoryBean extends SqlSessionFactoryBean impl
try { try {
long modified = resource.lastModified(); long modified = resource.lastModified();
if (map.containsKey(resource)) { if (map.containsKey(resource)) {
long lastModified = ((Long) map.get(resource)).longValue(); long lastModified = (Long) map.get(resource);
if (lastModified != modified) { if (lastModified != modified) {
map.put(resource, new Long(modified)); map.put(resource, modified);
modifiedResources.add(resource.getDescription()); modifiedResources.add(resource.getDescription());
retVal = true; retVal = true;
} }
} else { } else {
map.put(resource, new Long(modified)); map.put(resource, modified);
} }
} catch (IOException e) { } catch (IOException e) {
log.error("caught exception", e); log.error("caught exception", e);

@ -88,7 +88,7 @@ public class CustomPagedResourceAssembler<T> extends PagedResourcesAssembler<T>
resources.add(createLink(base, PageRequest.of(0, size, sort), IanaLinkRelations.FIRST)); 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); resources.add(selfLink);

@ -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);
}
}

@ -9,9 +9,9 @@ import java.io.Serializable;
public class Paginator implements Serializable { public class Paginator implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private int limit; private final int limit;
private int page = 1; private int page = 1;
private int totalCount; private final int totalCount;
public Paginator(int page, int limit, int totalCount) { public Paginator(int page, int limit, int totalCount) {
super(); super();

@ -65,14 +65,8 @@ public class SessionListener implements HttpSessionListener {
* @return boolean boolean * @return boolean boolean
*/ */
public boolean isMaxLoginSessions() { public boolean isMaxLoginSessions() {
boolean retVal = false; return maxSessionValidCount <= getActiveLoginSessionCount();
}
if(maxSessionValidCount <= getActiveLoginSessionCount()) {
retVal = true;
}
return retVal;
}
/** session . /** session .
* @return int int * @return int int

@ -1,11 +1,14 @@
package com.xit.core.support.listener; package com.xit.core.support.listener;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener; import javax.servlet.http.HttpSessionListener;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
@Slf4j
public class UserDupCheckListener implements HttpSessionListener { public class UserDupCheckListener implements HttpSessionListener {
private static UserDupCheckListener userDupCheckListener; private static UserDupCheckListener userDupCheckListener;
private static HashMap<String,String> sessionMap; private static HashMap<String,String> sessionMap;
@ -57,12 +60,12 @@ log();
private void log(){ private void log(){
Set<String> set = sessionMap.keySet(); Set<String> set = sessionMap.keySet();
Iterator<String> it = set.iterator(); Iterator<String> it = set.iterator();
System.out.printf("================================================\n"); System.out.print("================================================\n");
while (it.hasNext()) { while (it.hasNext()) {
String key = it.next(); String key = it.next();
System.out.printf("%s=%s\n", key, sessionMap.get(key)); System.out.printf("%s=%s\n", key, sessionMap.get(key));
} }
System.out.printf("================================================\n"); System.out.print("================================================\n");
} }
} }

@ -39,7 +39,7 @@ public class OffsetLimitInterceptor implements Interceptor {
static int MAPPED_STATEMENT_INDEX = 0; static int MAPPED_STATEMENT_INDEX = 0;
static int PARAMETER_INDEX = 1; static int PARAMETER_INDEX = 1;
static int ROWBOUNDS_INDEX = 2; static int ROWBOUNDS_INDEX = 2;
static int RESULT_HANDLER_INDEX = 3; //static int RESULT_HANDLER_INDEX = 3;
static ExecutorService Pool; static ExecutorService Pool;
String dialectClass; String dialectClass;
boolean asyncTotalCount = false; boolean asyncTotalCount = false;
@ -71,36 +71,30 @@ public class OffsetLimitInterceptor implements Interceptor {
queryArgs[PARAMETER_INDEX] = dialect.getParameterObject(); queryArgs[PARAMETER_INDEX] = dialect.getParameterObject();
queryArgs[ROWBOUNDS_INDEX] = new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT); queryArgs[ROWBOUNDS_INDEX] = new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT);
Boolean async = pageBounds.getAsyncTotalCount() == null ? asyncTotalCount : pageBounds.getAsyncTotalCount(); boolean async = pageBounds.getAsyncTotalCount() == null ? asyncTotalCount : pageBounds.getAsyncTotalCount();
Future<List> listFuture = call(new Callable<List>() { Future<List> listFuture = call((Callable<List>) () -> (List) invocation.proceed(), async);
public List call() throws Exception {
return (List) invocation.proceed();
}
}, async);
if (pageBounds.isContainsTotalCount()) { if (pageBounds.isContainsTotalCount()) {
Callable<Paginator> countTask = new Callable() { Callable<Paginator> countTask = (Callable) () -> {
public Object call() throws Exception { Paginator paginator;
Paginator paginator = null; Integer count;
Integer count; Cache cache = ms.getCache();
Cache cache = ms.getCache(); if (cache != null && ms.isUseCache() && ms.getConfiguration().isCacheEnabled()) {
if (cache != null && ms.isUseCache() && ms.getConfiguration().isCacheEnabled()) { CacheKey cacheKey = executor.createCacheKey(
CacheKey cacheKey = executor.createCacheKey( ms,
ms, parameter,
parameter, new PageBounds(),
new PageBounds(), copyFromBoundSql(ms, boundSql, dialect.getCountSQL(), boundSql.getParameterMappings(), boundSql.getParameterObject()));
copyFromBoundSql(ms, boundSql, dialect.getCountSQL(), boundSql.getParameterMappings(), boundSql.getParameterObject())); count = (Integer) cache.getObject(cacheKey);
count = (Integer) cache.getObject(cacheKey); if (count == null) {
if (count == null) {
count = SQLHelp.getCount(ms, parameter, boundSql, dialect);
cache.putObject(cacheKey, count);
}
} else {
count = SQLHelp.getCount(ms, parameter, boundSql, dialect); count = SQLHelp.getCount(ms, parameter, boundSql, dialect);
cache.putObject(cacheKey, count);
} }
paginator = new Paginator(pageBounds.getPage(), pageBounds.getLimit(), count); } else {
return paginator; count = SQLHelp.getCount(ms, parameter, boundSql, dialect);
} }
paginator = new Paginator(pageBounds.getPage(), pageBounds.getLimit(), count);
return paginator;
}; };
Future<Paginator> countFutrue = call(countTask, async); Future<Paginator> countFutrue = call(countTask, async);
// PageList pageList = new PageList(listFuture.get(), countFutrue.get()); // PageList pageList = new PageList(listFuture.get(), countFutrue.get());
@ -150,7 +144,7 @@ public class OffsetLimitInterceptor implements Interceptor {
builder.statementType(ms.getStatementType()); builder.statementType(ms.getStatementType());
builder.keyGenerator(ms.getKeyGenerator()); builder.keyGenerator(ms.getKeyGenerator());
if (Checks.isNotEmpty(ms.getKeyProperties())) { if (Checks.isNotEmpty(ms.getKeyProperties())) {
StringBuffer keyProperties = new StringBuffer(); StringBuilder keyProperties = new StringBuilder();
for (String keyProperty : ms.getKeyProperties()) { for (String keyProperty : ms.getKeyProperties()) {
keyProperties.append(keyProperty).append(","); keyProperties.append(keyProperty).append(",");
} }

@ -10,7 +10,7 @@ public class DB2Dialect extends Dialect {
} }
private static String getRowNumber(String sql) { private static String getRowNumber(String sql) {
StringBuffer rownumber = new StringBuffer(50) StringBuilder rownumber = new StringBuilder(50)
.append("rownumber() over("); .append("rownumber() over(");
int orderByIndex = sql.toLowerCase().indexOf("order by"); int orderByIndex = sql.toLowerCase().indexOf("order by");
@ -25,14 +25,14 @@ public class DB2Dialect extends Dialect {
} }
private static boolean hasDistinct(String sql) { 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, protected String getLimitString(String sql, String offsetName, int offset,
String limitName, int limit) { String limitName, int limit) {
int startOfSelect = sql.toLowerCase().indexOf("select"); 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(sql.substring(0, startOfSelect)) // add the comment
.append("select * from ( select ") // nest the main query in an .append("select * from ( select ") // nest the main query in an
// outer select // outer select

@ -22,10 +22,9 @@ public class DerbyDialect extends Dialect {
public String getLimitString(String sql, int offset, public String getLimitString(String sql, int offset,
String offsetPlaceholder, int limit, String limitPlaceholder) { String offsetPlaceholder, int limit, String limitPlaceholder) {
return new StringBuffer(sql.length() + 30) return sql +
.append(sql) " offset " + offsetPlaceholder + " rows fetch next "
.append(" offset " + offsetPlaceholder + " rows fetch next " + limitPlaceholder + " rows only";
+ limitPlaceholder + " rows only").toString();
} }

@ -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) { if (bufferSql.lastIndexOf(";") == bufferSql.length() - 1) {
bufferSql.deleteCharAt(bufferSql.length() - 1); bufferSql.deleteCharAt(bufferSql.length() - 1);
} }
@ -121,7 +121,7 @@ public class Dialect {
return sql; 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) { for (Order order : orders) {
if (order != null) { if (order != null) {
buffer.append(order.toString()).append(", "); buffer.append(order.toString()).append(", ");

@ -11,10 +11,8 @@ public class H2Dialect extends Dialect {
} }
protected String getLimitString(String sql, String offsetName,int offset, String limitName, int limit) { protected String getLimitString(String sql, String offsetName,int offset, String limitName, int limit) {
return new StringBuffer(sql.length() + 40). return sql +
append(sql). ((offset > 0) ? " limit " + String.valueOf(limit) + " offset " + String.valueOf(offset) : " limit " + String.valueOf(limit));
append((offset > 0) ? " limit "+String.valueOf(limit)+" offset "+String.valueOf(offset) : " limit "+String.valueOf(limit)).
toString();
} }

@ -10,7 +10,7 @@ public class MySQLDialect extends Dialect {
} }
protected String getLimitString(String sql, String offsetName, int offset, String limitName, int limit) { 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) { if (offset > 0) {
buffer.append("\n limit ?, ?"); buffer.append("\n limit ?, ?");
setPageParameter(offsetName, offset, Integer.class); setPageParameter(offsetName, offset, Integer.class);

@ -17,7 +17,7 @@ public class OracleDialect extends Dialect {
isForUpdate = true; isForUpdate = true;
} }
StringBuffer pagingSelect = new StringBuffer(sql.length() + 100); StringBuilder pagingSelect = new StringBuilder(sql.length() + 100);
if (offset > 0) { if (offset > 0) {
pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( "); pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( ");
} else { } else {

@ -14,7 +14,7 @@ public class PostgreSQLDialect extends Dialect{
} }
protected String getLimitString(String sql, String offsetName,int offset, String limitName, int limit) { 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){ if(offset > 0){
buffer.append(" limit ? offset ?"); buffer.append(" limit ? offset ?");
setPageParameter(limitName, limit, Integer.class); setPageParameter(limitName, limit, Integer.class);

@ -24,7 +24,7 @@ public class SQLServer2005Dialect extends Dialect{
* @return A new SQL statement with the LIMIT clause applied. * @return A new SQL statement with the LIMIT clause applied.
*/ */
protected String getLimitString(String sql, String offsetName,int offset, String limitName, int limit) { 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 orderby = getOrderByPart(sql);
String distinctStr = ""; String distinctStr = "";
@ -45,7 +45,7 @@ public class SQLServer2005Dialect extends Dialect{
orderby = "ORDER BY CURRENT_TIMESTAMP"; orderby = "ORDER BY CURRENT_TIMESTAMP";
} }
StringBuffer result = new StringBuffer(); StringBuilder result = new StringBuilder();
result.append("WITH query AS (SELECT ") result.append("WITH query AS (SELECT ")
.append(distinctStr) .append(distinctStr)
.append("TOP 100 PERCENT ") .append("TOP 100 PERCENT ")

@ -46,9 +46,8 @@ public class Order implements Serializable {
this.orderExpr = orderExpr; this.orderExpr = orderExpr;
} }
private static String INJECTION_REGEX = "[A-Za-z0-9\\_\\-\\+\\.]+";
public static boolean isSQLInjection(String str) { public static boolean isSQLInjection(String str) {
String INJECTION_REGEX = "[A-Za-z0-9\\_\\-\\+\\.]+";
return !Pattern.matches(INJECTION_REGEX, str); return !Pattern.matches(INJECTION_REGEX, str);
} }
@ -57,7 +56,7 @@ public class Order implements Serializable {
if (isSQLInjection(property)) { if (isSQLInjection(property)) {
throw new IllegalArgumentException("SQLInjection property: " + property); throw new IllegalArgumentException("SQLInjection property: " + property);
} }
if (orderExpr != null && orderExpr.indexOf("?") != -1) { if (orderExpr != null && orderExpr.contains("?")) {
String[] exprs = orderExpr.split("\\?"); String[] exprs = orderExpr.split("\\?");
if (exprs.length == 2) { if (exprs.length == 2) {
return String.format(orderExpr.replaceAll("\\?", "%s"), property) + (direction == null ? "" : " " + direction.name()); 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" * ex: "id.asc,code.desc" or "code.desc"
* * @param orderExpr String
* @param orderSegment orderSegment * @return List<Order> List
* @param orderExpr orderExpr
* @return List List
*/ */
public static List<Order> formString(String orderSegment, String orderExpr) { public static List<Order> formString(String orderSegment, String orderExpr) {
if (Objects.isNull(orderSegment) || Objects.equals(StringUtils.EMPTY, orderSegment.trim())) { if (Objects.isNull(orderSegment) || Objects.equals(StringUtils.EMPTY, orderSegment.trim())) {

@ -146,13 +146,11 @@ public class PageBounds extends RowBounds implements Serializable {
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("PageBounds{"); return "PageBounds{" + "page=" + page +
sb.append("page=").append(page); ", limit=" + limit +
sb.append(", limit=").append(limit); ", orders=" + orders +
sb.append(", orders=").append(orders); ", containsTotalCount=" + containsTotalCount +
sb.append(", containsTotalCount=").append(containsTotalCount); ", asyncTotalCount=" + asyncTotalCount +
sb.append(", asyncTotalCount=").append(asyncTotalCount); '}';
sb.append('}');
return sb.toString();
} }
} }

@ -9,9 +9,9 @@ import java.io.Serializable;
public class Paginator implements Serializable { public class Paginator implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private int limit; private final int limit;
private int page = 1; private int page = 1;
private int totalCount; private final int totalCount;
public Paginator(int page, int limit, int totalCount) { public Paginator(int page, int limit, int totalCount) {
super(); super();
@ -133,12 +133,10 @@ public class Paginator implements Serializable {
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder(); return "Paginator" +
sb.append("Paginator"); "{page=" + page +
sb.append("{page=").append(page); ", limit=" + limit +
sb.append(", limit=").append(limit); ", totalCount=" + totalCount +
sb.append(", totalCount=").append(totalCount); '}';
sb.append('}');
return sb.toString();
} }
} }

@ -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);
}
}

@ -1,7 +1,6 @@
package com.xit.core.support.mybatis.paging.jackson2; package com.xit.core.support.mybatis.paging.jackson2;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import com.xit.core.constant.XitConstants; import com.xit.core.constant.XitConstants;
@ -17,15 +16,15 @@ import java.util.Map;
//TODO PageListJsonSerializer - Converting시 data attribute name 정의 - property에서 읽어 온다 //TODO PageListJsonSerializer - Converting시 data attribute name 정의 - property에서 읽어 온다
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class PageListJsonSerializer extends JsonSerializer<PageList>{ public class PageListJsonSerializer extends JsonSerializer<PageList>{
private final Logger log = LoggerHelper.getLogger(); private final Logger log = LoggerHelper.getLogger();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @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(); Paginator paginator = value.getPaginator();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
map.put("totalCount", paginator.getTotalCount()); map.put("totalCount", paginator.getTotalCount());
map.put("totalPages", paginator.getTotalPages()); map.put("totalPages", paginator.getTotalPages());
map.put("page", paginator.getPage()); map.put("page", paginator.getPage());

@ -9,12 +9,9 @@ public class Checks {
/** /**
* val null , defVal * val null , defVal
* *
* @param val * @param val T
* @param defVal * @param defVal T
* @return T * @return T
* @warning [Optional]
* @exception [Mandatory]throw exception
* @see [Optional] ( , )
*/ */
public static < T > T checkVal( T val, T defVal ) { public static < T > T checkVal( T val, T defVal ) {
return ( isNotNull( val ) ? val : defVal ); return ( isNotNull( val ) ? val : defVal );
@ -23,11 +20,9 @@ public class Checks {
/** /**
* val Empty , defVal (Empty Map ) * val Empty , defVal (Empty Map )
* *
* @ : checkEmptyVal * @param val T
* * @param defVal T
* @param val * @return T
* @param defVal
* @return
*/ */
public static < T > T checkEmptyVal( T val, T defVal ) { public static < T > T checkEmptyVal( T val, T defVal ) {
return ( isNotEmpty( val ) ? val : defVal ); return ( isNotEmpty( val ) ? val : defVal );
@ -36,13 +31,10 @@ public class Checks {
/** /**
* expression true val, defVal * expression true val, defVal
* *
* @param expression * @param expression boolean
* @param tVal * @param tVal T
* @param fVal * @param fVal T
* @return T * @return T
* @warning [Optional]
* @exception [Mandatory]throw exception
* @see [Optional] ( , )
*/ */
public static < T > T checkVal( boolean expression, T tVal, T fVal ) { public static < T > T checkVal( boolean expression, T tVal, T fVal ) {
return ( expression ? tVal : fVal ); return ( expression ? tVal : fVal );

@ -28,15 +28,6 @@ import java.util.Random;
@Slf4j @Slf4j
public class CommUtil { public class CommUtil {
// /**
// * 클래스의 인스턴스 정보 생성 함수
// * @param className String
// * @return Object
// * @throws IllegalAccessException
// * @throws ClassNotFoundException
// * @exception
// */
/** /**
* *
* *

@ -1,7 +1,5 @@
package com.xit.core.util; package com.xit.core.util;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;

@ -1021,18 +1021,6 @@ public class DateUtil2 {
} }
public static void main(String args[]) throws Exception { public static void main(String args[]) throws Exception {
String format = "yyyy-MM-dd HH:mm:ss"; String format = "yyyy-MM-dd HH:mm:ss";
System.out.println("Current Local Time : " +getCurrentDateTime(format)); System.out.println("Current Local Time : " +getCurrentDateTime(format));

@ -4,18 +4,6 @@ import lombok.Data;
/** /**
* Device Class * Device Class
* com.golfzon.newgm.infra.config.common.domain.device DeviceInfo.java
* @author sjisbmoc
* @since
* @version 1.0
* @see <pre>
* == (Modification Infomation) ==
*
*
* ----------------------------------------
* 2021. 4. 6. sjisbmoc
*
* </pre>
*/ */
@Data @Data
public class DeviceInfo { public class DeviceInfo {

@ -12,26 +12,13 @@ import java.util.Map;
/** /**
* JSON Util Class * JSON Util Class
* com.golfzon.newgm.infra.config.common.util JsonUtil.java
* @author sjisbmoc
* @since
* @version 1.0
* @see <pre>
* == (Modification Infomation) ==
*
*
* ----------------------------------------
* 2021. 4. 6. sjisbmoc
*
* </pre>
*/ */
public class JsonUtil { public class JsonUtil {
/** /**
* Object json string * Object json string
* @return String * @return String
* @param obj * @param obj Object
* @throws JsonProcessingException
*/ */
public static String toJson(Object obj) throws JsonProcessingException { public static String toJson(Object obj) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@ -42,10 +29,9 @@ public class JsonUtil {
/** /**
* Json string class * Json string class
* @return T * @return T
* @param str * @param str String
* @param cls * @param cls Class
* @throws IOException
*/ */
public static <T> T toObject(String str, Class<T> cls) throws IOException { public static <T> T toObject(String str, Class<T> cls) throws IOException {
ObjectMapper om = new ObjectMapper(); ObjectMapper om = new ObjectMapper();
@ -55,10 +41,9 @@ public class JsonUtil {
/** /**
* Json string class * Json string class
* @return T * @param obj Object
* @param str * @param cls Class
* @param cls * @return T
* @throws IOException
*/ */
public static <T> T toObjByObj(Object obj, Class<T> cls) throws IOException { public static <T> T toObjByObj(Object obj, Class<T> cls) throws IOException {
String str = toJson(obj); String str = toJson(obj);
@ -86,9 +71,8 @@ public class JsonUtil {
/** /**
* JSON Map * JSON Map
* @param String str * @param str String str
* @return * @return Map
* @exception
*/ */
public static Map<String, Object> toMap(String str) throws IOException{ public static Map<String, Object> toMap(String str) throws IOException{
Map<String, Object> map = null; Map<String, Object> map = null;
@ -99,14 +83,14 @@ public class JsonUtil {
/** /**
* Json . * Json .
* @param String json * @param obj Object json
* @return String * @return String
*/ */
public static String jsonEnterConvert(Object obj) { public static String jsonEnterConvert(Object obj) {
String rltStr = ""; String rltStr;
try { try {
rltStr = jsonEnterConvert((JsonUtil.toJson(obj)).toString()); rltStr = jsonEnterConvert((JsonUtil.toJson(obj)));
} catch(Exception e) { } catch(Exception e) {
rltStr = ""; rltStr = "";
} }
@ -116,7 +100,7 @@ public class JsonUtil {
/** /**
* Json . * Json .
* @param String json * @param json String json
* @return String * @return String
*/ */
private static String jsonEnterConvert(String json) { private static String jsonEnterConvert(String json) {

@ -2,24 +2,12 @@ package com.xit.core.util;
/** /**
* Log Util Class * Log Util Class
* com.golfzon.newgm.infra.config.common.util LogUtil.java
* @author sjisbmoc
* @since
* @version 1.0
* @see <pre>
* == (Modification Infomation) ==
*
*
* ----------------------------------------
* 2021. 4. 6. sjisbmoc
*
* </pre>
*/ */
public class LogUtil { public class LogUtil {
/** /**
* Json . * Json .
* @param Object obj * @param obj Object obj
* @return String * @return String
*/ */
public static Object toString(Object obj){ public static Object toString(Object obj){

@ -13,9 +13,7 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
public class PoiExcelView extends AbstractXlsxView { public class PoiExcelView extends AbstractXlsxView {
private final String fileName;
String fileName = "";
public PoiExcelView(String fileName) { public PoiExcelView(String fileName) {
this.fileName = fileName; this.fileName = fileName;
@ -64,6 +62,7 @@ public class PoiExcelView extends AbstractXlsxView {
encodedFilename = encodedFilename1; encodedFilename = encodedFilename1;
} else if (Objects.equals("Chrome", browser)) { } else if (Objects.equals("Chrome", browser)) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < filename.length(); i++) { for (int i = 0; i < filename.length(); i++) {
char c = filename.charAt(i); char c = filename.charAt(i);
if (c > '~') { if (c > '~') {

@ -3,7 +3,7 @@ package com.xit.core.util;
import com.xit.core.config.support.ApplicationContextProvider; import com.xit.core.config.support.ApplicationContextProvider;
import com.xit.core.oauth2.api.service.IAuthService; import com.xit.core.oauth2.api.service.IAuthService;
import com.xit.core.oauth2.api.service.impl.AuthService; 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.ApplicationContext;
import org.springframework.context.support.MessageSourceAccessor; import org.springframework.context.support.MessageSourceAccessor;

@ -199,10 +199,7 @@ public class ValidationUtil {
public static boolean isEmpty(String value) { public static boolean isEmpty(String value) {
if(value == null){ if(value == null){
return true; return true;
} else if(value.trim().length() == 0){ } else return value.trim().length() == 0;
return true;
}
return false;
} }
/** /**
@ -241,11 +238,7 @@ public class ValidationUtil {
if(value.length() < min){ if(value.length() < min){
return false; return false;
} }
if(value.length() > max){ return value.length() <= max;
return false;
}
return true;
} }
/** /**
@ -356,10 +349,7 @@ public class ValidationUtil {
if(byte_ < min){ if(byte_ < min){
return false; return false;
} }
if(byte_ > max){ return byte_ <= max;
return false;
}
return true;
} }
/** /**
@ -372,10 +362,7 @@ public class ValidationUtil {
return false; return false;
} }
int byte_ = cstrlen(value); int byte_ = cstrlen(value);
if(byte_ < min){ return byte_ >= min;
return false;
}
return true;
} }
/** /**
@ -388,10 +375,7 @@ public class ValidationUtil {
return true; return true;
} }
int byte_ = cstrlen(value); int byte_ = cstrlen(value);
if(byte_ > max){ return byte_ <= max;
return false;
}
return true;
} }
/** /**

@ -9,6 +9,7 @@ import org.springframework.lang.Nullable;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.Objects;
import java.util.Properties; import java.util.Properties;
public class YamlPropertySourceFactory implements PropertySourceFactory { public class YamlPropertySourceFactory implements PropertySourceFactory {
@ -16,7 +17,7 @@ public class YamlPropertySourceFactory implements PropertySourceFactory {
public PropertySource<?> createPropertySource(@Nullable String name, EncodedResource resource) throws IOException { public PropertySource<?> createPropertySource(@Nullable String name, EncodedResource resource) throws IOException {
Properties propertiesFromYaml = loadYamlIntoProperties(resource); Properties propertiesFromYaml = loadYamlIntoProperties(resource);
String sourceName = name != null ? name : resource.getResource().getFilename(); 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 { private Properties loadYamlIntoProperties(EncodedResource resource) throws FileNotFoundException {

Loading…
Cancel
Save