//package com.eactive.eai.batch.xecure;
//
//import java.io.BufferedReader;
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.FileReader;
//
//import com.eactive.eai.common.property.PropManager;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import com.sf.xc3.XCClientBigfile;
//import com.sf.xc3.XCServerBigfile;
//
//public class XecureManager {
//
//	//디버그용 로그유틸
//	private static Logger logger = LoggerFactory.getLogger(ElinkLogger.LOGGER_SCHEDULER);
//
//	//응답수신 디렉토리 프라퍼티 키 정보
//	public static final String ENC_TYPE_INFO              = "EncTypeInfo";
//	public static final String ENC_KEY_FILE_NAME          = "key.file.name";
//	public static final String ENC_SERVER_TYPE            = "server.type";
//	public static final String ENC_SERVER_TYPE_SERVER     = "SERVER";
//	public static final String ENC_SERVER_TYPE_CLIENT     = "CLIENT";
//
//
//	//singleton 객체 생성
//	private static XecureManager instance = new XecureManager();
//	//singleton 객체 리턴
//    public static XecureManager getInstance() {
//        return instance;
//    }
//
//	//생성자 (다른 클래스에서 new 불가)
//	private XecureManager() {}
//	
//	private byte[] getKey(String encType) throws Exception{
//		String groupName = ENC_TYPE_INFO + "{" + encType + "}";
//		String keyFileName = PropManager.getInstance().getProperty( groupName, ENC_KEY_FILE_NAME);
//		if (keyFileName == null) {
//			logger.warn("'암/복호화 KEY파일명' 프라퍼티 정보가 없습니다. (PropGroupName:"+ groupName +", PropName:"+ ENC_KEY_FILE_NAME +")");
//			throw new Exception();
//		}
//		File file = new File(keyFileName);
//		if ( !file.exists()){
//			throw new Exception();
//		}
//        BufferedReader  reader = new BufferedReader(new FileReader(file));
//
//		FileInputStream fin = new FileInputStream(file);
//		try {
//			return reader.readLine().getBytes();
//		} catch (Exception e) {
//			throw new Exception();
//		} finally {
//			fin.close();
//		}
//	}
//	
//	public void encryptFile( String encType, String plainFile, String encFile) throws Exception{
//		logger.debug( "encType-->[" + encType + "]");
//		logger.debug( "plainFile-->[" + plainFile + "]");
//		logger.debug( "encFile-->[" + encFile + "]");
//		String groupName = ENC_TYPE_INFO + "{" + encType + "}";
//		String serverType = PropManager.getInstance().getProperty( groupName, ENC_SERVER_TYPE);
//		if (serverType == null) {
//			logger.warn("'암/복호화 서버타입' 프라퍼티 정보가 없습니다. (PropGroupName:"+ groupName +", PropName:"+ ENC_SERVER_TYPE +")");
//			throw new Exception();
//		}
//		
//		logger.debug( "KEY-->[" + new String(getKey(encType)) + "]");
//
//		if ( serverType.equalsIgnoreCase(ENC_SERVER_TYPE_SERVER) ){
//			XCServerBigfile xs = new XCServerBigfile(getKey(encType));
//			xs.encryptBig( plainFile, encFile );
//		}else if( serverType.equalsIgnoreCase(ENC_SERVER_TYPE_CLIENT) ){
//			XCClientBigfile xc = new XCClientBigfile(getKey(encType));
//			xc.encryptBig( plainFile, encFile );
//		}else{
//			throw new Exception();
//		}
//	}
//
//	public void decryptFile( String encType, String encFile, String plainFile) throws Exception{
//		logger.debug( "encType-->[" + encType + "]");
//		logger.debug( "plainFile-->[" + plainFile + "]");
//		logger.debug( "encFile-->[" + encFile + "]");
//
//		String groupName = ENC_TYPE_INFO + "{" + encType + "}";
//		String serverType = PropManager.getInstance().getProperty( groupName, ENC_SERVER_TYPE);
//		if (serverType == null) {
//			logger.warn("'암/복호화 서버타입' 프라퍼티 정보가 없습니다. (PropGroupName:"+ groupName +", PropName:"+ ENC_SERVER_TYPE +")");
//			throw new Exception();
//		}
//
//		logger.debug( "KEY-->[" + new String(getKey(encType)) + "]");
//
//		if ( serverType.equalsIgnoreCase(ENC_SERVER_TYPE_SERVER) ){
//			XCServerBigfile xs = new XCServerBigfile(getKey(encType));
//			xs.decryptBig( encFile, plainFile );
//		}else if( serverType.equalsIgnoreCase(ENC_SERVER_TYPE_CLIENT) ){
//			XCClientBigfile xc = new XCClientBigfile(getKey(encType));
//			xc.decryptBig( encFile, plainFile );
//		}else{
//			throw new Exception();
//		}
//	}
//
//}
