DB 접속정보 암호화를 위한 추상 클래스
import java.sql.SQLFeatureNotSupportedException; import java.util.logging.Logger; import org.apache.commons.dbcp.BasicDataSource; import org.apache.commons.lang3.StringUtils; /** * DB 접속 정보 암호화 */ public abstract class SecurityBasicDataSource extends BasicDataSource { /** * 사용자아이디 암호화 해제 설정 */ public void setUsername(String username){ try { if(StringUtils.isNotEmpty(username)) { super.setUsername(getDecryptValue(username)); } else { throw new Exception("usernmae is empty! username = [" + this.username + "]"); } } catch (Exception e) { e.printStackTrace(); } } /** * 비밀번호 암호화 해제 설정 */ public void setPassword(String password) { try { if(StringUtils.isNotEmpty(password)) { super.setPassword(getDecryptValue(password)); } else { throw new Exception("password is empty! password = [" + this.password + "]"); } } catch (Exception e) { e.printStackTrace(); } } /** * URL 암호화 해제 설정 */ public void setUrl(String url) { try { if (StringUtils.isNotEmpty(url)) { super.setUrl(getDecryptValue(url)); } else { throw new Exception("url is empty! url = [" + this.url + "]"); } } catch (Exception e) { e.printStackTrace(); } } /** * Parent method implement */ @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { return Logger.getLogger(this.getClass().getName()); } /** * 복호화 알고리즘 인터페이스 * @param encryptValue * @return decryptValue * @throws Exception * @since 2014. 3. 31. */ protected abstract String getDecryptValue(String encryptValue) throws Exception; }
'개발로그' 카테고리의 다른 글
페이지 로드 완료시에는 이미지 로드가 완료되지 않는다. (0) | 2017.07.20 |
---|---|
Cannot change version of project facet Dynamic Web Module to 3.0? (0) | 2017.07.20 |
깔끔하게 anchor 동작 안하게 하기! (0) | 2017.07.20 |
maven plugins (0) | 2017.07.20 |
패스워드 체크 규칙 스크립트 (0) | 2017.07.20 |