Example usage for org.bouncycastle.jce.provider BouncyCastleProvider BouncyCastleProvider

List of usage examples for org.bouncycastle.jce.provider BouncyCastleProvider BouncyCastleProvider

Introduction

In this page you can find the example usage for org.bouncycastle.jce.provider BouncyCastleProvider BouncyCastleProvider.

Prototype

public BouncyCastleProvider() 

Source Link

Document

Construct a new provider.

Usage

From source file:NaverShopnSendItem.java

private String run2(String imgUrl) { // 

    String response_type = "FALSE";
    NaverShopnSendItem NaverShopnSendItem = new NaverShopnSendItem();
    try {/*from   w  w w  . j a v  a  2  s.  c  o  m*/
        SimpleCryptLib SimpleCryptLib = new SimpleCryptLib();
        Security.addProvider(new BouncyCastleProvider());

        String accessLicense = "0100010000f3814c41974dc3e7f98d1cd213fa8b84c396872ff6c1abb57f0d2516f31cfb43";
        String secretKey = "AQABAADKObge3IgWtlgfbo1TaLqHKpjfyGNKYuZbfOZB8m+WJA==";

        String serviceName = "ImageService"; // 
        String id = "eugink";
        String password = "asdf0101";
        String timestamp = null;
        String signature = null;
        String data = null;

        byte[] encryptKey = null;

        String encryptedData = null;
        String decryptedData = null;
        String hashedData = null;

        String operationName = "UploadImage";
        // String orderID = "200087036";

        // timestamp create
        timestamp = SimpleCryptLib.getTimestamp();
        System.out.println("timestamp:" + timestamp);
        System.out.println("ImageService");

        // generateSign
        data = timestamp + serviceName + operationName;
        signature = SimpleCryptLib.generateSign(data, secretKey);

        // generateKey
        encryptKey = SimpleCryptLib.generateKey(timestamp, secretKey);

        // encrypt
        encryptedData = SimpleCryptLib.encrypt(encryptKey, password.getBytes("UTF-8"));

        // decrypt
        decryptedData = new String(SimpleCryptLib.decrypt(encryptKey, encryptedData), "UTF-8");

        // sha256
        hashedData = SimpleCryptLib.sha256(password);

        String imglist = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:shop=\"http://shopn.platform.nhncorp.com/\">"
                + "<soap:Header/>" + "<soap:Body>" + "<shop:UploadImageRequest>" + "<!--Optional:-->"
                + "<shop:RequestID>njoyny2</shop:RequestID>" + "<shop:AccessCredentials>"
                + "<shop:AccessLicense>" + accessLicense + "</shop:AccessLicense>" + "<shop:Timestamp>"
                + timestamp + "</shop:Timestamp>" + "<shop:Signature>" + signature + "</shop:Signature>"
                + "</shop:AccessCredentials>" + "<shop:Version>2.0</shop:Version>"
                + "<SellerId>njoyny2</SellerId>" + "<ImageURLList>" + "<!--Zero or more repetitions:-->"
                + "<shop:URL>" + imgUrl + "</shop:URL>" + "</ImageURLList>" + "</shop:UploadImageRequest>"
                + "</soap:Body>" + "</soap:Envelope>";

        // Create socket
        String hostname = "ec.api.naver.com";
        // String hostname = "api.naver.com";
        int port = 80;
        InetAddress addr = InetAddress.getByName(hostname);
        Socket sock = new Socket(addr, port);

        // Send header
        String path = "/ShopN/ImageService";
        BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(), "UTF-8"));
        // You can use "UTF8" for compatibility with the Microsoft virtual
        // machine.
        wr.write("POST " + path + " HTTP/1.0 \r\n");
        wr.write("Host: ec.api.naver.com \r\n");
        // wr.write("Host: api.naver.com \r\n");
        // wr.write("Content-Length: " + xmldata.length() + "\r\n");
        wr.write("Content-Length: " + imglist.length() + "\r\n");
        wr.write("Content-Type: text/xml; charset=\"UTF-8\"\r\n");
        wr.write("SOAPAction: \"http://ec.api.naver.com/ShopN/ImageService\" \r\n");
        // wr.write("SOAPAction: \"http://api.naver.com/Checkout/MallService2\" \r\n");
        wr.write("\r\n");

        // Send data
        // wr.write(xmldata);
        wr.write(imglist);
        wr.flush();
        // InputStream test = new
        // InputStream(sock.getInputStream(),"UTF-8");

        // Response
        BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream(), "UTF-8"));
        String line = "";
        String line_total = "";
        String tmp = "";
        String tmp2 = "";
        String newxml = "";

        while ((line = rd.readLine()) != null) {
            if (line.startsWith("<?xml")) {
                line = line.replaceAll("&#xd;", " ");
                line_total = line_total + line;
                //System.out.println(line);
            }

        }
        rd.close();
        wr.close();

        line_total = line_total.replaceAll("n:", "");
        //System.out.println(line_total);

        line_total = line_total.replaceAll("n:", "");
        // System.out.println(sf.toString().trim());

        // xml2
        InputStream in = new ByteArrayInputStream(line_total.getBytes("UTF-8"));

        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(in);

        Element element = document.getRootElement();
        List envel_list = element.getChildren();
        List body_list = null;
        List body_list1 = null;
        List result_list = null;
        List result_list1 = null;
        List result_list2 = null;
        List result_list3 = null;
        List result_list4 = null;
        List result_list5 = null;
        List info_list = null;
        List contr_group_list = null;
        List contr_info_list = null;

        PreparedStatement pstmt = null;
        ResultSet rs = null;
        CallableStatement cStmt = null;

        // conn.setAutoCommit(false);

        long UNIT_ID = 0;
        long cnt = 0;
        long interface_seq = 0;
        long DEL_QTY = 0;
        long ITEM_ID = 0;
        String ITEM_NAME = null;

        Element envel_el = (Element) envel_list.get(0);
        body_list = envel_el.getChildren();

        Element body_el = (Element) body_list.get(0);
        result_list = body_el.getChildren("ImageList");

        for (int h = 0; h < result_list.size(); h++) {

            Element body_el1 = (Element) result_list.get(h);

            result_list1 = body_el1.getChildren("Image");

            for (int i = 0; i < result_list1.size(); i++) {

                Element body_el2 = (Element) result_list1.get(i);

                response_type = body_el2.getChildText("URL");

            }
        }

    } catch (Exception e) {
        System.out.println("run2() : " + e.getMessage());
        response_type = "FALSE";
    } finally {
    }

    return response_type;
}

From source file:NaverShopnSendItem.java

