fix: logback 마스킹 설정 comment

main
Jonguk. Lim 2 years ago
parent a59fa237d5
commit e6c3de15ed

@ -385,12 +385,18 @@
<artifactId>tiles-jsp</artifactId>
<version>${org.apache.tiles.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>${org.apache.tiles.version}</version>
</dependency>
-->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>${org.apache.tiles.version}</version>
</dependency>
<!-- freemaker -->
<!--
@ -705,14 +711,6 @@
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>com.octo.captcha</groupId>
<artifactId>jcaptcha</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/repo/com/octo/captcha/1.0/jcaptcha-1.0.jar</systemPath>
</dependency>
</dependencies>
<build>

@ -1,155 +0,0 @@
package kr.xit.framework.support.captcha.ignore;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.Map;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.codec.binary.Base64InputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.octo.captcha.service.CaptchaServiceException;
//@Controller
@RequestMapping("captcha")
public class CaptchaController {
public static final Logger log = LoggerFactory.getLogger(CaptchaController.class);
//@Autowired
private MessageSourceAccessor messageSourceAccessor;
//@Autowired
private CaptchaService captchaService;
@RequestMapping(value="index", method=RequestMethod.GET)
public void index(@RequestParam Map<String, Object> paramMap, ModelMap modelMap) throws Exception {
log.debug("=========================================================================================");
log.debug("== paramMap : {}", paramMap);
log.debug("=========================================================================================");
modelMap.put("paramMap", paramMap);
}
@RequestMapping(value="jcaptcha", method=RequestMethod.GET)
public void jcaptcha(@RequestParam Map<String, Object> paramMap, ModelMap modelMap, HttpServletRequest request, HttpServletResponse response, HttpSession session) throws Exception {
byte[] captchaChallengeAsJpeg = null;
ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
try {
String captchaId = session.getId();
BufferedImage challenge = captchaService.getInstance().getImageChallengeForID(captchaId, request.getLocale());
//JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(jpegOutputStream);
//jpegEncoder.encode(challenge);
ImageIO.write(challenge, "jpg", jpegOutputStream);
} catch (IllegalArgumentException e) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
} catch (CaptchaServiceException e) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("image/jpeg");
ServletOutputStream responseOutputStream = response.getOutputStream();
responseOutputStream.write(captchaChallengeAsJpeg);
responseOutputStream.flush();
responseOutputStream.close();
}
@RequestMapping(value="jcaptchaImage.json")
public String jcaptchaImage(@RequestParam Map<String, Object> paramMap, ModelMap modelMap, HttpServletRequest request, HttpServletResponse response, HttpSession session) throws Exception {
byte[] captchaChallengeAsJpeg = null;
ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
try {
String captchaId = session.getId();
BufferedImage challenge = captchaService.getInstance().getImageChallengeForID(captchaId, request.getLocale());
//JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(jpegOutputStream);
//jpegEncoder.encode(challenge);
ImageIO.write(challenge, "jpg", jpegOutputStream);
} catch (IllegalArgumentException e) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
throw e;
} catch (CaptchaServiceException e) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
throw e;
}
BufferedInputStream bis = null;
ByteArrayOutputStream baos = null;
try {
captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
BufferedInputStream captchaBis = new BufferedInputStream(new ByteArrayInputStream(captchaChallengeAsJpeg));
Base64InputStream in = new Base64InputStream(captchaBis, true);
bis = new BufferedInputStream(in);
baos = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int read = 0;
while ((read = bis.read(buffer)) != -1) {
baos.write(buffer, 0, read);
}
modelMap.put("captchaCode", baos.toString());
} finally {
if(baos != null) {
baos.close();
}
if(bis != null) {
bis.close();
}
}
return "jsonView";
}
@RequestMapping(value="insert", method=RequestMethod.POST)
public String insert(@RequestParam Map<String, Object> paramMap, ModelMap modelMap, HttpServletRequest request, HttpSession session) throws Exception {
log.debug("=========================================================================================");
log.debug("== paramMap : {}", paramMap);
log.debug("=========================================================================================");
modelMap.put("paramMap", paramMap);
Boolean isResponseCorrect = Boolean.FALSE;
String captchaId = session.getId();
String jCaptchaResponse = (String)paramMap.get("j_captcha_response");
try {
isResponseCorrect = captchaService.getInstance().validateResponseForID(captchaId, jCaptchaResponse);
log.debug("isResponseCorrect : {}", isResponseCorrect);
} catch (CaptchaServiceException e) {
}
return "captcha/index";
}
}

@ -1,36 +0,0 @@
package kr.xit.framework.support.captcha.ignore;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import com.octo.captcha.service.captchastore.FastHashMapCaptchaStore;
import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;
import com.octo.captcha.service.image.ImageCaptchaService;
@Service
@Scope(value="singleton")
public class CaptchaService {
private final static ImageCaptchaService instance;
static {
instance = new DefaultManageableImageCaptchaService(new FastHashMapCaptchaStore(), new ImageCaptchaEngine(), 180, 100000, 75000);
}
public ImageCaptchaService getInstance() {
return instance;
}
/*
@PostConstruct
public void init() {
}
@PreDestroy
public void close() {
}
*/
}

