Desc.: 설정 간소화 처리에 사용되는 내부 factory bean
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public class AccessDataSourceFactoryBean implements FactoryBean
Desc.: 권한 정보를 처리하는 factory bean 클래스
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public class AuthorityMapFactoryBean implements FactoryBean
Desc.: 권한 및 접근제한 정보를 매핑하는 클래스
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 - * 2021.02.01 Egovframework Center 권한재설정 수정 + * 2019.10.01 ESFC 최초 생성 + * 2021.02.01 ESFC 권한재설정 수정 **/ public class AuthorityResourceMetadata { diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/bean/AuthorityUserFactoryBean.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/bean/AuthorityUserFactoryBean.java index b8f0e3f5..fd10d53b 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/bean/AuthorityUserFactoryBean.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/bean/AuthorityUserFactoryBean.java @@ -28,15 +28,15 @@ * *
Desc.: 권한 정보 취득을 위한 query 지정을 처리하는 factory bean 클래스
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public class AuthorityUserFactoryBean implements FactoryBean
Desc.: 접근제한 정보를 처리하는 factory bean 클래스
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 * **/ diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/bean/RoleAndUrlFactoryBean.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/bean/RoleAndUrlFactoryBean.java index be156e5a..7a44624c 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/bean/RoleAndUrlFactoryBean.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/bean/RoleAndUrlFactoryBean.java @@ -28,15 +28,15 @@ * *
Desc.: 접근제한 정보 취득을 위한 query 지정을 처리하는 factory bean 클래스
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 * **/ diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfig.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfig.java index ca29e3b5..407cb5d5 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfig.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfig.java @@ -22,16 +22,16 @@ * *
Desc.: 설정 간소화 처리에 사용되는 bean으로 설정에 대한 정보를 보관
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 - * 2019.12.30 신용호 mappingPath 추가 + * 2019.10.01 ESFC 최초 생성 + * 2019.12.30 신용호 mappingPath 추가 **/ public class EgovAccessConfig { diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfigBeanDefinitionParser.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfigBeanDefinitionParser.java index bae2473e..0fb8765a 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfigBeanDefinitionParser.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfigBeanDefinitionParser.java @@ -15,6 +15,7 @@ */ package org.egovframe.rte.fdl.access.config; +import org.apache.commons.lang3.ObjectUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.support.BeanDefinitionBuilder; @@ -26,13 +27,14 @@ import org.w3c.dom.Element; import java.io.ByteArrayInputStream; +import java.nio.charset.StandardCharsets; /** * egov-access schema namespace 'config' element 처리를 담당하는 bean definition parser 클래스 * *
Desc.: 설정 간소화 처리에 사용되는 bean definition parser
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 *@@ -40,8 +42,8 @@ * * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 - * 2019.12.30 신용호 mappingPath 추가 + * 2019.10.01 ESFC 최초 생성 + * 2019.12.30 신용호 mappingPath 추가 **/ public class EgovAccessConfigBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { @@ -56,7 +58,7 @@ protected Class> getBeanClass(Element element) { @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { - LOGGER.debug("##### EgovAccessConfigBeanDefinitionParser doParse Execute #####"); + LOGGER.debug("EgovAccessConfigBeanDefinitionParser doParse Execute !!!"); String globalAuthen = element.getAttribute("globalAuthen"); if (StringUtils.hasText(globalAuthen)) { @@ -100,63 +102,55 @@ protected void doParse(Element element, ParserContext parserContext, BeanDefinit if (StringUtils.hasText(excludeList)) { builder.addPropertyValue("excludeList", excludeList); } - - String mappingPath = element.getAttribute("mappingPath"); - LOGGER.debug("##### EgovAccessConfigBeanDefinitionParser mappingPath >>> {}", mappingPath); - - String beanDefinitionBuilderString = "\n" + - "
Desc.: 설정 간소화 처리에 사용되는 namespace handler
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public class EgovAccessConfigNameHandler extends NamespaceHandlerSupport { diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfigShare.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfigShare.java index a62d19e6..918c343c 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfigShare.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/config/EgovAccessConfigShare.java @@ -20,15 +20,15 @@ * *
Desc.: 설정 간소화 처리에 사용되는 config 공유 변수 클래스s
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public class EgovAccessConfigShare { diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/interceptor/EgovAccessInterceptor.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/interceptor/EgovAccessInterceptor.java index 193d60cf..d3008cc8 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/interceptor/EgovAccessInterceptor.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/interceptor/EgovAccessInterceptor.java @@ -36,15 +36,15 @@ * *
Desc.: 인증 및 접근제한 인터셉터
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public class EgovAccessInterceptor implements HandlerInterceptor, ApplicationContextAware { @@ -52,6 +52,8 @@ public class EgovAccessInterceptor implements HandlerInterceptor, ApplicationCon private static final Logger LOGGER = LoggerFactory.getLogger(EgovAccessInterceptor.class); private ApplicationContext context; + + @Override public void setApplicationContext(ApplicationContext context) throws BeansException { this.context = context; @@ -62,6 +64,8 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons LOGGER.debug("##### EgovAccessInterceptor Start #####"); + + // 인증 체크 boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated(); LOGGER.debug("##### EgovAccessInterceptor interceptor isAuthenticated >>> {}", isAuthenticated); diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/interceptor/EgovAccessUtil.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/interceptor/EgovAccessUtil.java index e01d523b..bea9b4ee 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/interceptor/EgovAccessUtil.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/interceptor/EgovAccessUtil.java @@ -25,15 +25,15 @@ * *
Desc.: Ant / Regular Expression Style Path Check
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public class EgovAccessUtil { diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/EgovAccessService.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/EgovAccessService.java index 41c523c5..7fc4af07 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/EgovAccessService.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/EgovAccessService.java @@ -23,15 +23,15 @@ * *
Desc.: DB기반의 보호된 자원 관리를 지원하는 인터페이스
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public interface EgovAccessService { diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/EgovUserDetailsHelper.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/EgovUserDetailsHelper.java index 2752e0f1..71a51b07 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/EgovUserDetailsHelper.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/EgovUserDetailsHelper.java @@ -33,15 +33,15 @@ * *
Desc.: 사용자 계정 정보를 처리하는 유틸 클래스
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public class EgovUserDetailsHelper { diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/impl/EgovAccessDao.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/impl/EgovAccessDao.java index 6e779aad..cdd0855a 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/impl/EgovAccessDao.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/impl/EgovAccessDao.java @@ -31,15 +31,15 @@ * *
Desc.: DB기반의 보호된 자원 관리를 구현한 DAO 클래스
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public class EgovAccessDao implements ApplicationContextAware { diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/impl/EgovAccessServiceImpl.java b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/impl/EgovAccessServiceImpl.java index 316456bc..b1258849 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/impl/EgovAccessServiceImpl.java +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/java/org/egovframe/rte/fdl/access/service/impl/EgovAccessServiceImpl.java @@ -25,15 +25,15 @@ * *
Desc.: DB기반의 보호된 자원 관리를 지원하는 구현 클래스
* - * @author Egovframework Center + * @author ESFC * @since 2019.10.01 * @version 3.9 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2019.10.01 Egovframework Center 최초 생성 + * 2019.10.01 ESFC 최초 생성 **/ public class EgovAccessServiceImpl implements EgovAccessService { diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/resources/META-INF/spring.schemas b/Foundation/org.egovframe.rte.fdl.access/src/main/resources/META-INF/spring.schemas index eb257af8..5a382f2f 100755 --- a/Foundation/org.egovframe.rte.fdl.access/src/main/resources/META-INF/spring.schemas +++ b/Foundation/org.egovframe.rte.fdl.access/src/main/resources/META-INF/spring.schemas @@ -1,2 +1,2 @@ -http\://maven.egovframe.go.kr/schema/egov-access/egov-access.xsd=org/egovframe/rte/fdl/access/config/egov-access-4.1.0.xsd -http\://maven.egovframe.go.kr/schema/egov-access/egov-access-4.1.0.xsd=org/egovframe/rte/fdl/access/config/egov-access-4.1.0.xsd +http\://maven.egovframe.go.kr/schema/egov-access/egov-access.xsd=org/egovframe/rte/fdl/access/config/egov-access-4.2.0.xsd +http\://maven.egovframe.go.kr/schema/egov-access/egov-access-4.2.0.xsd=org/egovframe/rte/fdl/access/config/egov-access-4.2.0.xsd diff --git a/Foundation/org.egovframe.rte.fdl.access/src/main/resources/org/egovframe/rte/fdl/access/config/egov-access-4.1.0.xsd b/Foundation/org.egovframe.rte.fdl.access/src/main/resources/org/egovframe/rte/fdl/access/config/egov-access-4.2.0.xsd similarity index 100% rename from Foundation/org.egovframe.rte.fdl.access/src/main/resources/org/egovframe/rte/fdl/access/config/egov-access-4.1.0.xsd rename to Foundation/org.egovframe.rte.fdl.access/src/main/resources/org/egovframe/rte/fdl/access/config/egov-access-4.2.0.xsd diff --git a/Foundation/org.egovframe.rte.fdl.access/src/test/resources/META-INF/spring/context-access.xml b/Foundation/org.egovframe.rte.fdl.access/src/test/resources/META-INF/spring/context-access.xml index 50fb88c3..bed0f478 100644 --- a/Foundation/org.egovframe.rte.fdl.access/src/test/resources/META-INF/spring/context-access.xml +++ b/Foundation/org.egovframe.rte.fdl.access/src/test/resources/META-INF/spring/context-access.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:egov-access="http://maven.egovframe.go.kr/schema/egov-access" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://maven.egovframe.go.kr/schema/egov-access http://maven.egovframe.go.kr/schema/egov-access/egov-access-4.1.0.xsd"> + http://maven.egovframe.go.kr/schema/egov-access http://maven.egovframe.go.kr/schema/egov-access/egov-access-4.2.0.xsd">
String
* @throws Exception
*/
- public static void cp(String source, String target) throws Exception {
+ public static void cp(String source, String target) throws FileSystemException {
try {
final FileObject src = manager.resolveFile(basefile, source);
FileObject dest = manager.resolveFile(basefile, target);
@@ -108,13 +104,14 @@ public static void cp(String source, String target) throws Exception {
throw new FileSystemException(fse);
}
}
+
/**
* 지정한 위치의 파일을 대상 위치로 이동한다.
* @param source String
* @param target String
* @throws Exception
*/
- public static void mv(String source, String target) throws Exception {
+ public static void mv(String source, String target) throws FileSystemException {
try {
final FileObject src = manager.resolveFile(basefile, source);
FileObject dest = manager.resolveFile(basefile, target);
@@ -142,7 +139,7 @@ public static FileName pwd() {
* @return
* @throws Exception
*/
- public static long touch(final String filepath) throws Exception {
+ public static long touch(final String filepath) throws FileSystemException {
long currentTime = 0;
final FileObject file = manager.resolveFile(basefile, filepath);
if (!file.exists()) {
@@ -159,7 +156,7 @@ public static long touch(final String filepath) throws Exception {
* @param changDirectory String
* @throws Exception
*/
- public static void cd(final String changDirectory) throws Exception {
+ public static void cd(final String changDirectory) throws FileSystemException {
final String path;
if (!EgovStringUtil.isNull(changDirectory)) {
path = changDirectory;
@@ -226,6 +223,7 @@ public List> ls(final String[] cmd) throws FileSystemException {
private StringBuffer listChildren(final FileObject dir, final boolean recursive, final String prefix) throws FileSystemException {
StringBuffer line = new StringBuffer();
final FileObject[] children = dir.getChildren();
+
for (int i = 0; i < children.length; i++) {
final FileObject child = children[i];
line.append(prefix).append(child.getName().getBaseName());
@@ -251,6 +249,7 @@ private StringBuffer listChildren(final FileObject dir, final boolean recursive,
public static String readFile(File file) throws IOException {
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
String sResult = "";
+
try {
sResult = readFileContent(in);
} catch(IllegalArgumentException e) {
@@ -286,6 +285,7 @@ public static String readFileContent(InputStream in) throws IOException {
public static String readFile(File file, String encoding) throws IOException {
StringBuffer sb = new StringBuffer();
ListNOTE: 이 서비스를 통해 어플리케이션에서 유일한 키값으로 키/값쌍을 가지고 오도록 서비스 한다.
- * + * * @author 실행환경 개발팀 김태호 * @since 2009.02.01 * @version 1.0 @@ -48,18 +56,17 @@ * * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2009.02.01 김태호 최초 생성 - * 2014.08.12 Vincent Han "properties" 속성이 없는 경우 처리 - * 2020.08.31 ESFC Property 값을 정확히 등록하기 위해 put() 메소드를 addProperty() 메소드로 변경 + * 2009.02.01 김태호 최초 생성 + * 2014.08.12 Vincent Han "properties" 속성이 없는 경우 처리 + * 2020.08.31 ESFC Property 값을 정확히 등록하기 위해 put() 메소드를 addProperty() 메소드로 변경 * */ public class EgovPropertyServiceImpl implements EgovPropertyService, ApplicationContextAware, InitializingBean, DisposableBean, ResourceLoaderAware { private static final Logger LOGGER = LoggerFactory.getLogger(EgovPropertyServiceImpl.class); - private ExtendedProperties egovProperties = null; - private ResourceLoader resourceLoader = null; - + private PropertiesConfiguration egovProperties; + private ResourceLoader resourceLoader; private MessageSource messageSource; private Set> extFileName; private Map, ?> properties; @@ -204,39 +211,11 @@ public String[] getStringArray(String name) { return getConfiguration().getStringArray(name); } - /** - * Vector 타입의 프로퍼티 값 얻기 - * @param name 프로퍼티키 - * @return Vector 타입의 값 - */ - public Vector> getVector(String name) { - return getConfiguration().getVector(name); - } - - /** - * Vector 타입의 프로퍼티 값 얻기 - * @param name 프로퍼티키 - * @param def 디폴트 값 - * @return Vector 타입의 값 - */ - public Vector> getVector(String name, Vector> def) { - return getConfiguration().getVector(name, def); - } - - /** - * 전체 키/값 쌍 얻기 - * @return Vector 타입의 값 - */ - @SuppressWarnings("unchecked") - public Collection- * NOTE: 전체 키쌍 제공 여부 확인 - * @author 실행환경 개발팀 김태호 - * @since 2009.02.01 - * @version 1.0 - * @see
- * == 개정이력(Modification Information) == - * - * 수정일 수정자 수정내용 - * ------- -------- --------------------------- - * 2009.02.01 김태호 최초 생성 - * - *- */ -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = {"classpath*:/spring/context-common.xml", - "classpath*:/spring/context-properties.xml" }) -public class PropertyServiceAllKeyValGetTest extends AbstractJUnit4SpringContextTests { - - @Resource(name = "propertyService") - protected EgovPropertyService propertyService = null; - - /** - * 전체 키/값 쌍 제공 - * @throws Exception - * fail to test - */ - @Test - public void testGetAllKeyValue() throws Exception { - - Collection> collectionKeyValue = propertyService.getAllKeyValue(); - assertEquals(15, collectionKeyValue.size()); - - } -} diff --git a/Foundation/org.egovframe.rte.fdl.property/src/test/java/org/egovframe/rte/fdl/property/PropertyServiceBasicTest.java b/Foundation/org.egovframe.rte.fdl.property/src/test/java/org/egovframe/rte/fdl/property/PropertyServiceBasicTest.java index def3cc21..1eab9b53 100644 --- a/Foundation/org.egovframe.rte.fdl.property/src/test/java/org/egovframe/rte/fdl/property/PropertyServiceBasicTest.java +++ b/Foundation/org.egovframe.rte.fdl.property/src/test/java/org/egovframe/rte/fdl/property/PropertyServiceBasicTest.java @@ -3,11 +3,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.annotation.Resource; -import java.util.Vector; import static org.junit.Assert.*; @@ -26,55 +24,45 @@ * */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = {"classpath*:/spring/context-common.xml", - "classpath*:/spring/context-properties.xml" }) -public class PropertyServiceBasicTest extends AbstractJUnit4SpringContextTests { +@ContextConfiguration(locations = { + "classpath*:/spring/context-common.xml", + "classpath*:/spring/context-properties.xml" +}) +public class PropertyServiceBasicTest { @Resource(name = "propertyService") protected EgovPropertyService propertyService; /** * 기본 처리 테스트 - * @throws Exception - * fail to test + * @throws Exception fail to test */ @Test public void testPropertiesService() throws Exception { + assertEquals("안녕하세요.", propertyService.getString("greet.message")); + assertNotNull(propertyService.getString("tokens_on_multiple_lines")); assertEquals("1234", propertyService.getString("AAAA")); - assertEquals(new Double(1234), new Double(propertyService - .getDouble("number.double"))); - - assertEquals(new Float(1234), new Float(propertyService - .getFloat("number.float"))); - - assertEquals(new Integer(1234), new Integer(propertyService - .getInt("number.int"))); + assertEquals(new Double(1234), new Double(propertyService.getDouble("number.double"))); - assertEquals(new Long(1234), new Long(propertyService - .getLong("number.long"))); + assertEquals(new Float(1234), new Float(propertyService.getFloat("number.float"))); - assertEquals(2, propertyService.getVector("tokens_on_a_line").size()); + assertEquals(new Integer(1234), new Integer(propertyService.getInt("number.int"))); - assertEquals(0, propertyService.getVector("notexist_tokens_on_a_line", - new Vector
* 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2014.03.12 한성곤 Spring Security 설정 간소화 기능 추가 - * 2020.05.27 Egovframework Center CSRF Access Denied 처리 URL 추가 + * 2014.03.12 한성곤 Spring Security 설정 간소화 기능 추가 + * 2020.05.27 ESFC CSRF Access Denied 처리 URL 추가 + * 2023.08.31 ESFC Spring 표현 언어(SpEL) 설정 옵션 추가 **/ public class EgovSecurityConfigBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { @@ -46,6 +47,7 @@ protected Class> getBeanClass(Element element) { @Override protected void doParse(Element element, BeanDefinitionBuilder bean) { + String loginUrl = element.getAttribute("loginUrl"); if (StringUtils.hasText(loginUrl)) { bean.addPropertyValue("loginUrl", loginUrl); @@ -124,13 +126,19 @@ protected void doParse(Element element, BeanDefinitionBuilder bean) { String alwaysUseDefaultTargetUrl = element.getAttribute("alwaysUseDefaultTargetUrl"); if (StringUtils.hasText(alwaysUseDefaultTargetUrl)) { bean.addPropertyValue("alwaysUseDefaultTargetUrl", alwaysUseDefaultTargetUrl); - EgovSecurityConfigShare.alwaysUseDefaultTargetUrl = Boolean.valueOf(alwaysUseDefaultTargetUrl); + EgovSecurityConfigShare.alwaysUseDefaultTargetUrl = Boolean.parseBoolean(alwaysUseDefaultTargetUrl); + } + + String useExpressions = element.getAttribute("useExpressions"); + if (StringUtils.hasText(useExpressions)) { + bean.addPropertyValue("useExpressions", useExpressions); + EgovSecurityConfigShare.useExpressions = Boolean.parseBoolean(useExpressions); } String sniff = element.getAttribute("sniff"); if (StringUtils.hasText(sniff)) { bean.addPropertyValue("sniff", sniff); - EgovSecurityConfigShare.sniff = Boolean.valueOf(sniff); + EgovSecurityConfigShare.sniff = Boolean.parseBoolean(sniff); } String xFrameOptions = element.getAttribute("xframeOptions"); @@ -142,25 +150,26 @@ protected void doParse(Element element, BeanDefinitionBuilder bean) { String xssProtection = element.getAttribute("xssProtection"); if (StringUtils.hasText(xssProtection)) { bean.addPropertyValue("xssProtection", xssProtection); - EgovSecurityConfigShare.xssProtection = Boolean.valueOf(xssProtection); + EgovSecurityConfigShare.xssProtection = Boolean.parseBoolean(xssProtection); } String cacheControl = element.getAttribute("cacheControl"); if (StringUtils.hasText(cacheControl)) { bean.addPropertyValue("cacheControl", cacheControl); - EgovSecurityConfigShare.cacheControl = Boolean.valueOf(cacheControl); + EgovSecurityConfigShare.cacheControl = Boolean.parseBoolean(cacheControl); } String csrf = element.getAttribute("csrf"); if (StringUtils.hasText(csrf)) { bean.addPropertyValue("csrf", csrf); - EgovSecurityConfigShare.csrf = Boolean.valueOf(csrf); + EgovSecurityConfigShare.csrf = Boolean.parseBoolean(csrf); } String csrfAccessDeniedUrl = element.getAttribute("csrfAccessDeniedUrl"); if (StringUtils.hasText(csrfAccessDeniedUrl)) { bean.addPropertyValue("csrfAccessDeniedUrl", csrfAccessDeniedUrl); } + } -} \ No newline at end of file +} diff --git a/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityConfigInitializerBeanDefinitionParser.java b/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityConfigInitializerBeanDefinitionParser.java index d98b0086..403331d2 100644 --- a/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityConfigInitializerBeanDefinitionParser.java +++ b/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityConfigInitializerBeanDefinitionParser.java @@ -36,24 +36,25 @@ * * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2014.03.12 한성곤 Spring Security 설정 간소화 기능 추가 - * 2017.07.03 장동한 Spring Security 4.x 업그레이드(보안설정기능) 추가 + * 2014.03.12 한성곤 Spring Security 설정 간소화 기능 추가 + * 2017.07.03 장동한 Spring Security 4.x 업그레이드(보안설정기능) 추가 + * 2023.08.31 ESFC Spring 표현 언어(SpEL) 설정 옵션 추가 * */ public class EgovSecurityConfigInitializerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { - + private static final Logger LOGGER = LoggerFactory.getLogger(EgovSecurityConfigInitializerBeanDefinitionParser.class); @Override protected Class> getBeanClass(Element element) { return SecurityConfigInitializer.class; } - + @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { - + LOGGER.debug("Load '/META-INF/spring/security/security-config.xml'"); - + parserContext.getReaderContext().getReader().loadBeanDefinitions("classpath*:/META-INF/spring/security/security-config.xml"); EgovSecurityHttp egovSecurityHttp = EgovSecurityHttp.getInstance(); @@ -62,20 +63,21 @@ protected void doParse(Element element, ParserContext parserContext, BeanDefinit LOGGER.debug("EgovSecurityConfigInitializerBeanDefinitionParser httpd load start..."); /** * EgovSecurityHttp.getHttp - * @param Sniff : 응답에 대한 브라우저의 MIME 가로채기를 방지 옵션(활성:true, 비활성:false) - * @param XFrameOptions : 프레임셋 동작여부 옵션(DENY:거부, SAMEORIGIN:허용) - * @param XssProtection : 브라우저가 XSS 공격에 사용될 수 있는 스크립트를 실행하지 않음 옵션(활성:true, 비활성:false) - * @param Csrf : HTTP 요청과 악의적 인 웹 사이트의 요청을 거부 옵션(활성:true, 비활성:false) - * @param CacheControl : 브라우저 캐시를 수동으로 제어하기 위한 설정(캐시비활성:true, 캐시활성:false) + * @param useExpressions : Spring 표현 언어(SpEL) 설정 옵션(활성:true, 비활성:false) + * @param sniff : 응답에 대한 브라우저의 MIME 가로채기를 방지 옵션(활성:true, 비활성:false) + * @param xFrameOptions : 프레임셋 동작여부 옵션(DENY:거부, SAMEORIGIN:허용) + * @param xssProtection : 브라우저가 XSS 공격에 사용될 수 있는 스크립트를 실행하지 않음 옵션(활성:true, 비활성:false) + * @param cacheControl : 브라우저 캐시를 수동으로 제어하기 위한 설정(캐시비활성:true, 캐시활성:false) + * @param csrf : HTTP 요청과 악의적 인 웹 사이트의 요청을 거부 옵션(활성:true, 비활성:false) * @return InputStreamResource */ parserContext.getReaderContext().getReader().loadBeanDefinitions(egovSecurityHttp.getHttp( + EgovSecurityConfigShare.useExpressions, EgovSecurityConfigShare.sniff, EgovSecurityConfigShare.xFrameOptions, EgovSecurityConfigShare.xssProtection, EgovSecurityConfigShare.cacheControl, EgovSecurityConfigShare.csrf )); - parserContext.getReaderContext().getReader().setValidationMode(XmlBeanDefinitionReader.VALIDATION_AUTO); } catch(IllegalArgumentException e) { LOGGER.error("[["+e.getClass()+"/IllegalArgumentException] Try/Catch... Runing : "+ e.getMessage()); @@ -92,7 +94,7 @@ protected void doParse(Element element, ParserContext parserContext, BeanDefinit LOGGER.debug("Load '/META-INF/spring/security/pointcut-config.xml'"); parserContext.getReaderContext().getReader().loadBeanDefinitions("classpath*:/META-INF/spring/security/pointcut-config.xml"); } - + String supportMethod = element.getAttribute("supportMethod"); if (supportMethod.equalsIgnoreCase("true")) { LOGGER.debug("Load '/META-INF/spring/security/method-config.xml'"); diff --git a/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityConfigShare.java b/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityConfigShare.java index 526aadaa..e5fced1e 100644 --- a/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityConfigShare.java +++ b/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityConfigShare.java @@ -28,13 +28,16 @@ * * 수정일 수정자 수정내용 * --------------------------------------------- - * 2014.03.12 장동한 SpringSecurity 4.x 업그레이드 추가 + * 2014.03.12 장동한 SpringSecurity 4.x 업그레이드 추가 + * 2023.08.31 ESFC Spring 표현 언어(SpEL) 설정 옵션 추가 * */ public class EgovSecurityConfigShare { public static boolean alwaysUseDefaultTargetUrl = true; + public static boolean useExpressions = false; + public static boolean sniff = true; public static String xFrameOptions = "SAMEORIGIN"; diff --git a/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityHttp.java b/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityHttp.java index b6f3a9f3..d37a52c0 100644 --- a/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityHttp.java +++ b/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/EgovSecurityHttp.java @@ -20,6 +20,7 @@ import org.springframework.core.io.InputStreamResource; import java.io.ByteArrayInputStream; +import java.nio.charset.StandardCharsets; /** * egov-security http create @@ -34,8 +35,9 @@ * * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2014.03.12 장동한 SpringSecurity 4.x 업그레이드 추가 - * 2020.05.27 ESFC CSRF Access Denied handler 설정 추가 + * 2014.03.12 장동한 SpringSecurity 4.x 업그레이드 추가 + * 2020.05.27 ESFC CSRF Access Denied handler 설정 추가 + * 2023.08.31 ESFC Spring 표현 언어(SpEL) 설정 옵션 추가 * */ public class EgovSecurityHttp { @@ -55,87 +57,84 @@ public synchronized static EgovSecurityHttp getInstance() { /** * egov-security http bean의 xml string 를 생성 + * @param useExpressions : Spring 표현 언어(SpEL) 설정 옵션(활성:true, 비활성:false) * @param Sniff : 응답에 대한 브라우저의 MIME 가로채기를 방지 옵션(활성:true, 비활성:false) * @param XFrameOptions : 프레임셋 동작여부 옵션(DENY:거부, SAMEORIGIN:허용) * @param XssProtection : 브라우저가 XSS 공격에 사용될 수 있는 스크립트를 실행하지 않음 옵션(활성:true, 비활성:false) + * @param CacheControl : 브라우저 캐시를 수동으로 제어하기 위한 설정(캐시비활성:true, 캐시활성:false) * @param Csrf : HTTP 요청과 악의적 인 웹 사이트의 요청을 거부 옵션(활성:true, 비활성:false) * @return InputStreamResource - * @throws Exception */ public InputStreamResource getHttp( - boolean Sniff, - String XFrameOptions, - boolean XssProtection, - boolean CacheControl, - boolean Csrf) throws Exception { - - String sHttp = - "\n" + - "
* 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2014.03.12 한성곤 Spring Security 설정 간소화 기능 추가 - * 2017.07.03 장동한 Spring Security 4.x 업그레이드(보안설정기능) 추가 - * 2020.05.27 Egovframework Center CSRF Access Denied 처리 URL 추가 + * 2014.03.12 한성곤 Spring Security 설정 간소화 기능 추가 + * 2017.07.03 장동한 Spring Security 4.x 업그레이드(보안설정기능) 추가 + * 2020.05.27 ESFC CSRF Access Denied 처리 URL 추가 + * 2023.08.31 ESFC Spring 표현 언어(SpEL) 설정 옵션 추가 **/ public class SecurityConfig { @@ -48,14 +49,15 @@ public class SecurityConfig { private String jdbcUsersByUsernameQuery = DEF_USERS_BY_USERNAME_QUERY_SQL; private String jdbcAuthoritiesByUsernameQuery = DEF_AUTHORITIES_BY_USERNAME_QUERY_SQL; private String jdbcMapClass = "org.egovframe.rte.fdl.security.userdetails.DefaultMapUserDetailsMapping"; - private String requestMatcherType = "regex"; // regex, ant, ciRegex (case-insensitive) - private String hash = "sha-256"; // hashing algorithm - private boolean hashBase64 = true; // default = true + private String requestMatcherType = "regex"; + private String hash = "sha-256"; + private boolean hashBase64 = true; private int concurrentMaxSessons; private String concurrentExpiredUrl; private boolean errorIfMaximumExceeded; private String defaultTargetUrl; private boolean alwaysUseDefaultTargetUrl; + private boolean useExpressions; private boolean sniff; private String xframeOptions; private boolean xssProtection; @@ -179,7 +181,9 @@ public void setDefaultTargetUrl(String defaultTargetUrl) { public boolean isAlwaysUseDefaultTargetUrl() { return alwaysUseDefaultTargetUrl; } - public void setAlwaysUseDefaultTargetUrl(boolean alwaysUseDefaultTargetUrl) { this.alwaysUseDefaultTargetUrl = alwaysUseDefaultTargetUrl; } + public void setAlwaysUseDefaultTargetUrl(boolean alwaysUseDefaultTargetUrl) { + this.alwaysUseDefaultTargetUrl = alwaysUseDefaultTargetUrl; + } public boolean isHashBase64() { return hashBase64; @@ -188,7 +192,15 @@ public boolean isHashBase64() { public void setHashBase64(boolean hashBase64) { this.hashBase64 = hashBase64; } - + + public boolean isUseExpression() { + return useExpressions; + } + + public void setUseExpressions(boolean useExpressions) { + this.useExpressions = useExpressions; + } + public boolean isSniff() { return sniff; } diff --git a/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/internal/CsrfAccessDeniedUrlFactoryBean.java b/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/internal/CsrfAccessDeniedUrlFactoryBean.java index c2f82142..058c6b9b 100644 --- a/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/internal/CsrfAccessDeniedUrlFactoryBean.java +++ b/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/config/internal/CsrfAccessDeniedUrlFactoryBean.java @@ -29,15 +29,15 @@ * *
Desc.: 설정 간소화 처리에 사용되는 내부 factory bean
* - * @author Egovframework Center + * @author ESFC * @since 2020.05.27 * @version 3.10 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2020.05.27 Egovframework Center 최초 생성 + * 2020.05.27 ESFC 최초 생성 **/ public class CsrfAccessDeniedUrlFactoryBean implements FactoryBean
Desc.: 설정 간소화 처리에 사용되는 내부 factory bean
* - * @author Egovframework Center + * @author ESFC * @since 2020.08.31 * @version 3.10 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2020.08.31 Egovframework Center 최초 생성 + * 2020.08.31 ESFC 최초 생성 * **/ diff --git a/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/intercept/CsrfAccessDeniedHandler.java b/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/intercept/CsrfAccessDeniedHandler.java index f32cb5e4..7223078c 100644 --- a/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/intercept/CsrfAccessDeniedHandler.java +++ b/Foundation/org.egovframe.rte.fdl.security/src/main/java/org/egovframe/rte/fdl/security/intercept/CsrfAccessDeniedHandler.java @@ -18,15 +18,15 @@ * *
Desc.: CSRF 사용 시 token 이 없거나(InvalidCsrfTokenException) 잘못된 경우(MissingCsrfTokenException) Access Denied URL 로 넘김
* - * @author Egovframework Center + * @author ESFC * @since 2020.05.27 * @version 3.10 ** 개정이력(Modification Information) * - * 수정일 수정자 수정내용 + * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2020.05.27 Egovframework Center 최초 생성 + * 2020.05.27 ESFC 최초 생성 **/ public class CsrfAccessDeniedHandler implements AccessDeniedHandler { diff --git a/Foundation/org.egovframe.rte.fdl.security/src/main/resources/META-INF/spring.schemas b/Foundation/org.egovframe.rte.fdl.security/src/main/resources/META-INF/spring.schemas index 7ac0a48b..e1cb135c 100644 --- a/Foundation/org.egovframe.rte.fdl.security/src/main/resources/META-INF/spring.schemas +++ b/Foundation/org.egovframe.rte.fdl.security/src/main/resources/META-INF/spring.schemas @@ -1,2 +1,2 @@ -http\://maven.egovframe.go.kr/schema/egov-security/egov-security.xsd=org/egovframe/rte/fdl/security/config/egov-security-4.1.0.xsd -http\://maven.egovframe.go.kr/schema/egov-security/egov-security-4.1.0.xsd=org/egovframe/rte/fdl/security/config/egov-security-4.1.0.xsd +http\://maven.egovframe.go.kr/schema/egov-security/egov-security.xsd=org/egovframe/rte/fdl/security/config/egov-security-4.2.0.xsd +http\://maven.egovframe.go.kr/schema/egov-security/egov-security-4.2.0.xsd=org/egovframe/rte/fdl/security/config/egov-security-4.2.0.xsd diff --git a/Foundation/org.egovframe.rte.fdl.security/src/main/resources/org/egovframe/rte/fdl/security/config/egov-security-4.1.0.xsd b/Foundation/org.egovframe.rte.fdl.security/src/main/resources/org/egovframe/rte/fdl/security/config/egov-security-4.2.0.xsd similarity index 96% rename from Foundation/org.egovframe.rte.fdl.security/src/main/resources/org/egovframe/rte/fdl/security/config/egov-security-4.1.0.xsd rename to Foundation/org.egovframe.rte.fdl.security/src/main/resources/org/egovframe/rte/fdl/security/config/egov-security-4.2.0.xsd index 2ea83b08..44ecb4e5 100644 --- a/Foundation/org.egovframe.rte.fdl.security/src/main/resources/org/egovframe/rte/fdl/security/config/egov-security-4.1.0.xsd +++ b/Foundation/org.egovframe.rte.fdl.security/src/main/resources/org/egovframe/rte/fdl/security/config/egov-security-4.2.0.xsd @@ -109,6 +109,11 @@ when you move, and to request back to the url you previously requested +
@@ -818,4 +813,5 @@ public static String toString(Date date, String format, Locale locale) { String tmp = sdf.format(date); return tmp; } + } diff --git a/Foundation/org.egovframe.rte.fdl.string/src/main/java/org/egovframe/rte/fdl/string/EgovNumericUtil.java b/Foundation/org.egovframe.rte.fdl.string/src/main/java/org/egovframe/rte/fdl/string/EgovNumericUtil.java index ffaa909d..f0781659 100644 --- a/Foundation/org.egovframe.rte.fdl.string/src/main/java/org/egovframe/rte/fdl/string/EgovNumericUtil.java +++ b/Foundation/org.egovframe.rte.fdl.string/src/main/java/org/egovframe/rte/fdl/string/EgovNumericUtil.java @@ -20,7 +20,7 @@ /** * 숫자의 연산을 처리하는 유틸 클래스 - * + * *
NOTE: 숫자와 관련된 여러 기능을 제공하는 유틸이다. 숫자의 연산 및 올림, 내림 등의 기능을 제공한다.
** ----------------------------------------------------------------------- @@ -34,7 +34,7 @@ * ROUND_UP : 무조건 올림 * ROUND_CEILING : 무조건 올림 (음수일 경우에 무조건 내림) *- * + * * @author 실행환경 개발팀 윤성종 * @since 2009.06.01 * @version 1.0 @@ -43,46 +43,47 @@ * * 수정일 수정자 수정내용 * ---------------------------------------------- - * 2009.06.01 윤성종 최초 생성 + * 2009.06.01 윤성종 최초 생성 + * 2023.08.31 ESFC 숫자 반올림/올림/내림에 RoundingMode 적용(Contribution 반영) * */ public class EgovNumericUtil { - /** - * 올림 - */ - public static final RoundingMode ROUND_UP = RoundingMode.UP; + /** + * 올림 + */ + public static final RoundingMode ROUND_UP = RoundingMode.UP; - /** - * 내림(절사) - */ - public static final RoundingMode ROUND_DOWN = RoundingMode.DOWN; + /** + * 내림(절사) + */ + public static final RoundingMode ROUND_DOWN = RoundingMode.DOWN; - /** - * 반올림 - */ - public static final RoundingMode ROUND_HALF_UP = RoundingMode.HALF_UP; + /** + * 반올림 + */ + public static final RoundingMode ROUND_HALF_UP = RoundingMode.HALF_UP; - /** - * 사용하지 않음 - */ - public static final RoundingMode ROUND_UNNECESSARY = RoundingMode.UNNECESSARY; + /** + * 사용하지 않음 + */ + public static final RoundingMode ROUND_UNNECESSARY = RoundingMode.UNNECESSARY; - /** - *
- * NumericHelper의 default 컨스트럭터(Constructor). - *
- */ - protected EgovNumericUtil() { - } + /** + *+ * NumericHelper의 default 컨스트럭터(Constructor). + *
+ */ + protected EgovNumericUtil() { + } - /** - *- * 문자열의 Number형 문자열인지 여부 (- 기호나 소수점도 포함) - *
- * @param source 검증 하고자 하는 문자열 - * @return 숫자형 문자열 여부 (true : 숫자형) - */ + /** + *+ * 문자열의 Number형 문자열인지 여부 (- 기호나 소수점도 포함) + *
+ * @param source 검증 하고자 하는 문자열 + * @return 숫자형 문자열 여부 (true : 숫자형) + */ public static boolean isNumber(String source) { if (EgovStringUtil.isNull(source)) { return false; @@ -96,16 +97,16 @@ public static boolean isNumber(String source) { } } - /** - *- * String형 값의 기본덧셈을 실행한다. - *
- * @param thisValString
- * @param addVal String
- * @return 결과 값
- * @see #plus(String, String, int)
- * @see #plus(String, String, int, RoundingMode)
- */
+ /**
+ * + * String형 값의 기본덧셈을 실행한다. + *
+ * @param thisValString
+ * @param addVal String
+ * @return 결과 값
+ * @see #plus(String, String, int)
+ * @see #plus(String, String, int, RoundingMode)
+ */
public static String plus(String thisVal, String addVal) {
String result = null;
BigDecimal one = new BigDecimal(thisVal == null ? "0" : thisVal);
@@ -114,36 +115,36 @@ public static String plus(String thisVal, String addVal) {
return result;
}
- /**
- * - * 덧셈한 결과값의 소숫점 자릿수만 지정한다. - *
- * @param thisValString
- * @param addVal String
- * @param scale int
자리수지정
- * @return 결과 값
- * @see #plus(String, String, int, RoundingMode)
- * @see #plus(String, String)
- */
- public static String plus(String thisVal, String addVal, int scale) {
- return plus(thisVal, addVal, scale, ROUND_UNNECESSARY);
- }
+ /**
+ * + * 덧셈한 결과값의 소숫점 자릿수만 지정한다. + *
+ * @param thisValString
+ * @param addVal String
+ * @param scale int
자리수지정
+ * @return 결과 값
+ * @see #plus(String, String, int, RoundingMode)
+ * @see #plus(String, String)
+ */
+ public static String plus(String thisVal, String addVal, int scale) {
+ return plus(thisVal, addVal, scale, ROUND_UNNECESSARY);
+ }
- /**
- * - * 덧셈한 결과값의 자릿수와 올림,내림,절삭여부 지정한다. - *
- * @param thisValString
- * @param addVal String
- * @param scale int
자리수지정
- * @param roundMode RoundingMode
Round 여부 + * 덧셈한 결과값의 자릿수와 올림,내림,절삭여부 지정한다. + *
+ * @param thisValString
+ * @param addVal String
+ * @param scale int
자리수지정
+ * @param roundMode RoundingMode
Round 여부 - * 기본뺄셈을 실행한다. - *
- * @param thisValString
- * @param addVal String
- * @return 결과 값
- * @see #minus(String, String, int)
- * @see #minus(String, String, int, RoundingMode)
- */
+ /**
+ * + * 기본뺄셈을 실행한다. + *
+ * @param thisValString
+ * @param addVal String
+ * @return 결과 값
+ * @see #minus(String, String, int)
+ * @see #minus(String, String, int, RoundingMode)
+ */
public static String minus(String thisVal, String addVal) {
String result = null;
BigDecimal one = new BigDecimal(thisVal == null ? "0" : thisVal);
@@ -170,36 +171,36 @@ public static String minus(String thisVal, String addVal) {
return result;
}
- /**
- * - * 뺄셈한 결과값의 자릿수만 지정한다. - *
- * @param thisValString
- * @param addVal String
- * @param scale int
자리수지정
- * @return 결과 값
- * @see #minus(String, String, int, RoundingMode)
- * @see #minus(String, String)
- */
- public static String minus(String thisVal, String addVal, int scale) {
- return minus(thisVal, addVal, scale, ROUND_UNNECESSARY);
- }
+ /**
+ * + * 뺄셈한 결과값의 자릿수만 지정한다. + *
+ * @param thisValString
+ * @param addVal String
+ * @param scale int
자리수지정
+ * @return 결과 값
+ * @see #minus(String, String, int, RoundingMode)
+ * @see #minus(String, String)
+ */
+ public static String minus(String thisVal, String addVal, int scale) {
+ return minus(thisVal, addVal, scale, ROUND_UNNECESSARY);
+ }
- /**
- * - * 뺄셈한 결과값의 자릿수와 올림,내림,절삭여부 지정한다. - *
- * @param thisValString
- * @param addVal String
- * @param scale int
자리수지정
- * @param roundMode RoundingMode
Round 여부 + * 뺄셈한 결과값의 자릿수와 올림,내림,절삭여부 지정한다. + *
+ * @param thisValString
+ * @param addVal String
+ * @param scale int
자리수지정
+ * @param roundMode RoundingMode
Round 여부 - * 기본곱셈을 실행한다. - *
- * @param thisValString
- * @param addVal String
- * @return 결과 값
- * @see #multiply(String, String, int)
- * @see #multiply(String, String, int, RoundingMode)
- */
- public static String multiply(String thisVal, String addVal) {
- String result = null;
- BigDecimal one = new BigDecimal(thisVal == null ? "0" : thisVal);
- BigDecimal two = new BigDecimal(addVal == null ? "0" : addVal);
- result = one.multiply(two).toString();
- return result;
- }
+ /**
+ * + * 기본곱셈을 실행한다. + *
+ * @param thisValString
+ * @param addVal String
+ * @return 결과 값
+ * @see #multiply(String, String, int)
+ * @see #multiply(String, String, int, RoundingMode)
+ */
+ public static String multiply(String thisVal, String addVal) {
+ String result = null;
+ BigDecimal one = new BigDecimal(thisVal == null ? "0" : thisVal);
+ BigDecimal two = new BigDecimal(addVal == null ? "0" : addVal);
+ result = one.multiply(two).toString();
+ return result;
+ }
- /**
- * - * 곱셈한 결과값의 자릿수만 지정한다. - *
- * @param thisValString
- * @param addVal String
- * @param scale int
자리수지정
- * @return 결과 값
- * @see #multiply(String, String, int, RoundingMode)
- * @see #multiply(String, String)
- */
- public static String multiply(String thisVal, String addVal, int scale) {
- return multiply(thisVal, addVal, scale, ROUND_UNNECESSARY);
- }
+ /**
+ * + * 곱셈한 결과값의 자릿수만 지정한다. + *
+ * @param thisValString
+ * @param addVal String
+ * @param scale int
자리수지정
+ * @return 결과 값
+ * @see #multiply(String, String, int, RoundingMode)
+ * @see #multiply(String, String)
+ */
+ public static String multiply(String thisVal, String addVal, int scale) {
+ return multiply(thisVal, addVal, scale, ROUND_UNNECESSARY);
+ }
- /**
- * - * 곱셈한 결과값의 자릿수와 올림,내림,절삭여부 지정한다. - *
- * @param thisValString
- * @param addVal String
- * @param scale int
자리수지정
- * @param roundMode RoundingMode
Round 여부 + * 곱셈한 결과값의 자릿수와 올림,내림,절삭여부 지정한다. + *
+ * @param thisValString
+ * @param addVal String
+ * @param scale int
자리수지정
+ * @param roundMode RoundingMode
Round 여부 - * 기본나눗셈을 실행한다. - *
- * @param thisValString
- * @param addVal String
- * @return 결과 값
- * @see #divide(String, String, RoundingMode)
- * @see #divide(String, String, int, RoundingMode)
- */
- public static String divide(String thisVal, String addVal) {
- String result = null;
- BigDecimal one = new BigDecimal(thisVal == null ? "0" : thisVal);
- BigDecimal two = new BigDecimal(addVal == null ? "0" : addVal);
- result = one.divide(two).toString();
- return result;
- }
+ /**
+ * + * 기본나눗셈을 실행한다. + *
+ * @param thisValString
+ * @param addVal String
+ * @return 결과 값
+ * @see #divide(String, String, RoundingMode)
+ * @see #divide(String, String, int, RoundingMode)
+ */
+ public static String divide(String thisVal, String addVal) {
+ String result = null;
+ BigDecimal one = new BigDecimal(thisVal == null ? "0" : thisVal);
+ BigDecimal two = new BigDecimal(addVal == null ? "0" : addVal);
+ result = one.divide(two).toString();
+ return result;
+ }
- /**
- * - * 나눗셈의 결과값이 정수 - *
- * @param thisValString
- * @param addVal String
- * @param roundMode RoundingMode
Round 여부 + * 나눗셈의 결과값이 정수 + *
+ * @param thisValString
+ * @param addVal String
+ * @param roundMode RoundingMode
Round 여부 - * 나눗셈 결과값의 자릿수와 올림,내림,절삭여부 지정한다 - *
- * @param thisValString
- * @param addVal String
- * @param scale int
자리수지정
- * @param roundMode RoundingMode
Round 여부 + * 나눗셈 결과값의 자릿수와 올림,내림,절삭여부 지정한다 + *
+ * @param thisValString
+ * @param addVal String
+ * @param scale int
자리수지정
+ * @param roundMode int
Round 여부 - * 기본값을 scale 자릿수만큼 ROUND한다. - *
- * @param thisValString
- * @param scale int
자리수지정
- * @param roundMode RoundingMode
Round 여부 + * 기본값을 scale 자릿수만큼 ROUND한다. + *
+ * @param thisValString
+ * @param scale int
자리수지정
+ * @param roundMode RoundingMode
Round 여부 * 문자열의 뒷쪽에 지정한 길이만큼 공백으로 채움 - *
- * @param str - * @param length - * @param isEllipsis - * @return */ public static String alignLeft(String str, int length, boolean isEllipsis) { - if (str.length() <= length) { - StringBuffer temp = new StringBuffer(str); + StringBuilder result = new StringBuilder(str); + if (str.length() <= length) { for (int i = 0; i < (length - str.length()); i++) { - temp.append(WHITE_SPACE); + result.append(WHITE_SPACE); } - return temp.toString(); + return result.toString(); } else { if (isEllipsis) { - StringBuffer temp = new StringBuffer(length); - temp.append(str.substring(0, length - 3)); - temp.append("..."); - return temp.toString(); + result.append(str, 0, length - 3); + result.append("..."); + return result.toString(); } else { return str.substring(0, length); } @@ -516,9 +404,6 @@ public static String alignLeft(String str, int length, boolean isEllipsis) { /** * alignRight - * @param str - * @param length - * @return */ public static String alignRight(String str, int length) { return alignRight(str, length, false); @@ -526,25 +411,20 @@ public static String alignRight(String str, int length) { /** * alignRight - * @param str - * @param length - * @param isEllipsis - * @return */ public static String alignRight(String str, int length, boolean isEllipsis) { - if (str.length() <= length) { - StringBuffer temp = new StringBuffer(length); + StringBuilder result = new StringBuilder(length); + if (str.length() <= length) { for (int i = 0; i < (length - str.length()); i++) { - temp.append(WHITE_SPACE); + result.append(WHITE_SPACE); } - temp.append(str); - return temp.toString(); + result.append(str); + return result.toString(); } else { if (isEllipsis) { - StringBuffer temp = new StringBuffer(length); - temp.append(str.substring(0, length - 3)); - temp.append("..."); - return temp.toString(); + result.append(str, 0, length - 3); + result.append("..."); + return result.toString(); } else { return str.substring(0, length); } @@ -553,9 +433,6 @@ public static String alignRight(String str, int length, boolean isEllipsis) { /** * alignCenter - * @param str - * @param length - * @return */ public static String alignCenter(String str, int length) { return alignCenter(str, length, false); @@ -563,15 +440,11 @@ public static String alignCenter(String str, int length) { /** * alignCenter - * @param str - * @param length - * @param isEllipsis - * @return */ public static String alignCenter(String str, int length, boolean isEllipsis) { - if (str.length() <= length) { - StringBuffer temp = new StringBuffer(length); - int leftMargin = (int) (length - str.length()) / 2; + StringBuilder result = new StringBuilder(length); + if (str.length() <= length) { + int leftMargin = (length - str.length()) / 2; int rightMargin; if ((leftMargin * 2) == (length - str.length())) { rightMargin = leftMargin; @@ -579,19 +452,18 @@ public static String alignCenter(String str, int length, boolean isEllipsis) { rightMargin = leftMargin + 1; } for (int i = 0; i < leftMargin; i++) { - temp.append(WHITE_SPACE); + result.append(WHITE_SPACE); } - temp.append(str); + result.append(str); for (int i = 0; i < rightMargin; i++) { - temp.append(WHITE_SPACE); + result.append(WHITE_SPACE); } - return temp.toString(); + return result.toString(); } else { if (isEllipsis) { - StringBuffer temp = new StringBuffer(length); - temp.append(str.substring(0, length - 3)); - temp.append("..."); - return temp.toString(); + result.append(str, 0, length - 3); + result.append("..."); + return result.toString(); } else { return str.substring(0, length); } @@ -600,8 +472,6 @@ public static String alignCenter(String str, int length, boolean isEllipsis) { /** * capitalize - * @param str - * @return */ public static String capitalize(String str) { return !isNull(str) ? str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase() : str; @@ -609,12 +479,8 @@ public static String capitalize(String str) { /** * isPatternMatch - * @param str - * @param pattern - * @return - * @throws Exception */ - public static boolean isPatternMatch(String str, String pattern) throws Exception { + public static boolean isPatternMatch(String str, String pattern) { Matcher matcher = Pattern.compile(pattern).matcher(str); LOGGER.debug("{}", matcher); return matcher.matches(); @@ -622,35 +488,26 @@ public static boolean isPatternMatch(String str, String pattern) throws Exceptio /** * toEng - * @param kor - * @return - * @throws UnsupportedEncodingException - */ + */ public static String toEng(String kor) throws UnsupportedEncodingException { if (isNull(kor)) { return null; } - return new String(kor.getBytes("KSC5601"), "8859_1"); + return new String(kor.getBytes("KSC5601"), StandardCharsets.ISO_8859_1); } /** * toKor - * @param en - * @return - * @throws UnsupportedEncodingException */ public static String toKor(String en) throws UnsupportedEncodingException { if (isNull(en)) { return null; } - return new String(en.getBytes("8859_1"), "euc-kr"); + return new String(en.getBytes(StandardCharsets.ISO_8859_1), "euc-kr"); } /** * countOf - * @param str - * @param charToFind - * @return */ public static int countOf(String str, String charToFind) { int findLength = charToFind.length(); @@ -670,7 +527,7 @@ public static int countOf(String str, String charToFind) { */ public static String encodePassword(String password, String algorithm) { byte[] unencodedPassword = password.getBytes(); - MessageDigest md = null; + MessageDigest md; try { md = MessageDigest.getInstance(algorithm); @@ -683,16 +540,15 @@ public static String encodePassword(String password, String algorithm) { md.reset(); md.update(unencodedPassword); byte[] encodedPassword = md.digest(); - StringBuffer buf = new StringBuffer(); - - for (int i = 0; i < encodedPassword.length; i++) { - if (((int) encodedPassword[i] & 0xff) < 0x10) { - buf.append("0"); - } - buf.append(Long.toString((int) encodedPassword[i] & 0xff, 16)); - } + StringBuilder result = new StringBuilder(); + for (byte b : encodedPassword) { + if (((int) b & 0xff) < 0x10) { + result.append("0"); + } + result.append(Long.toString((int) b & 0xff, 16)); + } - return buf.toString(); + return result.toString(); } /** @@ -732,14 +588,14 @@ public static String decodeString(String str) { * @return String converting result */ public static String swapFirstLetterCase(String str) { - StringBuffer sbuf = new StringBuffer(str); - sbuf.deleteCharAt(0); + StringBuilder result = new StringBuilder(str); + result.deleteCharAt(0); if (Character.isLowerCase(str.substring(0, 1).toCharArray()[0])) { - sbuf.insert(0, str.substring(0, 1).toUpperCase()); + result.insert(0, str.substring(0, 1).toUpperCase()); } else { - sbuf.insert(0, str.substring(0, 1).toLowerCase()); + result.insert(0, str.substring(0, 1).toLowerCase()); } - return sbuf.toString(); + return result.toString(); } /** @@ -790,7 +646,7 @@ public static String getLastString(String origStr, String strToken) { * @return String[] */ public static String[] getStringArray(String str, String strToken) { - if (str.indexOf(strToken) != -1) { + if (str.contains(strToken)) { StringTokenizer st = new StringTokenizer(str, strToken); String[] stringArray = new String[st.countTokens()]; for (int i = 0; st.hasMoreTokens(); i++) { @@ -830,7 +686,7 @@ public static boolean isNotEmpty(String str) { * @return which empty string or not. */ public static boolean isEmpty(String str) { - return (str == null || str.length() == 0); + return (str == null || str.isEmpty()); } /** @@ -846,7 +702,7 @@ public static boolean isEmpty(String str) { */ public static String replace(String str, String replacedStr, String replaceStr) { String newStr = ""; - if (str.indexOf(replacedStr) != -1) { + if (str.contains(replacedStr)) { String s1 = str.substring(0, str.indexOf(replacedStr)); String s2 = str.substring(str.indexOf(replacedStr) + 1); newStr = s1 + replaceStr + s2; @@ -933,14 +789,13 @@ public static boolean containsInvalidChars(String str, char[] invalidChars) { return false; } int strSize = str.length(); - int validSize = invalidChars.length; for (int i = 0; i < strSize; i++) { char ch = str.charAt(i); - for (int j = 0; j < validSize; j++) { - if (invalidChars[j] == ch) { - return true; - } - } + for (char invalidChar : invalidChars) { + if (invalidChar == ch) { + return true; + } + } } return false; } @@ -1048,12 +903,12 @@ public static String fillString(String originalStr, char ch, int cipers) { return null; } int difference = cipers - originalStrLength; - StringBuffer strBuf = new StringBuffer(); + StringBuilder result = new StringBuilder(); for (int i = 0; i < difference; i++) { - strBuf.append(ch); + result.append(ch); } - strBuf.append(originalStr); - return strBuf.toString(); + result.append(originalStr); + return result.toString(); } /** @@ -1061,15 +916,15 @@ public static String fillString(String originalStr, char ch, int cipers) { * @param foo The text to check. * @return Whether empty. */ - public static final boolean isEmptyTrimmed(String foo) { - return (foo == null || foo.trim().length() == 0); + public static boolean isEmptyTrimmed(String foo) { + return (foo == null || foo.trim().isEmpty()); } /** * Return token list - * @param lst - * @param separator - * @return + * @param lst using commas as separators + * @param separator separators + * @return List result */ public static List