public String run(String InputItem) {
    StringBuffer itemlist = new StringBuffer(); // 

    String response_type = "FALSE";
    PreparedStatement pstmt = null;
    ResultSet rs = null;//from   w w  w. j  a  v  a 2s.  com
    CallableStatement cStmt = null;

    try {

        StringBuffer selectItem = new StringBuffer();

        selectItem.append(" select  \n");
        selectItem.append("  a.ITEM_ID               , \n");
        selectItem.append(
                "  (select b.co_item_id from ktc_item_interlock b where coven_id = 27346 and b.item_id = a.item_id)     co_item_id      , \n");
        //selectItem.append("  (select CASE WHEN  sum(decode(use_yn,'Y',vir_stock_qty,0)) < 0 then 0 else sum(decode(use_yn,'Y',vir_stock_qty,0)) end  from ktc_unit where item_id = a.item_id    ) qty        , \n");
        selectItem.append(
                "  (select  sum(CASE WHEN  vir_stock_qty <= 0 then decode(use_yn,'Y',1,0) else decode(use_yn,'Y',vir_stock_qty,0) end)  from ktc_unit where item_id = a.item_id    ) qty        , \n");
        selectItem.append("  a.ITEM_GB                 , \n");
        selectItem.append("  a.PRE_ITEM_NAME            , \n");
        selectItem.append("  a.MODEL                 , \n");
        selectItem.append("  a.STD_CTG_ID            , \n");
        selectItem.append("  a.START_DATETIME         , \n");
        selectItem.append("  a.END_DATETIME           , \n");
        selectItem.append(
                "  decode( (select sum(decode(use_yn,'Y',vir_stock_qty,0))  from ktc_unit where item_id = a.item_id    )  , 0, 'SUSP' , decode(a.ITEM_STAT_CODE,120103,'SALE', 'SUSP'))   item_stat_code     , \n");// SALE()// SUSP()// QSTK())
        selectItem.append(
                "  (select b.co_ctg_id from ktc_ctg_interlock b where b.coven_id = 27346 and b.sctg_id in (select c.sctg_id from ktc_ctgitem c where c.item_id = a.item_id) and rownum  = 1)     co_ctg_id     , \n"); // 
        // 
        selectItem.append(
                "  decode((select count(DC_SALE_PRICE) from KTC_SITEITEM where ITEM_ID = a.ITEM_ID and SITE_ID = 10 and sysdate between START_DATETIME and END_DATETIME and sysdate between DC_START_DATETIME and DC_END_DATETIME and rownum = 1), 0, (select SALE_PRICE from KTC_SITEITEM where ITEM_ID = a.ITEM_ID  and SITE_ID = 10 and sysdate between START_DATETIME and END_DATETIME and rownum = 1),decode((select DC_SALE_PRICE from KTC_SITEITEM where ITEM_ID = a.ITEM_ID  and SITE_ID = 10 and sysdate between START_DATETIME and END_DATETIME and rownum = 1),0,(select SALE_PRICE from KTC_SITEITEM where ITEM_ID = a.ITEM_ID  and SITE_ID = 10 and sysdate between START_DATETIME and END_DATETIME and rownum = 1),(select DC_SALE_PRICE from KTC_SITEITEM where ITEM_ID = a.ITEM_ID  and SITE_ID = 10 and sysdate between START_DATETIME and END_DATETIME and rownum = 1))) as SALE_PRICE, \n");
        selectItem.append("  a.MIN_ORDER_QTY          , \n");
        selectItem.append("  a.EMP_ID                , \n");
        selectItem.append("  a.IMPORT_VEN_NAME        , \n");
        selectItem.append("  a.PACKER_CODE             , \n");
        selectItem.append("  a.PACK_MATR_CODE          , \n");
        selectItem.append("  a.STOCK_DIS_YN            , \n");
        selectItem.append("  a.VEN_ID                , \n");
        selectItem.append("  a.TAX_GB_CODE             , \n");
        selectItem.append("  a.ORDER_UNIT_CODE         , \n");
        selectItem.append("  a.CON_CARD_YN             , \n");
        selectItem.append("  a.CON_CARD_PRICE         , \n");
        selectItem.append("  a.ACCOUNT_METHOD_CODE     , \n");
        selectItem.append("  a.DELY_AREA_CODE          , \n");
        selectItem.append("  a.LEADTIME_CODE           , \n");
        selectItem.append("  decode(a.LOW_PRICE_YN,'Y',3,1)  LOW_PRICE_YN           , \n");
        selectItem.append("  a.LOW_PRICE_STD           , \n");
        selectItem.append("  a.LOW_PRICE_DELY_FEE      , \n");
        selectItem.append("  a.BUY_TYPE_CODE          , \n");
        selectItem.append("  a.DELI_TYPE_CODE          , \n");
        selectItem.append("  a.WHCENTER_CODE          , \n");
        selectItem.append("  a.GIFT_PACK_YN            , \n");
        selectItem.append("  a.GIFT_PACK_FEE           , \n");
        selectItem.append("  a.BRAND_ID                , \n");
        selectItem.append("  a.QUICK_YN                , \n");
        selectItem.append("  a.NOINTEREST_YN           , \n");
        selectItem.append("  a.NEW_YN                  , \n");
        selectItem.append("  a.RECOMM_YN              , \n");
        selectItem.append("  a.BEST_YN                 , \n");
        selectItem.append("  a.GIFT_SET_ID             , \n");
        selectItem.append("  a.GIFT_OFFER_CNT_CODE     , \n");
        selectItem.append("  a.GIFT_ACC_CNT            , \n");
        selectItem.append("  a.GIFT_LIMIT_CNT          , \n");
        selectItem.append("  a.GIFT_START_DATETIME     , \n");
        selectItem.append("  a.GIFT_END_DATETIME       , \n");
        selectItem.append("  a.HEADCOPY                , \n");
        selectItem.append("  a.ITEM_DESC                , \n");
        selectItem.append("  a.ETC                     , \n");
        selectItem.append("  a.IMG_SET_ID              , \n");
        selectItem.append("  a.GG_PRICE_METH_CODE      , \n");
        selectItem.append("  a.GG_SLIDE_YN             , \n");
        selectItem.append("  a.GG_BUY_PRICE            , \n");
        selectItem.append("  a.GG_SALE_PRICE           , \n");
        selectItem.append("  a.GG_SLIDE_PRICE          , \n");
        selectItem.append("  a.GG_SLIDE_QTY            , \n");
        selectItem.append("  a.GG_SALE_QTY             , \n");
        selectItem.append("  a.GG_NET_COMMISSION      , \n");
        selectItem.append("  a.GG_COMMISSION_CODE     , \n");
        selectItem.append("  a.INSERT_DATE             , \n");
        selectItem.append("  a.INSERT_ID              , \n");
        selectItem.append("  a.MODIFY_DATE             , \n");
        selectItem.append("  a.MODIFY_ID               , \n");
        selectItem.append(
                "  (select code_val from ktc_code where code_id = a.ORIGIN_NAME )    ORIGIN_NAME         , \n");
        selectItem.append("  a.BT_YN                   , \n");
        selectItem.append("  a.ITEM_NAME               , \n");
        selectItem.append("  a.MAKING_VEN_CODE        , \n");
        selectItem.append("  a.IMGX                    , \n");
        selectItem.append("  a.IMGL1                   , \n");
        selectItem.append("  a.IMGL2                   , \n");
        selectItem.append("  a.IMGM1                   , \n");
        selectItem.append("  a.IMGM2                   , \n");
        selectItem.append("  a.IMGS1                   , \n");
        selectItem.append("  a.IMGS2                   , \n");
        selectItem.append("  a.ITMID                   , \n");
        selectItem.append("  a.STORE_ID               , \n");
        selectItem.append("  a.REG_METHOD_GB           , \n");
        selectItem.append("  a.REG_VEN_ID              , \n");
        selectItem.append("  a.VOD_PATH               , \n");
        selectItem.append("  a.RTN_YN                  , \n");
        selectItem.append("  a.MALL_NAME              , \n");
        selectItem.append("  a.MALL_URL                , \n");
        selectItem.append("  a.HUSOISU_YN              , \n");
        selectItem.append("  a.PENALTY_YN              , \n");
        selectItem.append("  a.SEQ_NUM                 , \n");
        selectItem.append("  a.CASH_DISCOUNT_YN        , \n");
        selectItem.append("  a.TWELVE_H_YN             , \n");
        selectItem.append("  a.FIX_FEE_YN              , \n");
        selectItem.append("  a.BUYER_DELY_FEE_YN       , \n");
        selectItem.append("  a.SETYN                   , \n");
        selectItem.append("  a.VIAKTC                  , \n");
        selectItem.append("  a.PREBUYING               , \n");
        selectItem.append("  a.ANOTHER_MARKET_YN       , \n");
        selectItem.append("  a.SPECIAL_DC_FORBID       , \n");
        selectItem.append("  a.CHINA_COMMERCE_YN       , \n");
        selectItem.append("  a.MALL_URL2               , \n");
        selectItem.append("  a.COUPON_MEMO             , \n");
        selectItem.append("  a.FASHIONPLUS_YN          , \n");
        selectItem.append("  a.INTERPARK_YN            , \n");
        selectItem.append("  a.BUYER_DELY_FEE_PRICE    , \n");
        selectItem.append("  a.SINGLE_PLANNING         , \n");
        selectItem.append("  a.CURRENCY                , \n");
        selectItem.append("  a.OUTSIDE_ID              , \n");
        selectItem.append("  a.SINGLE_ITEM_YN          , \n");
        selectItem.append("  a.STYLE_E2A               , \n");
        selectItem.append("  a.CODYITEM_1              , \n");
        selectItem.append("  a.CODYITEM_2              , \n");
        selectItem.append("  a.CODYITEM_3              , \n");
        selectItem.append("  a.CODYITEM_4              , \n");
        selectItem.append("  a.REJECT_DESC             , \n");
        selectItem.append("  a.SHIPPLAN_DATE           , \n");
        selectItem.append("  a.RESERVSHIP_YN           , \n");
        selectItem.append("  a.ELEC_SAFE         ,       \n");

        selectItem.append("  b.kind           , \n");
        selectItem.append("  b.itemid           , \n");
        selectItem.append("  b.string1        ,       \n");
        selectItem.append("  b.string2        ,       \n");
        selectItem.append("  b.string3        ,       \n");
        selectItem.append("  b.string4        ,      \n");
        selectItem.append("  b.string5        ,       \n");
        selectItem.append("  b.string6         ,      \n");
        selectItem.append("  b.string7          ,     \n");
        selectItem.append("  b.string8        ,       \n");
        selectItem.append("  b.string9        ,       \n");
        selectItem.append("  b.string10         ,      \n");
        selectItem.append("  b.string11         ,      \n");
        selectItem.append("  b.string12         ,      \n");
        selectItem.append("  b.string13         ,      \n");
        selectItem.append("  b.string14         ,      \n");
        selectItem.append("  b.string15               \n");

        selectItem.append(" from ktc_item a ,mirus_detailitem b \n");
        selectItem.append(" where a.item_id > 5000000  \n");
        selectItem.append(" and a.item_id = b.itemid \n");

        selectItem.append(" and a.ven_id in (select ven_id from ktc_vendor where van_status = 120846 ) \n"); // 
        // 
        // 20120109
        // 
        //selectItem.append(" and a.std_ctg_id in ( select ctg_id from ktc_stdctg where prnt_ctg_id=5994 )  \n"); // 
        selectItem.append(" and a.item_id = ? \n");

        System.out.println("selectItem:" + selectItem.toString());
        /* 20120723   */

        /*   */

        try {

            if (rs != null)
                try {
                    rs.close();
                } catch (Exception e) {
                }
            if (pstmt != null)
                try {
                    pstmt.close();
                } catch (Exception e) {
                }

            // NaverShopnSendItem NaverShopnSendItem= new
            // NaverShopnSendItem();

            pstmt = conn.prepareStatement(selectItem.toString());
            pstmt.setString(1, InputItem);
            System.out.println("InputItem:" + InputItem);
            rs = pstmt.executeQuery();
            System.out.println("rs:" + rs.getRow());
            while (rs.next()) {
                System.out.println("selectItem in:" + selectItem.toString());

                SimpleCryptLib SimpleCryptLib = new SimpleCryptLib();
                Security.addProvider(new BouncyCastleProvider());

                String accessLicense = "0100010000f3814c41974dc3e7f98d1cd213fa8b84c396872ff6c1abb57f0d2516f31cfb43";
                String secretKey = "AQABAADKObge3IgWtlgfbo1TaLqHKpjfyGNKYuZbfOZB8m+WJA==";

                String serviceName = "ProductService"; // 
                String id = "eugink";
                String password = "asdf0101";
                String timestamp = null;
                String signature = null;
                String data = null;

                byte[] encryptKey = null;

                String encryptedData = null;
                String decryptedData = null;
                String hashedData = null;

                String operationName = "ManageProduct";
                String ResponseType = "";

                // String orderID = "200087036";

                // timestamp create
                timestamp = SimpleCryptLib.getTimestamp();
                System.out.println("timestamp:" + timestamp);
                System.out.println("ManageProduct");
                // generateSign
                data = timestamp + serviceName + operationName;
                signature = SimpleCryptLib.generateSign(data, secretKey);

                // generateKey
                encryptKey = SimpleCryptLib.generateKey(timestamp, secretKey);

                // encrypt
                encryptedData = SimpleCryptLib.encrypt(encryptKey, password.getBytes("UTF-8"));

                // decrypt
                decryptedData = new String(SimpleCryptLib.decrypt(encryptKey, encryptedData), "UTF-8");

                // sha256
                hashedData = SimpleCryptLib.sha256(password);

                NaverShopnSendItem NaverShopnSendItem = new NaverShopnSendItem();

                String ProductId = "";
                String item_id = "";
                String n_item_id = "";

                item_id = rs.getString("co_item_id");
                n_item_id = rs.getString("item_id");

                /*
                 * CLOB 
                 */

                // 1.StringBuffer, char[], Reader . 
                StringBuffer stringbuffer = new StringBuffer();
                char[] charbuffer = new char[1024];
                Reader reader = null; // CLOB  .
                // 2. ResultSet  CLOB  Reader .
                reader = rs.getCharacterStream("ITEM_DESC");
                int read = 0;
                // 3.  StringBuffer append . 1024 ..
                while ((read = reader.read(charbuffer, 0, 1024)) != -1) {
                    stringbuffer.append(charbuffer, 0, read);
                }
                // 4.  StringBuffer append    .
                String rpl_cont = stringbuffer.toString();
                // 5. StringBuffer  . ( ,      .)
                stringbuffer.delete(0, stringbuffer.capacity());

                itemlist.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n ");
                itemlist.append(
                        "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:shop=\"http://shopn.platform.nhncorp.com/\">");
                itemlist.append("   <soap:Header/>");
                itemlist.append("   <soap:Body>");
                itemlist.append("      <shop:ManageProductRequest>");
                itemlist.append("         <shop:RequestID>njoyny2</shop:RequestID>");
                itemlist.append("         <shop:AccessCredentials>");
                itemlist.append("            <shop:AccessLicense>" + accessLicense + "</shop:AccessLicense>");
                itemlist.append("            <shop:Timestamp>" + timestamp + "</shop:Timestamp>");
                itemlist.append("            <shop:Signature>" + signature + "</shop:Signature>");
                itemlist.append("         </shop:AccessCredentials>");
                itemlist.append("         <shop:Version>2.0</shop:Version>");
                itemlist.append("         <SellerId>njoyny2</SellerId>");
                itemlist.append("         <Product>");
                if (item_id != null) {
                    itemlist.append("            <shop:ProductId>" + item_id + "</shop:ProductId>"); // item_id
                    // 
                    // :null
                    // :id()
                }
                itemlist.append("            <shop:StatusType>" + rs.getString("item_stat_code")
                        + "</shop:StatusType>"); // SALE
                // ()
                // SUSP()
                // QSTK())
                itemlist.append("            <shop:SaleType>NEW</shop:SaleType>"); // 
                // 
                // 
                // 
                // NEW:
                //   20130329
                if (item_id == null) {
                    itemlist.append(
                            "            <shop:CategoryId>" + rs.getString("co_ctg_id") + "</shop:CategoryId>"); // 

                }

                itemlist.append("            <shop:LayoutType>BASIC</shop:LayoutType>"); // BASIC
                // :
                // 
                // IMAGE:
                // 
                itemlist.append("            <shop:Name><![CDATA["
                        + NaverShopnSendItem.removeXssString(
                                NaverShopnSendItem.parsingSpecialforXml(rs.getString("item_name")))
                        + "]]></shop:Name>"); // 
                itemlist.append("            <shop:SellerManagementCode>" + rs.getString("item_id")
                        + "</shop:SellerManagementCode>"); // 
                itemlist.append("            <shop:Model>");
                itemlist.append("               <shop:ManufacturerName><![CDATA["
                        + rs.getString("MAKING_VEN_CODE") + "]]></shop:ManufacturerName>"); // 
                // itemlist.append("               <shop:BrandName><![CDATA["+
                // rs.getString("brand_id") +"]]></shop:BrandName>" );
                // //
                itemlist.append("            </shop:Model>");
                itemlist.append("            <shop:OriginArea>"); // 
                // GetOriginAreaList
                itemlist.append("               <shop:Code>03</shop:Code>"); // 
                // 
                itemlist.append("            </shop:OriginArea>");
                itemlist.append("            <shop:TaxType>TAX</shop:TaxType>"); // 
                itemlist.append("            <shop:MinorPurchasable>Y</shop:MinorPurchasable>"); // 
                // */
                itemlist.append("            <shop:Image>");
                itemlist.append("               <shop:Representative>"); // 
                // 450*450
                itemlist.append("                  <shop:URL><![CDATA["
                        + NaverShopnSendItem.run2(rs.getString("IMGX")) + "]]></shop:URL>");

                // itemlist.append("                  <shop:URL><![CDATA[http://beta.shop1.phinf.naver.net/20120829_211/nmp_1346214765097FUx6u_JPEG/45862043648053663_117747847.jpg]]></shop:URL>"
                // );
                itemlist.append("               </shop:Representative>");
                itemlist.append("            </shop:Image>");

                // String DetailContent =
                // NaverShopnSendItem.parsingSpecialforXml("/ :"+rs.getString("MAKING_VEN_CODE")+"/"+
                // rs.getString("ORIGIN_NAME")+"<br>"+
                // rs.getString("ITEM_DESC")) ;
                itemlist.append("            <shop:DetailContent><![CDATA[" + "/ :"
                        + rs.getString("MAKING_VEN_CODE") + "/" + rs.getString("ORIGIN_NAME") + "<br>"
                        + rpl_cont + "]]></shop:DetailContent>"); // 
                // itemlist.append("            <shop:DetailContent><![CDATA["+"/ :"+rs.getString("MAKING_VEN_CODE")+"/"+
                // rs.getString("ORIGIN_NAME")+ ""
                // +"]]></shop:DetailContent>" ); //
                itemlist.append("            <shop:AfterServiceTelephoneNumber><![CDATA[" + "02-1577-3212"
                        + "]]></shop:AfterServiceTelephoneNumber>"); // AS()
                itemlist.append("            <shop:AfterServiceGuideContent><![CDATA["
                        + "     ."
                        + "]]></shop:AfterServiceGuideContent>"); // A/S
                itemlist.append("            <shop:PurchaseReviewExposure>Y</shop:PurchaseReviewExposure>"); // 
                itemlist.append(
                        "            <shop:KnowledgeShoppingProductRegistration>Y</shop:KnowledgeShoppingProductRegistration>"); // 
                itemlist.append(
                        "            <shop:SalePrice>" + rs.getString("SALE_PRICE") + "</shop:SalePrice>"); // 
                itemlist.append(
                        "            <shop:StockQuantity>" + rs.getString("qty") + "</shop:StockQuantity>");

                itemlist.append("            <shop:Delivery>");
                itemlist.append("            <shop:Type>1</shop:Type>");
                itemlist.append("            <shop:BundleGroupAvailable>N</shop:BundleGroupAvailable>");
                itemlist.append("            <shop:PayType>2</shop:PayType>"); //  1  3 
                itemlist.append(
                        "            <shop:FeeType>" + rs.getString("low_price_yn") + "</shop:FeeType>"); //  1  3 
                itemlist.append(
                        "            <shop:BaseFee>" + rs.getString("LOW_PRICE_DELY_FEE") + "</shop:BaseFee>"); //
                itemlist.append(
                        "            <shop:ReturnDeliveryCompanyPriority>0</shop:ReturnDeliveryCompanyPriority>"); //
                itemlist.append("            <shop:ReturnFee>2500</shop:ReturnFee>"); // 
                itemlist.append("            <shop:ExchangeFee>2500</shop:ExchangeFee>"); //
                itemlist.append("            </shop:Delivery>");

                /*
                 *   start 20121112
                 */
                itemlist.append("            <shop:ProductSummary>"); // 20121112

                if ("3".equals(rs.getString("kind")) || "4".equals(rs.getString("kind"))) {

                    itemlist.append(" <shop:Shoes> "); // ShoesSummaryType
                    itemlist.append(" <shop:Material>:" + rs.getString("string1") + "/:"
                            + rs.getString("string2") + "</shop:Material> "); // 
                    itemlist.append(" <shop:Color>" + rs.getString("string3") + "</shop:Color> "); //
                    itemlist.append(" <shop:Size>" + rs.getString("string4") + "</shop:Size> "); //
                    itemlist.append(" <shop:Height>" + rs.getString("string5") + "</shop:Height> "); //
                    itemlist.append(" <shop:Manufacturer>" + rs.getString("string6") + "</shop:Manufacturer> "); //
                    itemlist.append(" <shop:Caution>" + rs.getString("string8") + "</shop:Caution> "); //
                    itemlist.append(
                            " <shop:WarrantyPolicy>" + rs.getString("string9") + "</shop:WarrantyPolicy> "); //
                    itemlist.append(
                            " <shop:AfterServiceDirector>" + "1577-1533" + "</shop:AfterServiceDirector> "); //a/s               
                    itemlist.append(" </shop:Shoes> "); //

                } else if ("1".equals(rs.getString("kind")) || "2".equals(rs.getString("kind"))) {

                    itemlist.append(" <shop:Wear> "); // WearSummaryType
                    itemlist.append(" <shop:Material>" + rs.getString("string1") + "</shop:Material> "); //
                    itemlist.append(" <shop:Color>" + rs.getString("string2") + "</shop:Color> "); //
                    itemlist.append(" <shop:Size>" + rs.getString("string3") + "</shop:Size> "); //
                    itemlist.append(" <shop:Manufacturer>" + rs.getString("string4") + "</shop:Manufacturer> "); //
                    itemlist.append(" <shop:Caution>" + rs.getString("string6") + "</shop:Caution> "); // 
                    //itemlist.append(" <shop:PackDate> string </shop:PackDate> "); //
                    itemlist.append(" <shop:PackDateText>" + rs.getString("string7") + "</shop:PackDateText> "); //   
                    itemlist.append(
                            " <shop:WarrantyPolicy>" + rs.getString("string8") + "</shop:WarrantyPolicy> "); //
                    itemlist.append(
                            " <shop:AfterServiceDirector>" + "1577-1533" + "</shop:AfterServiceDirector> "); //a/s               
                    itemlist.append(" </shop:Wear>"); //

                } else if ("5".equals(rs.getString("kind")) || "6".equals(rs.getString("kind"))) {

                    itemlist.append(" <shop:Bag> "); // BagSummaryType
                    itemlist.append(" <shop:Type>" + rs.getString("string1") + "</shop:Tye> "); //
                    itemlist.append(" <shop:Material>" + rs.getString("string2") + "</shop:Material> "); //
                    itemlist.append(" <shop:Color>" + rs.getString("string3") + "</shop:Color> "); //
                    itemlist.append(" <shop:Size>" + rs.getString("string4") + "</shop:Size> "); //
                    itemlist.append(" <shop:Manufacturer>" + rs.getString("string5") + "</shop:Manufacturer> "); //
                    itemlist.append(" <shop:Caution>" + rs.getString("string7") + "</shop:Caution> "); //
                    itemlist.append(
                            " <shop:WarrantyPolicy>" + rs.getString("string8") + "</shop:WarrantyPolicy> "); //
                    itemlist.append(
                            " <shop:AfterServiceDirector>" + "1577-1533" + "</shop:AfterServiceDirector> "); //a/s               
                    itemlist.append(" </shop:Wear>"); //

                } else if ("7".equals(rs.getString("kind")) || "8".equals(rs.getString("kind"))) {

                    itemlist.append(" <shop:FashionItems> "); // FashionItemsSummaryType
                    itemlist.append(" <shop:Type>" + rs.getString("string1") + "</shop:Tye> "); //
                    itemlist.append(" <shop:Material>" + rs.getString("string2") + "</shop:Material> "); //
                    itemlist.append(" <shop:Size>" + rs.getString("string3") + "</shop:Size> "); //
                    itemlist.append(" <shop:Manufacturer>" + rs.getString("string4") + "</shop:Manufacturer> "); //
                    itemlist.append(" <shop:Caution>" + rs.getString("string6") + "</shop:Caution> "); // 
                    itemlist.append(
                            " <shop:WarrantyPolicy>" + rs.getString("string7") + "</shop:WarrantyPolicy> "); //
                    itemlist.append(
                            " <shop:AfterServiceDirector>" + "1577-1533" + "</shop:AfterServiceDirector> "); //a/s               
                    itemlist.append(" </shop:FashionItems>"); //

                } else if ("13".equals(rs.getString("kind")) || "14".equals(rs.getString("kind"))) {

                    itemlist.append(" <shop:HomeAppliances> "); //() HomeAppliancesSummaryType
                    itemlist.append(" <shop:ItemName>" + rs.getString("string1") + "</shop:ItemName> "); //
                    itemlist.append(" <shop:ModelName>" + rs.getString("string1") + "</shop:ModelName> "); //
                    //itemlist.append(" <shop:Certified> string </shop:Certified> "); //  
                    itemlist.append(" <shop:RatedVoltage>" + rs.getString("string3") + "</shop:RatedVoltage> "); //
                    itemlist.append(
                            " <shop:PowerConsumption>" + rs.getString("string3") + "</shop:PowerConsumption> "); //
                    itemlist.append(" <shop:EnergyEfficiencyRating>" + rs.getString("string3")
                            + "</shop:EnergyEfficiencyRating> "); //
                    itemlist.append(" <shop:ReleaseDate>" + rs.getString("string4") + "</shop:ReleaseDate> "); //  'yyyy-mm'
                    itemlist.append(" <shop:Manufacturer>" + rs.getString("string5") + "</shop:Manufacturer> "); //
                    itemlist.append(" <shop:Size>" + rs.getString("string7") + "</shop:Size> "); //
                    itemlist.append(
                            " <shop:WarrantyPolicy>" + rs.getString("string8") + "</shop:WarrantyPolicy> "); //
                    itemlist.append(
                            " <shop:AfterServiceDirector>" + "1577-1533" + "</shop:AfterServiceDirector> "); //a/s               
                    itemlist.append(" </shop:HomeAppliances>"); //()

                } else if ("17".equals(rs.getString("kind")) || "18".equals(rs.getString("kind"))) {

                    itemlist.append(" <shop:MedicalAppliances> "); // MedicalAppliancesSummaryType
                    itemlist.append(" <shop:ItemName>" + rs.getString("string1") + "</shop:ItemName> "); //
                    itemlist.append(" <shop:ModelName>" + rs.getString("string1") + "</shop:ModelName> "); //
                    itemlist.append(" <shop:LicenceNo>" + rs.getString("string2") + "</shop:LicenceNo> "); // 
                    //itemlist.append(" <shop:AdvertisingCertified> string </shop:AdvertisingCertified> "); //
                    //itemlist.append(" <shop:Certified> string </shop:Certified> "); //kc
                    itemlist.append(" <shop:RatedVoltage>" + rs.getString("string4") + "</shop:RatedVoltage> "); //
                    itemlist.append(
                            " <shop:PowerConsumption>" + rs.getString("string4") + "</shop:PowerConsumption> "); //
                    itemlist.append(" <shop:ReleaseDate>" + rs.getString("string5") + "</shop:ReleaseDate> "); // 'yyyy-mm'
                    itemlist.append(" <shop:Manufacturer>" + rs.getString("string6") + "</shop:Manufacturer> "); //
                    itemlist.append(" <shop:Purpose>" + rs.getString("string8") + "</shop:Purpose> "); //
                    itemlist.append(" <shop:Usage><![CDATA[" + rs.getString("string8") + "]]></shop:Usage> "); //
                    itemlist.append(" <shop:Caution>" + rs.getString("string9") + "</shop:Caution> "); //
                    itemlist.append(
                            " <shop:WarrantyPolicy>" + rs.getString("string10") + "</shop:WarrantyPolicy> "); //
                    itemlist.append(
                            " <shop:AfterServiceDirector>" + "1577-1533" + "</shop:AfterServiceDirector> "); //a/s               
                    itemlist.append(" </shop:MedicalAppliances>"); //

                } else if ("11".equals(rs.getString("kind")) || "12".equals(rs.getString("kind"))) {

                    itemlist.append(" <shop:Cosmetic>"); // CosmeticSummaryType
                    itemlist.append(" <shop:Capacity>" + rs.getString("string1") + "</shop:Capacity> "); // 
                    itemlist.append(
                            " <shop:Specification>" + rs.getString("string2") + "</shop:Specification> "); // 
                    //itemlist.append(" <shop:ExpirationDate> string </shop:ExpirationDate> "); //  
                    itemlist.append(" <shop:ExpirationDateText>" + rs.getString("string3")
                            + "</shop:ExpirationDateText> "); //  ()
                    itemlist.append(" <shop:Usage><![CDATA[" + rs.getString("string4") + "]]></shop:Usage> "); //
                    itemlist.append(" <shop:Manufacturer>" + rs.getString("string5") + "</shop:Manufacturer> "); //
                    itemlist.append(" <shop:Distributor>" + rs.getString("string5") + "</shop:Distributor> "); //
                    itemlist.append(
                            " <shop:MainIngredient>" + rs.getString("string7") + "</shop:MainIngredient> "); //
                    //itemlist.append(" <shop:Certified> string </shop:Certified> "); //  Y,N
                    itemlist.append(" <shop:Caution>" + rs.getString("string9") + "</shop:Caution> "); //
                    itemlist.append(
                            " <shop:WarrantyPolicy>" + rs.getString("string10") + "</shop:WarrantyPolicy> "); //
                    itemlist.append(" <shop:CustomerServicePhoneNumber>" + "1577-1533"
                            + "</shop:CustomerServicePhoneNumber> "); //                  
                    itemlist.append(" </shop:Cosmetic>"); //

                } else if ("9".equals(rs.getString("kind")) || "10".equals(rs.getString("kind"))) {

                    itemlist.append(" <shop:Jewellery> "); // JewellerySummaryType
                    itemlist.append(" <shop:Material>" + rs.getString("string1") + "</shop:Material> "); //
                    itemlist.append(" <shop:Purity>" + rs.getString("string1") + "</shop:Purity> "); //
                    itemlist.append(" <shop:BandMaterial>" + rs.getString("string1") + "</shop:BandMaterial> "); //
                    itemlist.append(" <shop:Weight>" + rs.getString("string2") + "</shop:Weight> "); //
                    itemlist.append(" <shop:Manufacturer>" + rs.getString("string3") + "</shop:Manufacturer> "); //
                    itemlist.append(" <shop:Producer>" + rs.getString("string4") + "</shop:Producer> "); //
                    itemlist.append(" <shop:Size>" + rs.getString("string5") + "</shop:Size> "); //
                    itemlist.append(" <shop:Caution>" + rs.getString("string6") + "</shop:Caution> "); //
                    itemlist.append(
                            " <shop:Specification>" + rs.getString("string7") + "</shop:Specification> "); //
                    //itemlist.append(" <shop:ProvideWarranty>" + rs.getString("string8") + "</shop:ProvideWarranty> "); // Y,N
                    itemlist.append(" <shop:ProvideWarranty>N</shop:ProvideWarranty> "); // Y,N
                    itemlist.append(
                            " <shop:WarrantyPolicy>" + rs.getString("string9") + "</shop:WarrantyPolicy> "); // 
                    itemlist.append(
                            " <shop:AfterServiceDirector>" + "1577-1533" + "</shop:AfterServiceDirector> "); //a/s               
                    itemlist.append(" </shop:Jewellery>"); //

                } else if ("15".equals(rs.getString("kind")) || "16".equals(rs.getString("kind"))) {

                    itemlist.append(" <shop:DietFood> "); //    DietFoodSummaryType
                    itemlist.append(" <shop:FoodType>" + rs.getString("string1") + "</shop:FoodType> "); //
                    itemlist.append(" <shop:Producer>" + rs.getString("string2") + "</shop:Producer> "); //
                    itemlist.append(" <shop:Location>" + rs.getString("string2") + "</shop:Location> "); //
                    //itemlist.append(" <shop:PackDate> string </shop:PackDate> "); //
                    itemlist.append(" <shop:PackDateText>" + rs.getString("string3") + "</shop:PackDateText> "); //()
                    //itemlist.append(" <shop:ExpirationDate> string </shop:ExpirationDate> "); //  
                    itemlist.append(" <shop:ExpirationDateText>" + rs.getString("string3")
                            + "</shop:ExpirationDateText> "); //  ()
                    itemlist.append(" <shop:Weight>" + rs.getString("string4") + "</shop:Weight> "); //
                    itemlist.append(" <shop:Amount>" + rs.getString("string4") + "</shop:Amount> "); // 
                    itemlist.append(" <shop:Ingredients>" + rs.getString("string5") + "</shop:Ingredients> "); //  
                    itemlist.append(
                            " <shop:NutritionFacts>" + rs.getString("string6") + "</shop:NutritionFacts> "); //
                    itemlist.append(
                            " <shop:Specification>" + rs.getString("string7") + "</shop:Specification> "); //
                    itemlist.append(" <shop:CautionAndSideEffect>" + rs.getString("string8")
                            + "</shop:CautionAndSideEffect> "); //,   
                    itemlist.append(" <shop:NonMedicinalUsesMessage>" + rs.getString("string9")
                            + "</shop:NonMedicinalUsesMessage> "); //      
                    itemlist.append(" <shop:GeneticallyModified>" + rs.getString("string10")
                            + "</shop:GeneticallyModified> "); //      y,n
                    //itemlist.append(" <shop:AdvertisingCertified> string </shop:AdvertisingCertified> "); //   
                    itemlist.append(" <shop:ImportDeclarationCheck>" + rs.getString("string12")
                            + "</shop:ImportDeclarationCheck> "); //     y,n
                    itemlist.append(" <shop:CustomerServicePhoneNumber>" + "1577-1533"
                            + "</shop:CustomerServicePhoneNumber> "); // 
                    itemlist.append(" </shop:DietFood>   "); //   

                }

                /*
                 *   end 20121112
                 */

                itemlist.append("            </shop:ProductSummary>");

                itemlist.append("      </Product>");
                itemlist.append("      </shop:ManageProductRequest>");
                itemlist.append("      </soap:Body>");
                itemlist.append("      </soap:Envelope>");

                System.out.println("itemlist.toString():" + itemlist.toString());

                /************************************/
                int pre_cnt = 0;

                StringBuffer unitCnt1 = new StringBuffer();

                unitCnt1.append(" select count(*) cnt \n");
                unitCnt1.append(" from ( \n");
                unitCnt1.append(
                        "  select nvl(b.coven_id,0) coven_id,a.unit_name,nvl(b.co_unit_id,0) co_unit_id,a.unit_id,a.vir_stock_qty,decode(a.use_yn,'Y','Y','N') use_yn  \n");
                unitCnt1.append(" from ktc_unit a,ktc_unit_interlock b \n");
                unitCnt1.append(" where a.unit_id = b.unit_id(+)  \n");
                unitCnt1.append(" and a.unit_name is not null  \n");
                unitCnt1.append(" and a.item_id = ? \n");
                unitCnt1.append(" )where  coven_id in (27346)    \n");

                try {
                    PreparedStatement pstmt3 = null;
                    ResultSet rs3 = null;

                    pstmt3 = conn.prepareStatement(unitCnt1.toString());
                    pstmt3.setString(1, n_item_id); // h_order_no
                    rs3 = pstmt3.executeQuery();

                    while (rs3.next()) {
                        pre_cnt = rs3.getInt("cnt");
                    }

                    /*if (pre_cnt > 0) {
                       NaverShopnSendItem.run4(item_id, n_item_id, pre_cnt); // 
                            
                    }*/

                    if (rs3 != null)
                        try {
                            rs3.close();
                        } catch (Exception e) {
                        }
                    if (pstmt3 != null)
                        try {
                            pstmt3.close();
                        } catch (Exception e) {
                        }
                } catch (Exception e) {
                    System.out.println("() : " + e.getMessage());
                } finally {
                }

                /**********************************/

                if (item_id != null && pre_cnt > 0) { //     .
                    try {
                        StringBuffer unitCnt = new StringBuffer();

                        unitCnt.append(" select count(*) cnt \n");
                        unitCnt.append(" from ( \n");
                        unitCnt.append(
                                "  select decode(b.coven_id,27346,b.coven_id,0) coven_id,a.unit_name,decode(b.coven_id,27346,b.co_unit_id,0) co_unit_id,a.unit_id,a.vir_stock_qty,decode(a.use_yn,'Y','Y','N') use_yn   \n");
                        unitCnt.append(" from ktc_unit a,ktc_unit_interlock b \n");
                        unitCnt.append(" where a.unit_id = b.unit_id(+)  \n");
                        unitCnt.append(" and a.unit_name is not null  \n");
                        unitCnt.append(" and a.item_id = ? \n");
                        unitCnt.append(" )where  coven_id in (27346,0)    \n");

                        System.out.println("   !!!!!!!!!!!!");
                        try {
                            PreparedStatement pstmt3 = null;
                            ResultSet rs3 = null;

                            pstmt3 = conn.prepareStatement(unitCnt.toString());
                            pstmt3.setString(1, n_item_id); // h_order_no
                            rs3 = pstmt3.executeQuery();
                            int cnt = 0;

                            while (rs3.next()) {
                                cnt = rs3.getInt("cnt");
                            }

                            if (cnt > 0) {
                                NaverShopnSendItem.run4(item_id, n_item_id, cnt); // 

                            }

                            if (rs3 != null)
                                try {
                                    rs3.close();
                                } catch (Exception e) {
                                }
                            if (pstmt3 != null)
                                try {
                                    pstmt3.close();
                                } catch (Exception e) {
                                }
                        } catch (Exception e) {
                            System.out.println("() : " + e.getMessage());
                        } finally {
                        }
                    } catch (Exception e) {
                        System.out.println("() : " + e.getMessage());
                    } finally {
                    }
                }

                String line_total = "";
                URL url = new URL("http://ec.api.naver.com/ShopN/ProductService");
                HttpURLConnection con = (HttpURLConnection) url.openConnection();
                con.setDoOutput(true);
                con.setRequestMethod("POST");
                con.setDoOutput(true);
                //      .  true.
                con.setDoInput(true);
                con.setUseCaches(false);
                con.setDefaultUseCaches(false);
                // Header  
                con.addRequestProperty("Content-Type", "text/xml;charset=UTF-8");

                // BODY  
                OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream(), "UTF-8");
                wr.write(itemlist.toString());
                wr.flush();

                //   
                String inputLine = null;
                BufferedReader rd = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));

                while ((inputLine = rd.readLine()) != null) {
                    line_total = line_total + inputLine;
                    System.out.println(inputLine);
                }

                rd.close();
                wr.close();

                line_total = line_total.replaceAll("n:", "");
                //System.out.println(line_total);

                // xml2
                InputStream in = new ByteArrayInputStream(line_total.getBytes("UTF-8"));

                SAXBuilder builder = new SAXBuilder();
                Document document = builder.build(in);

                Element element = document.getRootElement();
                List envel_list = element.getChildren();
                //System.out.println("envel_list:" + envel_list);

                List body_list = null;
                List body_list1 = null;
                List result_list = null;
                List result_list1 = null;
                List result_list2 = null;
                List result_list3 = null;
                List result_list4 = null;
                List result_list5 = null;
                List info_list = null;
                List contr_group_list = null;
                List contr_info_list = null;

                PreparedStatement pstmt2 = null;
                ResultSet rs2 = null;
                CallableStatement cStmt2 = null;

                Element envel_el = (Element) envel_list.get(0);
                body_list = envel_el.getChildren();

                Element body_el = (Element) body_list.get(0);
                result_list = body_el.getChildren("ManageProductResponse");

                ResponseType = body_el.getChildText("ResponseType");
                ProductId = body_el.getChildText("ProductId");
                System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
                System.out.println("ResponseType:" + ResponseType);
                System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");

                if (ResponseType.equals("SUCCESS")) {

                    if (item_id == null) {

                        StringBuffer setCovenID = new StringBuffer();
                        setCovenID.append(
                                " insert into ktc_item_interlock(coven_id , co_item_id , item_id ,insert_date,update_date)  \n");
                        setCovenID.append(" values (27346,?,?,sysdate,sysdate)  \n");

                        pstmt2 = conn.prepareStatement(setCovenID.toString());

                        int insert_cnt = 0;

                        try {
                            // pstmt2.clearParameters();

                            // 
                            pstmt2.setString(1, ProductId); //id
                            pstmt2.setString(2, n_item_id); // h_order_no
                            System.out.println("ProductId:" + ProductId);
                            System.out.println("n_item_id:" + n_item_id);

                            pstmt2.executeUpdate();
                            System.out.println("end insert");
                            if (rs2 != null)
                                try {
                                    rs2.close();
                                } catch (Exception e) {
                                }
                            if (pstmt2 != null)
                                try {
                                    pstmt2.close();
                                } catch (Exception e) {
                                }
                        } catch (Exception e) {
                            response_type = "FALSE";
                            e.printStackTrace();
                            conn.rollback();
                        }
                    } else {

                        StringBuffer setCovenID = new StringBuffer();
                        setCovenID.append(" update ktc_item_interlock set   \n");
                        setCovenID.append(" update_date = sysdate  \n");
                        setCovenID.append(" where coven_id = 27346 and item_id = ?  \n");

                        int insert_cnt = 0;
                        pstmt2 = conn.prepareStatement(setCovenID.toString());

                        try {
                            // pstmt2.clearParameters();

                            // 

                            pstmt2.setString(1, n_item_id); // h_order_no
                            pstmt2.executeUpdate();
                            System.out.println("end update22");
                            if (rs2 != null)
                                try {
                                    rs2.close();
                                } catch (Exception e) {
                                }
                            if (pstmt2 != null)
                                try {
                                    pstmt2.close();
                                } catch (Exception e) {
                                }
                        } catch (Exception e) {
                            System.out.println("error() : " + e.getMessage());
                            response_type = "FALSE";
                            e.printStackTrace();
                            conn.rollback();
                        }
                    }

                }

                if (rs2 != null)
                    try {
                        rs2.close();
                    } catch (Exception e) {
                    }
                if (pstmt2 != null)
                    try {
                        pstmt2.close();
                    } catch (Exception e) {
                    }

                System.out.println("pre_cnt:" + pre_cnt);
                if (item_id == null || pre_cnt == 0) { //item_id   
                    StringBuffer unitCnt = new StringBuffer();
                    System.out.println("!!!!");
                    unitCnt.append(" select count(*) cnt \n");
                    unitCnt.append(" from ( \n");
                    unitCnt.append(
                            "  select decode(b.coven_id,27346,b.coven_id,0) coven_id,a.unit_name,decode(b.coven_id,27346,b.co_unit_id,0) co_unit_id,a.unit_id,a.vir_stock_qty,decode(a.use_yn,'Y','Y','N') use_yn   \n");
                    unitCnt.append(" from ktc_unit a,ktc_unit_interlock b \n");
                    unitCnt.append(" where a.unit_id = b.unit_id(+)  \n");
                    unitCnt.append(" and a.unit_name is not null  \n");
                    unitCnt.append(" and a.item_id = ? \n");
                    unitCnt.append(" )where  coven_id in (27346,0)    \n");

                    System.out.println("n_item_id:" + n_item_id);
                    try {
                        PreparedStatement pstmt3 = null;
                        ResultSet rs3 = null;

                        pstmt3 = conn.prepareStatement(unitCnt.toString());
                        pstmt3.setString(1, n_item_id); // h_order_no
                        rs3 = pstmt3.executeQuery();
                        int cnt = 0;

                        while (rs3.next()) {
                            cnt = rs3.getInt("cnt");
                        }

                        if (cnt > 0) {
                            if (pre_cnt == 0) {
                                System.out.println("ProductId:" + item_id);
                                System.out.println("n_item_id:" + n_item_id);
                                System.out.println("cnt:" + cnt);
                                NaverShopnSendItem.run4(ProductId, n_item_id, cnt); // insert
                            } else {

                                NaverShopnSendItem.run4(ProductId, n_item_id, cnt); // update
                                System.out.println("update end");
                            }
                        }

                        if (rs3 != null)
                            try {
                                rs3.close();
                            } catch (Exception e) {
                            }
                        if (pstmt3 != null)
                            try {
                                pstmt3.close();
                            } catch (Exception e) {
                            }
                    } catch (Exception e) {
                        System.out.println("() : " + e.getMessage());
                    } finally {
                    }
                }

            }
            //System.out.println("itemlist:" + itemlist.toString());
            if (rs != null) {
                try {
                    rs.close();
                } catch (Exception e) {
                    response_type = "FALSE";
                }
            }
            if (pstmt != null) {
                try {
                    pstmt.close();
                } catch (Exception e) {
                    response_type = "FALSE";
                }
            }

        } catch (Exception e) {
            System.out.println("run_1() : " + e.getMessage());
        } finally {
        }

        /*   */

    } catch (Exception e) {
        System.out.println("run_2() : " + e.getMessage());
        response_type = "FALSE";
    } finally {
    }

    return response_type;
}