@ -1,35 +0,0 @@
package kr.xit.framework.support.captcha.ignore;
import com.octo.captcha.service.captchastore.FastHashMapCaptchaStore;
import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;
import com.octo.captcha.service.image.ImageCaptchaService;
public class CaptchaServiceSingleton {
private final static ImageCaptchaService instance;
static {
instance = new DefaultManageableImageCaptchaService(new FastHashMapCaptchaStore(), new ImageCaptchaEngine(), 180, 100000, 75000);
}
public static ImageCaptchaService getInstance() {
return instance;
}
/*
// 기본설정 그대로 사용
private static ImageCaptchaService instance = new DefaultManageableImageCaptchaService();
public static ImageCaptchaService getInstance(){
return instance;
}
// 기본 옵션만 변경하여 사용
private static ImageCaptchaService instance = initializeService();
private static ImageCaptchaService initializeService(){
SimpleListImageCaptchaEngine engine = new SimpleListImageCaptchaEngine();
return new DefaultManageableImageCaptchaService(new FastHashMapCaptchaStore(), engine, 180, 100000, 75000);
}
public static ImageCaptchaService getInstance(){
return instance;
}
*/
}

@ -1,58 +0,0 @@
package kr.xit.framework.support.captcha.ignore;
import java.awt.Font;
import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
import com.octo.captcha.component.image.backgroundgenerator.FunkyBackgroundGenerator;
import com.octo.captcha.component.image.color.RandomRangeColorGenerator;
import com.octo.captcha.component.image.fontgenerator.FontGenerator;
import com.octo.captcha.component.image.fontgenerator.RandomFontGenerator;
import com.octo.captcha.component.image.textpaster.RandomTextPaster;
import com.octo.captcha.component.image.textpaster.TextPaster;
import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage;
import com.octo.captcha.component.image.wordtoimage.WordToImage;
import com.octo.captcha.component.word.wordgenerator.RandomWordGenerator;
import com.octo.captcha.component.word.wordgenerator.WordGenerator;
import com.octo.captcha.engine.image.ListImageCaptchaEngine;
import com.octo.captcha.image.gimpy.GimpyFactory;
public class ImageCaptchaEngine extends ListImageCaptchaEngine {
protected void buildInitialFactories() {
// 랜덤문자생성
WordGenerator wgen = new RandomWordGenerator("ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789");
// Text 색 설정
RandomRangeColorGenerator cgen = new RandomRangeColorGenerator(
new int[] { 0, 100 },
new int[] { 0, 100 },
new int[] { 0, 100 });
// Text 설정(랜덤시작 Text Size, 랜덤 종료 Text size, 색상)
TextPaster textPaster = new RandomTextPaster(new Integer(4), new Integer(7), cgen, true);
// background color setting
RandomRangeColorGenerator bcgen = new RandomRangeColorGenerator(
new int[] { 150, 255 },
new int[] { 150, 255 },
new int[] { 150, 255 });
// background setting(가로크기, 세로크기, 색상)
BackgroundGenerator backgroundGenerator = new FunkyBackgroundGenerator(new Integer(150), new Integer(50), bcgen);
// 백그라운드 기본 설정
// BackgroundGenerator backgroundGenerator = new FunkyBackgroundGenerator(new Integer(150), new Integer(50));
// font setting
Font[] fontsList = new Font[] {
new Font("Arial", 0, 10),
new Font("Tahoma", 0, 10),
new Font("Verdana", 0, 10)
};
// font setting(랜덤시작폰트 크기, 랜덤종료 폰트 크기)
FontGenerator fontGenerator = new RandomFontGenerator(new Integer(20), new Integer(35), fontsList);
WordToImage wordToImage = new ComposedWordToImage(fontGenerator, backgroundGenerator, textPaster);
this.addFactory(new GimpyFactory(wgen, wordToImage));
}
}

@ -1,56 +0,0 @@
package kr.xit.framework.support.captcha.ignore;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.octo.captcha.service.CaptchaServiceException;
public class ImageCaptchaServlet extends HttpServlet {
@Override
public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
byte[] captchaChallengeAsJpeg = null;
ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
try {
String captchaId = request.getSession().getId();
BufferedImage challenge = CaptchaServiceSingleton.getInstance().getImageChallengeForID(captchaId, request.getLocale());
//JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(jpegOutputStream);
//jpegEncoder.encode(challenge);
ImageIO.write(challenge, "jpeg", response.getOutputStream());
} catch (IllegalArgumentException e) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
} catch (CaptchaServiceException e) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("image/jpeg");
ServletOutputStream responseOutputStream = response.getOutputStream();
responseOutputStream.write(captchaChallengeAsJpeg);
responseOutputStream.flush();
responseOutputStream.close();
}
}

@ -1,11 +0,0 @@
package kr.xit.framework.support.captcha.ignore;
import com.octo.captcha.service.image.ImageCaptchaService;
import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;
public class JCapchaServiceInstance {
private static ImageCaptchaService instance = new DefaultManageableImageCaptchaService();
public static ImageCaptchaService getInstance(){
return instance;
}
}

@ -11,11 +11,11 @@
<property name="REQUEST_PARAM_LEVEL" value="INFO" />
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<encoder> <!--class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">-->
<!-- <maskPattern>\"SSN\"\s*:\s*\"(.*?)\"</maskPattern> &lt;!&ndash; SSN JSON pattern &ndash;&gt;-->
<!-- <maskPattern>\"address\"\s*:\s*\"(.*?)\"</maskPattern> &lt;!&ndash; Address JSON pattern &ndash;&gt;-->
<maskPattern>(\d+\.\d+\.\d+\.\d+)</maskPattern> <!-- Ip address IPv4 pattern -->
<maskPattern>(\w+@\w+\.\w+)</maskPattern> <!-- Email pattern -->
<!-- <maskPattern>(\d+\.\d+\.\d+\.\d+)</maskPattern> &lt;!&ndash; Ip address IPv4 pattern &ndash;&gt;-->
<!-- <maskPattern>(\w+@\w+\.\w+)</maskPattern> &lt;!&ndash; Email pattern &ndash;&gt;-->
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>

Loading…
Cancel
Save