From source file:MenuPrincipal.java

public void cifrarDados_2CERT(byte[] aesPass, InputStream certKeyFile) { //<-- person to share with
    try {//from  w  w  w  . j  av  a2  s.  c o  m
        //
        // CERT ENCRYPT
        //
        //load cert
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        X509Certificate cert = (X509Certificate) cf.generateCertificate(certKeyFile);

        //init provider
        RSAPublicKey rsaPublicKey = (RSAPublicKey) cert.getPublicKey();
        BouncyCastleProvider bcp = new BouncyCastleProvider();
        Security.addProvider(bcp);

        //init cipher
        Cipher encCipher = Cipher.getInstance("RSA", bcp);
        encCipher.init(Cipher.ENCRYPT_MODE, rsaPublicKey);

        //encrypt
        byte[] encAesPass = encCipher.doFinal(aesPass);
        FileOutputStream fout = new FileOutputStream(new java.io.File("encrypted.pass"));
        fout.write(encAesPass);
        fout.flush();
        fout.close();

    } catch (FileNotFoundException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (CertificateException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NoSuchAlgorithmException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NoSuchPaddingException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InvalidKeyException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalBlockSizeException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (BadPaddingException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:MenuPrincipal.java

public byte[] decifrarDados_1CERT(InputStream aesPassFileStream, String pfxFilePath, String pfxFilePass) {

    try {//  ww w . j  a  v  a  2s .  c om
        //
        // CERT DECRYPT
        //

        //set KeyStore with PFX
        KeyStore ks = KeyStore.getInstance("pkcs12");
        ks.load(new FileInputStream(pfxFilePath), pfxFilePass.toCharArray());
        String alias = ks.aliases().nextElement();

        //load PK from KeyStore
        PrivateKey pKey = (PrivateKey) ks.getKey(alias, pfxFilePass.toCharArray());
        X509Certificate cert = (X509Certificate) ks.getCertificate(alias);

        //init provider
        BouncyCastleProvider bcp = new BouncyCastleProvider();
        Security.addProvider(bcp);

        //init cipher
        Cipher encCipher = Cipher.getInstance("RSA", bcp);
        encCipher.init(Cipher.DECRYPT_MODE, pKey);

        //get encrypted AES pass bytes
        int nRead;
        byte[] tempbytes = new byte[1024];
        ByteArrayOutputStream buff = new ByteArrayOutputStream();
        while ((nRead = aesPassFileStream.read(tempbytes, 0, tempbytes.length)) != -1) {
            buff.write(tempbytes, 0, nRead);
        }
        buff.flush();
        byte[] encAesPassBytes = buff.toByteArray();//(!)

        //decrypt AES pass
        return encCipher.doFinal(encAesPassBytes);

    } catch (KeyStoreException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NoSuchAlgorithmException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (CertificateException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnrecoverableKeyException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InvalidKeyException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NoSuchPaddingException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalBlockSizeException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    } catch (BadPaddingException ex) {
        Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex);
    }

    return new byte[0];

}

From source file:assinaBc.java

CMSSignedDataGenerator setUpProvider(final KeyStore keystore) throws Exception {

    Security.addProvider(new BouncyCastleProvider());

    Certificate[] certchain = (Certificate[]) keystore.getCertificateChain(KEY_ALIAS_IN_KEYSTORE);

    final List<Certificate> certlist = new ArrayList<>();

    for (int i = 0, length = certchain == null ? 0 : certchain.length; i < length; i++) {
        certlist.add(certchain[i]);/*from   w  ww  .j  a v a 2  s .c  o m*/
    }
    Store certstore = new JcaCertStore(certlist);

    Certificate cert = keystore.getCertificate(KEY_ALIAS_IN_KEYSTORE);

    ContentSigner signer = new JcaContentSignerBuilder(SIGNATUREALGO).setProvider("BC")
            .build((PrivateKey) (keystore.getKey(KEY_ALIAS_IN_KEYSTORE, KEYSTORE_PASSWORD.toCharArray())));

    CMSSignedDataGenerator generator = new CMSSignedDataGenerator();

    generator.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(
            new JcaDigestCalculatorProviderBuilder().setProvider("BC").build()).build(signer,
                    (X509Certificate) cert));

    generator.addCertificates(certstore);

    return generator;
}

From source file:VerifyDescriptors.java

License:Open Source License

public static void main(String[] args) throws Exception {
    System.out.println("Verifying consensuses...");
    if (Security.getProvider("BC") == null) {
        Security.addProvider(new BouncyCastleProvider());
    }/*  w w w  .  ja v a 2 s .c o m*/
    verifyServerDescriptors();
    verifyConsensuses();
}

From source file:NaverShopnGetCtg.java

public String run() {
    String response_type = "FALSE";
    try {/*from ww w  .  ja v a2  s.co m*/
        SimpleCryptLib SimpleCryptLib = new SimpleCryptLib();
        Security.addProvider(new BouncyCastleProvider());

        String accessLicense = "0100010000f3814c41974dc3e7f98d1cd213fa8b84c396872ff6c1abb57f0d2516f31cfb43";
        String secretKey = "AQABAADKObge3IgWtlgfbo1TaLqHKpjfyGNKYuZbfOZB8m+WJA==";

        String serviceName = "ProductService"; // 
        String id = "eugink";
        String password = "asdf0101";
        String timestamp = null;
        String signature = null;
        String data = null;

        byte[] encryptKey = null;

        String encryptedData = null;
        String decryptedData = null;
        String hashedData = null;

        String operationName = "GetAllCategoryList";
        //String orderID = "200087036";      

        //timestamp create
        timestamp = SimpleCryptLib.getTimestamp();
        System.out.println("timestamp:" + timestamp);

        //generateSign
        data = timestamp + serviceName + operationName;
        signature = SimpleCryptLib.generateSign(data, secretKey);

        //generateKey
        encryptKey = SimpleCryptLib.generateKey(timestamp, secretKey);

        //encrypt
        encryptedData = SimpleCryptLib.encrypt(encryptKey, password.getBytes("UTF-8"));

        //decrypt
        decryptedData = new String(SimpleCryptLib.decrypt(encryptKey, encryptedData), "UTF-8");

        //sha256
        hashedData = SimpleCryptLib.sha256(password);

        NaverShopnGetCtg NaverShopnGetCtg = new NaverShopnGetCtg();
        System.out.println("NaverShopnGetCtg.getYesterday():" + NaverShopnGetCtg.getYesterday());
        System.out.println("NaverShopnGetCtg.getYesterday():" + NaverShopnGetCtg.getToday());

        System.out.println("accessLicense : [" + accessLicense + "]");
        System.out.println("secretKey : [" + secretKey + "]");
        System.out.println("serviceName : [" + serviceName + "]");
        System.out.println("operationName : [" + operationName + "]");
        System.out.println("timestamp : [" + timestamp + "]");
        System.out.println("signature : [" + signature + "]");
        System.out.println("encryptKey : [" + new String(Hex.encode(encryptKey)) + "]");
        System.out.println("encryptedData : [" + encryptedData + "]");
        System.out.println("decryptedData : [" + decryptedData + "]");
        System.out.println("sha256Data : [" + hashedData + "]");

        /*String xmldata = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:mall=\"http://mall.checkout.platform.nhncorp.com/\" xmlns:base=\"http://base.checkout.platform.nhncorp.com/\">" +
             "<soapenv:Header/>" +
             "<soapenv:Body>" +
                "<mall:GetOrderInfoRequest>" +
                   "<base:RequestID>?</base:RequestID>" +
                   "<base:AccessCredentials>" +
                      "<base:AccessLicense>"+ accessLicense +"</base:AccessLicense>" +
                      "<base:Timestamp>"+ timestamp +"</base:Timestamp>" +
                      "<base:Signature>"+ signature +"</base:Signature>" +
                   "</base:AccessCredentials>" +
                   "<base:DetailLevel>Full</base:DetailLevel>" + //<!--  value Full, Compact  )
                   "<base:Version>2.0</base:Version>" +
                   "<OrderID>"+ orderID +"</OrderID>" +
                "</mall:GetOrderInfoRequest>" +
             "</soapenv:Body>" +
          "</soapenv:Envelope>";*/

        System.out.println("NaverShopnGetCtg.getYesterday():" + NaverShopnGetCtg.getYesterday());
        System.out.println("NaverShopnGetCtg.getToday():" + NaverShopnGetCtg.getToday());
        String ctglist = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:shop=\"http://shopn.platform.nhncorp.com/\">"
                + "<soap:Header/>" + "<soap:Body>" + "<shop:GetAllCategoryListRequest>" + "<!--Optional:-->"
                + "<shop:RequestID>njoyny2</shop:RequestID>" + "<shop:AccessCredentials>"
                + "<shop:AccessLicense>" + accessLicense + "</shop:AccessLicense>" + "<shop:Timestamp>"
                + timestamp + "</shop:Timestamp>" + "<shop:Signature>" + signature + "</shop:Signature>"
                + "</shop:AccessCredentials>" + "<shop:Version>1.0</shop:Version>" + "<!--Optional:-->"
                + "<Last>N</Last>" +
                //"<CategoryId></CategoryId>" +
                "</shop:GetAllCategoryListRequest>" + "</soap:Body>" + "</soap:Envelope>";

        //Create socket
        String hostname = "sandbox.api.naver.com";
        //String hostname = "api.naver.com";
        int port = 80;
        InetAddress addr = InetAddress.getByName(hostname);
        Socket sock = new Socket(addr, port);

        //Send header 
        String path = "/ShopN/ProductService";
        BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(), "UTF-8"));
        // You can use "UTF8" for compatibility with the Microsoft virtual machine.
        wr.write("POST " + path + " HTTP/1.0 \r\n");
        wr.write("Host: sandbox.api.naver.com \r\n");
        //wr.write("Host: api.naver.com \r\n");
        //wr.write("Content-Length: " + xmldata.length() + "\r\n");
        wr.write("Content-Length: " + ctglist.length() + "\r\n");
        wr.write("Content-Type: text/xml; charset=\"UTF-8\"\r\n");
        wr.write("SOAPAction: \"http://sandbox.api.naver.com/ShopN/ProductService\" \r\n");
        //wr.write("SOAPAction: \"http://api.naver.com/Checkout/MallService2\" \r\n");
        wr.write("\r\n");

        //Send data
        //wr.write(xmldata);
        wr.write(ctglist);
        wr.flush();
        // InputStream test = new InputStream(sock.getInputStream(),"UTF-8");   

        // Response
        BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream(), "UTF-8"));
        String line = "";
        String line_total = "";
        String tmp = "";
        String tmp2 = "";
        String newxml = "";

        while ((line = rd.readLine()) != null) {
            if (line.startsWith("<?xml")) {
                line = line.replaceAll("&#xd;", " ");
                line_total = line_total + line;
                System.out.println(line);
            }

        }

        StringBuffer sf = new StringBuffer();
        /* while((line = rd.readLine()) != null){
           if (line.startsWith("<?xml")){
              sf.append(line+"\n");        //   .
           }
        }*/

        //char[] bufferResult = new char[1048576];
        /* char[] bufferResult = new char[60000000];
         int index = -1;
         while((index = rd.read(bufferResult)) != -1) {
                
        sf.append(bufferResult, 135, index); //response   133 135 
                
         }*/

        //line_total = sf.toString().trim();        
        System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");

        line_total = line_total.replaceAll("n:", "");
        //System.out.println(sf.toString().trim());   

        //xml2
        InputStream in = new ByteArrayInputStream(line_total.getBytes("UTF-8"));

        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(in);

        System.out.println("%%%%%%%%%%%%%%%%2222%%%%%%%%%%%%%%%%%");

        Element element = document.getRootElement();
        List envel_list = element.getChildren();
        List body_list = null;
        List body_list1 = null;
        List result_list = null;
        List result_list1 = null;
        List result_list2 = null;
        List result_list3 = null;
        List result_list4 = null;
        List result_list5 = null;
        List info_list = null;
        List contr_group_list = null;
        List contr_info_list = null;

        PreparedStatement pstmt = null;
        ResultSet rs = null;
        CallableStatement cStmt = null;

        //conn.setAutoCommit(false);

        long UNIT_ID = 0;
        long cnt = 0;
        long interface_seq = 0;
        long DEL_QTY = 0;
        long ITEM_ID = 0;
        String ITEM_NAME = null;

        System.out.println("CategoryId.size:" + envel_list.size());
        Element envel_el = (Element) envel_list.get(0);
        body_list = envel_el.getChildren();

        //System.out.println("+++++++11+++++++++++el.getName() : " + envel_el.getChildren());

        //System.out.println("body_list.size:"+body_list.size());
        Element body_el = (Element) body_list.get(0);
        result_list = body_el.getChildren("CategoryList");

        //System.out.println("++++++++22++++++++++el.getName() : " + body_el.getChildren());
        for (int h = 0; h < result_list.size(); h++) {

            Element body_el1 = (Element) result_list.get(h);

            result_list1 = body_el1.getChildren("Category");
            //System.out.println("result_list1.size:"+result_list1.size());

            //System.out.println("++++++++33++++++++++el.getName() : " + body_el1.getChildren());
            for (int i = 0; i < result_list1.size(); i++) {

                Element body_el2 = (Element) result_list1.get(i);
                System.out.println("CategoryName:" + body_el2.getChildText("CategoryName"));
                System.out.println("Id:" + body_el2.getChildText("Id"));
                System.out.println("Name:" + body_el2.getChildText("Name"));
                System.out.println("Last:" + body_el2.getChildText("Last"));
                // 
                StringBuffer setOrder = new StringBuffer();
                setOrder.append(" insert  \n");
                setOrder.append(" into mirus_navershopnctg(  \n");
                setOrder.append("     CategoryName, Id, Name, Last, insert_date ,modify_date \n");
                setOrder.append(" ) values (  \n");
                setOrder.append("     ?, ?, ?, ?, sysdate,null  \n");
                setOrder.append(" )  \n");

                pstmt = conn.prepareStatement(setOrder.toString());

                System.out.println("query:" + setOrder.toString());

                int insert_cnt = 0;

                try {
                    pstmt.clearParameters();

                    //
                    pstmt.setString(1, body_el2.getChildText("CategoryName")); // CategoryName
                    pstmt.setLong(2, Long.parseLong(body_el2.getChildText("Id"))); // Id
                    pstmt.setString(3, body_el2.getChildText("Name")); //Name
                    pstmt.setString(4, body_el2.getChildText("Last")); // Last

                    pstmt.executeUpdate();

                    System.out.println("\n+ insert_cnt [" + i + "]\n");

                } catch (Exception e) {
                    response_type = "FALSE";
                    e.printStackTrace();
                    conn.rollback();
                    break;
                }
                conn.commit();

                if (pstmt != null) {
                    try {
                        pstmt.close();
                    } catch (Exception ex) {
                        response_type = "FALSE";
                    }
                }

                /*
                Element body_el3 = (Element) result_list1.get(i);
                result_list3 = body_el3.getChildren("OrderProductList");
                        
                        
                        
                Element body_el4 = (Element) result_list1.get(i);
                result_list4 = body_el4.getChildren("Shipping");
                        
                */
                /*            
                for (int j = 0; j < result_list2.size(); j++) {
                           
                   Element body_el5 = (Element) result_list2.get(j);//
                   Element body_el7 = (Element) result_list4.get(j);//
                   Element body_el8 = (Element) result_list3.get(j);
                   result_list5 = body_el8.getChildren("OrderProduct");//
                   //result_list5  = (Element) result_list3.get(j);//
                           
                   System.out.println("$$55555$$");
                   if(body_el5.getChildText("OrderStatusCode").equals("OD0002")){//  
                        
                   pstmt = conn.prepareStatement(selectChk.toString());
                   pstmt.setString(1, body_el5.getChildText("OrderID"));
                        
                      rs = pstmt.executeQuery();
                      if(rs.next()) {
                          cnt = rs.getLong("cnt");
                      }
                        
                   System.out.println("  cnt:"+cnt);
                   if(rs!=null) {try{rs.close();} catch(Exception e){ response_type="FALSE";}}
                    if(pstmt!=null) {try{pstmt.close();} catch(Exception e){ response_type="FALSE";}}
                           
                   System.out.println("result_list5.size():"+result_list5.size());
                        
                        
                   for (int k = 0; k < result_list5.size(); k++) {
                              
                      Element body_el9 = (Element) result_list5.get(k);
                        
                      ITEM_NAME = body_el9.getChildText("ProductName");
                      DEL_QTY = Long.parseLong(body_el9.getChildText("Quantity"));
                                                                    
                      pstmt = conn.prepareStatement(getInterfacedata);                           
                      System.out.println("body_el9.getChildText:"+body_el9.getChildText("ProductID"));
                      System.out.println("body_el9.getChildText:"+body_el9.getChildText("ProductOption"));
                      pstmt.setLong(1, Long.parseLong(body_el9.getChildText("ProductID")));
                      pstmt.setString(2, body_el9.getChildText("ProductOption"));
                      pstmt.setLong(3, Long.parseLong(body_el9.getChildText("ProductID")));
                        
                         rs = pstmt.executeQuery();
                         if(rs.next()) {
                             UNIT_ID = rs.getLong("UNIT_ID");
                             ITEM_ID = rs.getLong("ITEM_ID");
                             //DEL_QTY = rs.getLong("DEL_QTY");
                         }
                      System.out.println("UNIT_ID:"+UNIT_ID);
                      System.out.println("ITEM_ID:"+ITEM_ID);
                      System.out.println("ITEM_NAME:"+ITEM_NAME);
                      if(rs!=null) {try{rs.close();} catch(Exception e){ response_type="FALSE";}}
                       if(pstmt!=null) {try{pstmt.close();} catch(Exception e){ response_type="FALSE";}}
                   }//  1 .
                        
                        
                   System.out.println("1111 333331");
                         String getInterfaceSeq = " select ktc_njoyny_hmall_if_seq.nextval interfaceSeq from dual ";
                        
                         pstmt = conn.prepareStatement(getInterfaceSeq);
                      rs = pstmt.executeQuery();
                      if(rs.next()) {
                          interface_seq = rs.getLong("interfaceSeq");
                      }
                        
                         System.out.println("+ interface_seq ["+interface_seq+"]");
                        
                         if(rs!=null) {try{rs.close();} catch(Exception e){ response_type="FALSE";}}
                         if(pstmt!=null) {try{pstmt.close();} catch(Exception e){ response_type="FALSE";}}
                        
                        
                           
                          if(cnt == 0) { //    ..
                             System.out.println("body_el5.getChildText:"+body_el5.getChildText("OrderID"));
                                     
                             if(NaverShopnGetCtg.run2(body_el5.getChildText("OrderID")).equals("SUCCESS")){// 
                                        
                                 StringBuffer setOrder = new StringBuffer();
                                 setOrder.append(" insert  \n");
                                 setOrder.append(" into ktc_njoyny_hmall_if(  \n");
                                 setOrder.append("     h_order_no, seq, order_date, recv_date, item_id,   \n");
                                 setOrder.append("     unit_id, item_name, price, qty, orderer_name,   \n");
                                 setOrder.append("     orderer_phone, orderer_cell_phone, orderer_eng_name, orderer_resi_no, orderer_email,  \n");
                                 setOrder.append("     msg_for_mall, del_plan_date, receiver_name, receiver_phone, receiver_cell_phone,   \n");
                                 setOrder.append("     receiver_zip_code, receiver_addr1, receiver_addr2, msg_for_outbnd, interface_date, \n");
                                 setOrder.append("     interface_seq, sysregdt, coven_id \n");
                                 setOrder.append(" ) values (  \n");
                                 setOrder.append("     'naver_'||?, ktc_njoyny_hmall_if_seq.nextval, to_date(?,'yyyy/mm/dd hh24:mi:ss'), sysdate, ?,  \n");
                                 setOrder.append("     ?, ?, ?, ?, ?,  \n");
                                 setOrder.append("     ?, ?, ?, ?, ?,  \n");
                                 setOrder.append("     ?, sysdate+5, ?, ?, ?,  \n");
                                 setOrder.append("     ?, ?, ?, ?, sysdate,  \n");
                                 setOrder.append("     ?, sysdate, ? \n");
                                 setOrder.append(" )  \n");
                        
                                 pstmt = conn.prepareStatement(setOrder.toString());
                        
                                 int insert_cnt = 0;
                        
                                 try {
                                         pstmt.clearParameters();
                        
                                         //
                                         pstmt.setLong(1, Long.parseLong(body_el5.getChildText("OrderID")) );                           // h_order_no
                                         System.out.println(body_el5.getChildText("OrderID"));
                                         pstmt.setString(2 , body_el5.getChildText("OrderDateTime").substring(0,10));                                 //order_date
                                         System.out.println(body_el5.getChildText("OrderDateTime").substring(0,10));
                                         pstmt.setLong(3 , ITEM_ID);     // item_id
                                           System.out.println(ITEM_ID);
                                           pstmt.setLong(4 , UNIT_ID);   // unit_id
                                         System.out.println(UNIT_ID);
                              
                                         pstmt.setString(5 , ITEM_NAME);     // ITEM_NAME
                                         System.out.println(ITEM_NAME);
                                         pstmt.setLong(6 , Long.parseLong(body_el5.getChildText("TotalProductAmount")));       //price ->  0.95    +  + 
                                         System.out.println(Long.parseLong(body_el5.getChildText("TotalProductAmount")));
                                         pstmt.setLong(7 , DEL_QTY);    //qty
                                         System.out.println(DEL_QTY);
                        
                                         pstmt.setString(8 , new String(SimpleCryptLib.decrypt(encryptKey, body_el5.getChildText("OrdererName")), "UTF-8"));                             // orderer_name
                                         System.out.println(new String(SimpleCryptLib.decrypt(encryptKey, body_el5.getChildText("OrdererName")), "UTF-8"));
                                         pstmt.setString(9 , NaverShopnGetCtg.getTel(new String(SimpleCryptLib.decrypt(encryptKey,body_el5.getChildText("OrdererTel")), "UTF-8")));                               //orderer_phone
                                         System.out.println(NaverShopnGetCtg.getTel(new String(SimpleCryptLib.decrypt(encryptKey, body_el5.getChildText("OrdererTel")), "UTF-8")));
                                         pstmt.setString(10, NaverShopnGetCtg.getTel(new String(SimpleCryptLib.decrypt(encryptKey,body_el5.getChildText("OrdererTel")), "UTF-8")));               // orderer_cell_phone
                                         pstmt.setString(11, null);                      // orderer_eng_name
                                         pstmt.setString(12, null);                      // orderer_resi_no
                                         pstmt.setString(13, null);                      // orderer_email
                                         pstmt.setString(14, body_el7.getChildText("ShippingMessage"));                      // msg_for_mall
                                         pstmt.setString(15, new String(SimpleCryptLib.decrypt(encryptKey,body_el7.getChildText("Recipient")), "UTF-8")); // receiver_name
                                         System.out.println(new String(SimpleCryptLib.decrypt(encryptKey, body_el7.getChildText("Recipient")), "UTF-8"));
                        
                                         pstmt.setString(16, NaverShopnGetCtg.getTel(new String(SimpleCryptLib.decrypt(encryptKey,body_el7.getChildText("RecipientTel1")), "UTF-8")));                    // receiver_phone
                                         System.out.println(NaverShopnGetCtg.getTel(new String(SimpleCryptLib.decrypt(encryptKey, body_el7.getChildText("RecipientTel1")), "UTF-8")));
                        
                                         pstmt.setString(17, NaverShopnGetCtg.getTel(new String(SimpleCryptLib.decrypt(encryptKey,body_el7.getChildText("RecipientTel1")), "UTF-8")));                    // receiver_cell_phone
                                         System.out.println(NaverShopnGetCtg.getTel(new String(SimpleCryptLib.decrypt(encryptKey, body_el7.getChildText("RecipientTel1")), "UTF-8")));
                        
                                         pstmt.setString(18, body_el7.getChildText("ZipCode"));                              //receiver_zip_code
                                         pstmt.setString(19, new String(SimpleCryptLib.decrypt(encryptKey,body_el7.getChildText("ShippingAddress1")), "UTF-8"));                           //receiver_addr1
                                         System.out.println(new String(SimpleCryptLib.decrypt(encryptKey, body_el7.getChildText("ShippingAddress1")), "UTF-8"));
                        
                                         pstmt.setString(20, new String(SimpleCryptLib.decrypt(encryptKey,body_el7.getChildText("ShippingAddress2")), "UTF-8"));                            //receiver_addr2
                                         System.out.println(new String(SimpleCryptLib.decrypt(encryptKey, body_el7.getChildText("ShippingAddress2")), "UTF-8"));
                        
                                         pstmt.setString(21, body_el7.getChildText("ShippingMessage"));                                  // msg_for_outbnd
                                         System.out.println(body_el7.getChildText("ShippingMessage"));
                        
                                         pstmt.setLong(22, interface_seq);                                       // interface_seq
                                         pstmt.setString(23, "26050");                                                   // coven_id
                        
                                         pstmt.executeUpdate();
                        
                                         System.out.println("\n+ insert_cnt ["+i+"]\n");
                        
                        
                                     } catch(Exception e) {
                                           response_type="FALSE";
                                             e.printStackTrace();
                                             conn.rollback();
                                             break;
                                     }
                            conn.commit();
                        
                                     if(pstmt != null) {try{ pstmt.close(); } catch(Exception ex){ response_type="FALSE";}}
                            System.out.println("  ");
                            System.out.println("interface_seq:"+interface_seq);
                                  //  ....
                                  cStmt = conn.prepareCall("{ call CREAT_NJOYNY_HMALL_ORDER(?,?,?) }");
                               cStmt.setLong(1, interface_seq);
                               cStmt.registerOutParameter(2, Types.VARCHAR);
                               cStmt.registerOutParameter(3, Types.VARCHAR);
                               cStmt.executeUpdate();
                               String r_code = cStmt.getString(2);
                               String r_msg = cStmt.getString(3);
                            System.out.println("++++++++++++++++r_code : " + r_code);
                            System.out.println("++++++++++++++++r_msg : " + r_msg);
                                  conn.commit();
                            System.out.println("  ");   
                               if(cStmt != null){ try{ cStmt.close(); } catch(Exception e){ response_type="FALSE";}}
                               conn.setAutoCommit(true);
                              response_type="TRUE";
                              }else{
                                 System.out.println("  " );
                              }
                              }else{
                                      System.out.println("  =.." );
                              }
                                 cnt = 0; // ..
                        
                        
                        
                              
                   }
                }
                */

            }
        }

    } catch (Exception e) {
        System.out.println("run() : " + e.getMessage());
        response_type = "FALSE";
    } finally {
    }

    return response_type;
}

From source file:testCryptoStrength.java

License:Open Source License

public static void main(String[] args) throws Exception {
    Security.addProvider(new BouncyCastleProvider());
    try {//from  w  w w .  ja  va2s  .c  o  m
        /*KeyPairGenerator dsaKpg = KeyPairGenerator.getInstance("RSA", "BC");
        dsaKpg.initialize(3096);
        KeyPair dsaKp = dsaKpg.generateKeyPair();*/
        /*KeyPairGenerator elgKpg = KeyPairGenerator.getInstance("ELGAMAL", "BC");
        elgKpg.initialize(elParams);
        elgKp = elgKpg.generateKeyPair();*/

        /*KeyGenerator kg = KeyGenerator.getInstance("AES", "BC");
        kg.init(256);
        KerberosKey sk = (KerberosKey) kg.generateKey();*/

        byte[] randomNumber = new byte[32];
        SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        random.nextBytes(randomNumber);
        SecretKeySpec sk = new SecretKeySpec(randomNumber, "AES");
        Cipher c = Cipher.getInstance("AES", "BC");
        c.init(c.ENCRYPT_MODE, (Key) sk);
        byte[] enc = c.doFinal(new String("test").getBytes());

        System.out.println("Unlimited Strength Policy Test Successful\n");
    } catch (SecurityException e) {
        System.out.println("Caught Exception: " + e.toString());
    }
}

From source file:CA.java

License:Apache License

public static void main(String[] args) {
    // The original implementation only consisted of these two calls.
    //Security.insertProviderAt(new DSTC(), 1);
    //com.dstc.security.pki.ConsoleCATool.main(args);
    Security.insertProviderAt(new BouncyCastleProvider(), 1);
    try {/*from   w  w  w.  j  av a2 s .  co  m*/
        if (args[0].equals("-CA")) {
            generateCertificateAuthorityCerts();
            return;
        } else if (args[0].equals("-CR")) {
            signCertificationRequests();
            return;
        } else {
            throw new IllegalArgumentException("Argument required either -CA or -CR");
        }
    } catch (Exception ex) {
        ex.printStackTrace(System.err);
    }
}

From source file:genkeys.java

License:Open Source License

public static void main(String[] args) {
    Security.addProvider(new BouncyCastleProvider());
    Random rand = new Random();

    for (String keyType : keyTypes) {
        System.out.print("Generating " + keyType + " keys... ");
        for (int keyLength : keyLengths) {

            if (keyType == "DSA" && keyLength > 1024) {
                continue;
            }/*from w  w  w  .j a v  a  2 s.  c om*/

            System.out.print(keyLength);
            System.out.print(" ");

            KeyPair kp;
            try {
                kp = generatePair(keyType, keyLength);
            } catch (Exception e) {
                System.err.println("Error generating key: " + e.getMessage());
                continue;
            }

            for (int hash : hashAlgorithms) {
                String dir = String.format("%s/%s/%d/%s", keyDir, keyType, keyLength,
                        hashNames[hash].toLowerCase());
                new File(dir).mkdirs();

                for (int cipher : ciphers) {
                    boolean[] truthValues = { true, false };
                    for (boolean useSHA1 : truthValues) {
                        FileOutputStream out;
                        boolean armor = rand.nextBoolean();
                        try {
                            out = new FileOutputStream(
                                    String.format("%s/%s%s.%s", dir, cipherNames[cipher].toLowerCase(),
                                            (useSHA1 ? "_sha1" : ""), (armor ? "asc" : "pgp")));
                            exportSecretKey(out, kp, cipher, S2K.SALTED_AND_ITERATED, hash, useSHA1,
                                    password(rand), armor);
                        } catch (Exception e) {
                            System.err.println("Error exporting key: " + e.getMessage());
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
        System.out.println();
    }
}