Example usage for java.lang String String

List of usage examples for java.lang String String

Introduction

In this page you can find the example usage for java.lang String String.

Prototype

String(byte[] value, byte coder) 

Source Link

Usage

From source file:io.fabric8.apiman.gateway.ApimanGatewayStarter.java

/**
 * Main entry point for the Apiman Gateway micro service.
 * @param args the arguments// w  w  w.  j av a  2  s  .c o  m
 * @throws Exception when any unhandled exception occurs
 */
public static final void main(String[] args) throws Exception {

    String isTestModeString = Systems.getEnvVarOrSystemProperty(APIMAN_GATEWAY_TESTMODE, "false");
    boolean isTestMode = "true".equalsIgnoreCase(isTestModeString);
    if (isTestMode)
        log.info("Apiman Gateway Running in TestMode");

    String isSslString = Systems.getEnvVarOrSystemProperty(APIMAN_GATEWAY_SSL, "false");
    isSsl = "true".equalsIgnoreCase(isSslString);
    log.info("Apiman Gateway running in SSL: " + isSsl);
    String protocol = "http";
    if (isSsl)
        protocol = "https";

    URL elasticEndpoint = null;

    File gatewayConfigFile = new File(APIMAN_GATEWAY_PROPERTIES);
    String esUsername = null;
    String esPassword = null;
    if (gatewayConfigFile.exists()) {
        PropertiesConfiguration config = new PropertiesConfiguration(gatewayConfigFile);
        esUsername = config.getString("es.username");
        esPassword = config.getString("es.password");
        if (Utils.isNotNullOrEmpty(esPassword))
            esPassword = new String(Base64.getDecoder().decode(esPassword), StandardCharsets.UTF_8).trim();
        setConfigProp(APIMAN_GATEWAY_ES_USERNAME, esUsername);
        setConfigProp(APIMAN_GATEWAY_ES_PASSWORD, esPassword);
    }
    log.info(esUsername + esPassword);

    // Require ElasticSearch and the Gateway Services to to be up before proceeding
    if (isTestMode) {
        URL url = new URL(protocol + "://localhost:9200");
        elasticEndpoint = waitForDependency(url, "elasticsearch-v1", "status", "200", esUsername, esPassword);
    } else {
        String defaultEsUrl = protocol + "://elasticsearch-v1:9200";
        String esURL = Systems.getEnvVarOrSystemProperty(APIMAN_GATEWAY_ELASTICSEARCH_URL, defaultEsUrl);
        URL url = new URL(esURL);
        elasticEndpoint = waitForDependency(url, "elasticsearch-v1", "status", "200", esUsername, esPassword);
        log.info("Found " + elasticEndpoint);
    }

    File usersFile = new File(APIMAN_GATEWAY_USER_PATH);
    if (usersFile.exists()) {
        setConfigProp(Users.USERS_FILE_PROP, APIMAN_GATEWAY_USER_PATH);
    }

    log.info("** ******************************************** **");

    Fabric8GatewayMicroService microService = new Fabric8GatewayMicroService(elasticEndpoint);

    if (isSsl) {
        microService.startSsl();
        microService.joinSsl();
    } else {
        microService.start();
        microService.join();
    }
}

From source file:io.fabric8.apiman.ApimanStarter.java

/**
 * Main entry point for the API Manager micro service.
 * @param args the arguments/*from   w w  w .  j a  v a  2 s.c  om*/
 * @throws Exception when any unhandled exception occurs
 */
public static final void main(String[] args) throws Exception {

    Fabric8ManagerApiMicroService microService = new Fabric8ManagerApiMicroService();

    boolean isTestMode = getSystemPropertyOrEnvVar(APIMAN_TESTMODE, false);
    if (isTestMode)
        log.info("Apiman running in TestMode");

    boolean isSsl = getSystemPropertyOrEnvVar(APIMAN_SSL, false);
    log.info("Apiman running in SSL: " + isSsl);
    String protocol = "http";
    if (isSsl)
        protocol = "https";

    File apimanConfigFile = new File(APIMAN_PROPERTIES);
    String esUsername = null;
    String esPassword = null;
    if (apimanConfigFile.exists()) {
        PropertiesConfiguration config = new PropertiesConfiguration(apimanConfigFile);
        esUsername = config.getString("es.username");
        esPassword = config.getString("es.password");
        if (Utils.isNotNullOrEmpty(esPassword))
            esPassword = new String(Base64.getDecoder().decode(esPassword), StandardCharsets.UTF_8).trim();
        setConfigProp(APIMAN_ELASTICSEARCH_USERNAME, esUsername);
        setConfigProp(APIMAN_ELASTICSEARCH_PASSWORD, esPassword);
    }
    URL elasticEndpoint = null;
    // Require ElasticSearch and the Gateway Services to to be up before proceeding
    if (isTestMode) {
        URL url = new URL("https://localhost:9200");
        elasticEndpoint = waitForDependency(url, "", "elasticsearch-v1", "status", "200", esUsername,
                esPassword);
    } else {
        String defaultEsUrl = protocol + "://elasticsearch-v1:9200";
        String esURL = getSystemPropertyOrEnvVar(APIMAN_ELASTICSEARCH_URL, defaultEsUrl);
        URL url = new URL(esURL);
        elasticEndpoint = waitForDependency(url, "", "elasticsearch-v1", "status", "200", esUsername,
                esPassword);
        log.info("Found " + elasticEndpoint);
        String defaultGatewayUrl = protocol + "://apiman-gateway:7777";
        gatewayUrl = getSystemPropertyOrEnvVar(APIMAN_GATEWAY_URL, defaultGatewayUrl);

        URL gatewayEndpoint = waitForDependency(new URL(gatewayUrl), "/api/system/status", "apiman-gateway",
                "up", "true", null, null);
        log.info("Found " + gatewayEndpoint);
    }

    setConfigProp("apiman.plugins.repositories", "http://repo1.maven.org/maven2/");
    setConfigProp("apiman-manager.plugins.registries",
            "http://cdn.rawgit.com/apiman/apiman-plugin-registry/1.2.6.Final/registry.json");
    setFabric8Props(elasticEndpoint);
    if (isSsl) {
        microService.startSsl();
        microService.joinSsl();
    } else {
        microService.start();
        microService.join();
    }
}

From source file:com.athena.peacock.agent.sample.CommandExecutorSample.java

/**
 * <pre>/*from ww  w . j ava2 s.co m*/
 * 
 * </pre>
 * @param args
 * @throws CommandLineException 
 * @throws IOException 
 */
public static void main(String[] args) throws CommandLineException, IOException {

    // Windows wmic usage
    // http://blog.naver.com/PostView.nhn?blogId=diadld2&logNo=30157625015
    // http://www.petenetlive.com/KB/Article/0000619.htm

    OSType osType = OSUtil.getOSName();

    File executable = null;
    Commandline commandLine = null;

    if (osType.equals(OSType.WINDOWS)) {
        executable = new File("C:\\Windows\\System32\\wbem\\WMIC.exe");
        commandLine = new Commandline();
        commandLine.setExecutable(executable.getAbsolutePath());

        //commandLine.setExecutable("wmic");  // available only that command is in path

        /** change working directory if necessary */
        commandLine.setWorkingDirectory("/");

        /** invoke createArg() and setValue() one by one for each arguments */
        commandLine.createArg().setValue("product");
        commandLine.createArg().setValue("get");
        commandLine.createArg().setValue("name,vendor,version");

        /** invoke createArg() and setLine() for entire arguments */
        //commandLine.createArg().setLine("product get name,vendor,version");

        /** verify command string */
        System.out.println("C:\\> " + commandLine.toString() + "\n");
    } else {
        executable = new File("/bin/cat");
        commandLine = new Commandline();
        commandLine.setExecutable(executable.getAbsolutePath());

        /** change working directory if necessary */
        commandLine.setWorkingDirectory("/");

        /** invoke createArg() and setValue() one by one for each arguments */
        commandLine.createArg().setValue("-n");
        commandLine.createArg().setValue("/etc/hosts");

        /** invoke createArg() and setLine() for entire arguments */
        //commandLine.createArg().setLine("-n /etc/hosts");

        /** verify command string */
        System.out.println("~]$ " + commandLine.toString() + "\n");
    }

    /** also enable StringWriter, PrintWriter, WriterStreamConsumer and etc. */
    StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer();

    int returnCode = CommandLineUtils.executeCommandLine(commandLine, consumer, consumer, Integer.MAX_VALUE);

    if (returnCode == 0) {
        // success
        System.out.println("==============[SUCCEED]==============");
        System.out.println("[" + consumer.getOutput().substring(0, consumer.getOutput().length() - 1) + "]");

        if (osType.equals(OSType.WINDOWS)) {
            List<Product> productList = parse(consumer.getOutput());
            for (Product product : productList) {
                System.out.println(product);
            }

            int UTF_8 = 0x01;
            int EUC_KR = 0x02;
            int KSC5601 = 0x04;
            int MS949 = 0x08;
            int ISO8859_1 = 0x10;

            int mode = 0x00;
            //mode ^= UTF_8;
            //mode ^= EUC_KR;
            //mode ^= KSC5601;
            //mode ^= MS949;
            //mode ^= ISO8859_1;

            if ((mode & UTF_8) == UTF_8) {
                System.out.println("+:+:+:+: UTF-8 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes(), "UTF-8"));
                System.out.println("+:+:+:+: EUC-KR => UTF-8 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("EUC-KR"), "UTF-8"));
                System.out.println("+:+:+:+: KSC5601 => UTF-8 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("KSC5601"), "UTF-8"));
                System.out.println("+:+:+:+: MS949 => UTF-8 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("MS949"), "UTF-8"));
                System.out.println("+:+:+:+: ISO8859_1 => UTF-8 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("ISO8859_1"), "UTF-8"));
            }
            if ((mode & EUC_KR) == EUC_KR) {
                System.out.println("+:+:+:+: EUC-KR +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes(), "EUC-KR"));
                System.out.println("+:+:+:+: UTF-8 => EUC-KR +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("UTF-8"), "EUC-KR"));
                System.out.println("+:+:+:+: KSC5601 => EUC-KR +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("KSC5601"), "EUC-KR"));
                System.out.println("+:+:+:+: MS949 => EUC-KR +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("MS949"), "EUC-KR"));
                System.out.println("+:+:+:+: ISO8859_1 => EUC-KR +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("ISO8859_1"), "EUC-KR"));
            }
            if ((mode & KSC5601) == KSC5601) {
                System.out.println("+:+:+:+: KSC5601 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes(), "KSC5601"));
                System.out.println("+:+:+:+: EUC-KR => KSC5601 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("EUC-KR"), "KSC5601"));
                System.out.println("+:+:+:+: UTF-8 => KSC5601 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("UTF-8"), "KSC5601"));
                System.out.println("+:+:+:+: MS949 => KSC5601 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("MS949"), "KSC5601"));
                System.out.println("+:+:+:+: ISO8859_1 => KSC5601 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("ISO8859_1"), "KSC5601"));
            }
            if ((mode & MS949) == MS949) {
                System.out.println("+:+:+:+: MS949 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes(), "MS949"));
                System.out.println("+:+:+:+: EUC-KR => MS949 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("EUC-KR"), "MS949"));
                System.out.println("+:+:+:+: UTF-8 => MS949 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("UTF-8"), "MS949"));
                System.out.println("+:+:+:+: KSC5601 => MS949 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("KSC5601"), "MS949"));
                System.out.println("+:+:+:+: ISO8859_1 => MS949 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("ISO8859_1"), "MS949"));
            }
            if ((mode & ISO8859_1) == ISO8859_1) {
                System.out.println("+:+:+:+: ISO8859_1 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes(), "ISO8859_1"));
                System.out.println("+:+:+:+: EUC-KR => ISO8859_1 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("EUC-KR"), "ISO8859_1"));
                System.out.println("+:+:+:+: UTF-8 => ISO8859_1 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("UTF-8"), "ISO8859_1"));
                System.out.println("+:+:+:+: KSC5601 => ISO8859_1 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("KSC5601"), "ISO8859_1"));
                System.out.println("+:+:+:+: MS949 => ISO8859_1 +:+:+:+:");
                System.out.println(new String(consumer.getOutput().getBytes("MS949"), "ISO8859_1"));
            }
        }
    } else {
        // fail
        System.err.println("==============[FAILED]==============");
        System.err.println(consumer.getOutput());
    }
}

From source file:com.cisco.dvbu.ps.common.adapters.core.CisWsClient.java

public static void main(String[] args) throws Exception {
    if (args.length < 8) {
        System.err.println(/*from  w w  w.  jav  a 2  s  . co m*/
                "usage: java com.cisco.dvbu.ps.common.adapters.core.CisWsClient endpointName endpointMethod configXml requestXml host port user password <domain>");
        System.exit(1);
    }
    org.apache.log4j.BasicConfigurator.configure();
    // DEBUG, INFO, ERROR
    org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.DEBUG);
    String endpointName = args[0]; // "server"
    String endpointMethod = args[1]; // "getServerAttributes"
    String adapterConfigPath = args[2]; // E:\dev\Workspaces\PDToolGitTest\PDTool_poc\resources\config\6.2.0\cis_adapter_config.xml
    String requestXMLPath = args[3]; // path to request xml

    Properties props = new Properties();
    props.setProperty(AdapterConstants.ADAPTER_HOST, args[4]);
    props.setProperty(AdapterConstants.ADAPTER_PORT, args[5]);
    props.setProperty(AdapterConstants.ADAPTER_USER, args[6]);
    props.setProperty(AdapterConstants.ADAPTER_PSWD, args[7]);
    if (args.length == 9)
        props.setProperty(AdapterConstants.ADAPTER_DOMAIN, args[8]);

    // Read the request xml file
    FileInputStream input = new FileInputStream(requestXMLPath);
    byte[] fileData = new byte[input.available()];
    input.read(fileData);
    input.close();
    String requestXml = new String(fileData, "UTF-8");

    // Execute the CIS Web Service Client for an adapter configuration
    CisWsClient cisclient = new CisWsClient(props, adapterConfigPath);

    System.out.println("Request: " + requestXml);
    // String requestXml = "<?xml version=\"1.0\"?> <p1:ServerAttributeModule xmlns:p1=\"http://www.dvbu.cisco.com/ps/deploytool/modules\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.dvbu.cisco.com/ps/deploytool/modules file:///e:/dev/Workspaces/PDToolGitTest/PDToolModules/schema/PDToolModules.xsd\">     <!--Element serverAttribute, maxOccurs=unbounded-->     <serverAttribute>         <id>sa1</id>         <name>/server/event/generation/sessions/sessionLoginFail</name>         <type>UNKNOWN</type>         <!--Element value is optional-->         <value>string</value>         <!--Element valueArray is optional-->         <valueArray>             <!--Element item is optional, maxOccurs=unbounded-->             <item>string</item>             <item>string</item>             <item>string</item>         </valueArray>         <!--Element valueList is optional-->         <valueList>             <!--Element item is optional, maxOccurs=unbounded-->             <item>                 <!--Element type is optional-->                 <type>UNKNOWN</type>                 <!--Element value is optional-->                 <value>string</value>             </item>             <item>                 <!--Element type is optional-->                 <type>UNKNOWN</type>                 <!--Element value is optional-->                 <value>string</value>             </item>             <item>                 <!--Element type is optional-->                 <type>UNKNOWN</type>                 <!--Element value is optional-->                 <value>string</value>             </item>         </valueList>         <!--Element valueMap is optional-->         <valueMap>             <!--Element entry is optional, maxOccurs=unbounded-->             <entry>                 <!--Element key is optional-->                 <key>                     <!--Element type is optional-->                     <type>UNKNOWN</type>                     <!--Element value is optional-->                     <value>string</value>                 </key>                 <!--Element value is optional-->                 <value>                     <!--Element type is optional-->                     <type>UNKNOWN</type>                     <!--Element value is optional-->                     <value>string</value>                 </value>             </entry>             <entry>                 <!--Element key is optional-->                 <key>                     <!--Element type is optional-->                     <type>UNKNOWN</type>                     <!--Element value is optional-->                     <value>string</value>                 </key>                 <!--Element value is optional-->                 <value>                     <!--Element type is optional-->                     <type>UNKNOWN</type>                     <!--Element value is optional-->                     <value>string</value>                 </value>             </entry>             <entry>                 <!--Element key is optional-->                 <key>                     <!--Element type is optional-->                     <type>UNKNOWN</type>                     <!--Element value is optional-->                     <value>string</value>                 </key>                 <!--Element value is optional-->                 <value>                     <!--Element type is optional-->                     <type>UNKNOWN</type>                     <!--Element value is optional-->                     <value>string</value>                 </value>             </entry>         </valueMap>     </serverAttribute> </p1:ServerAttributeModule>";
    String response = cisclient.sendRequest(endpointName, endpointMethod, requestXml);
    System.out.println("Response: " + response);
}

From source file:com.zip.CreateZipWithOutputStreams.java

/**
 * @param args/*from w  w  w  . java 2  s  . co m*/
 * @throws UnsupportedEncodingException 
 */
public static void main(String[] args) throws UnsupportedEncodingException {
    //      new CreateZipWithOutputStreams();
    //      zipFilesAndEncrypt("D:\\test\\download","D:\\test\\download\\1.zip","12345");
    //      unzipFile("D:\\test\\download\\1.zip","D:\\test\\download",null);
    String str = "/usr/local/aiomni/27/temp/offLineFolder/admin8a21848b4056b2e4014056b533240000/??????_1.xls";
    System.out.println(new String(str.getBytes("ISO8859-1"), "GBK"));
    System.out.println(System.getProperty("file.encoding"));
}

From source file:com.cilogi.lid.util.TEA.java

public static void main(String[] args) {
    /* Create a cipher using the first 16 bytes of the passphrase */
    TEA tea = new TEA("And is there honey still for tea?".getBytes());

    byte[] original = quote.getBytes(Charsets.UTF_8);

    /* Run it through the cipher... and back */
    byte[] crypt = tea.encrypt(original);
    byte[] result = tea.decrypt(crypt);

    /* Ensure that all went well */
    String test = new String(result, Charsets.UTF_8);
    if (!test.equals(quote))
        throw new RuntimeException("Fail");
}

From source file:com.lsq.httpclient.netpay.BasicInfo.java

public static void main(String[] args) throws Exception {
    //   final PrivateKey hzfPriKey = CryptoUtil.getRSAPrivateKeyByFileSuffix("F://test/pkcs8_rsa_private_key_2048.pem", "pem", null, "RSA");
    //   final PublicKey yhPubKey = CryptoUtil.getRSAPublicKeyByFileSuffix("F://??/rsa_public_key_2048.pem", "pem", "RSA");
    ///*from  w  ww.ja  v  a  2 s .  c o m*/
    //   final String url = "http://localhost:8080/interfaceWeb/basicInfo";
    //   final String url = "https://testapp.sicpay.com:11008/interfaceWeb/basicInfo";   

    //?
    //   final String url = "http://120.31.132.120:8082/interfaceWeb/basicInfo";
    //       final PublicKey yhPubKey = CryptoUtil.getRSAPublicKeyByFileSuffix("C:\\document\\key\\000158120120\\GHT_ROOT.pem", "pem", "RSA");
    //        final PrivateKey hzfPriKey = CryptoUtil.getRSAPrivateKeyByFileSuffix("C:\\document\\key\\000000153990021\\000000153990021.pem", "pem", null, "RSA");
    //   final PrivateKey hzfPriKey = CryptoUtil.getRSAPrivateKeyByFileSuffix("C:/document/key/000000158120121/000000158120121.pem", "pem", null, "RSA");
    //   final PrivateKey hzfPriKey = CryptoUtil.getRSAPrivateKeyByFileSuffix("D:/key/000000152110003.pem", "pem", null, "RSA");
    //   final PrivateKey hzfPriKey = CryptoUtil.getRSAPrivateKeyByFileSuffix("D:/key/test_pkcs8_rsa_private_key_2048.pem", "pem", null, "RSA");
    //   PublicKey yhPubKey = TestUtil.getPublicKey();
    //   PrivateKey hzfPriKey = TestUtil.getPrivateKey();

    //    final String url = "http://epay.gaohuitong.com:8083/interfaceWeb/basicInfo";

    //        final String url = "http://gpay.gaohuitong.com:8086/interfaceWeb2/basicInfo";
    //       final PublicKey yhPubKey = CryptoUtil.getRSAPublicKeyByFileSuffix("C:/document/key/549440155510001/GHT_ROOT.pem", "pem", "RSA");
    //    final PrivateKey hzfPriKey = CryptoUtil.getRSAPrivateKeyByFileSuffix("C:/document/key/549440155510001/549440155510001.pem", "pem", null, "RSA");

    //    final String url = "https://portal.sicpay.com:8087/interfaceWeb/basicInfo";

    final String url = TestUtil.interface_url + "basicInfo";

    final PublicKey yhPubKey = TestUtil.getPublicKey();
    final PrivateKey hzfPriKey = TestUtil.getPrivateKey();

    int i = 0;
    //   int j = 0;
    while (i < 1) {
        i++;
        try {
            HttpClient4Util httpClient4Util = new HttpClient4Util();
            StringBuilder sBuilder = new StringBuilder();
            sBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            sBuilder.append("<merchant>");
            sBuilder.append("<head>");
            sBuilder.append("<version>2.0.0</version>");
            //         sBuilder.append("<agencyId>549440155510001</agencyId>");
            sBuilder.append("<agencyId>" + TestUtil.merchantId + "</agencyId>");
            sBuilder.append("<msgType>01</msgType>");
            sBuilder.append("<tranCode>100001</tranCode>");
            sBuilder.append("<reqMsgId>" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss") + i + i
                    + "</reqMsgId>");
            sBuilder.append("<reqDate>" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss") + "</reqDate>");
            sBuilder.append("</head>");
            sBuilder.append("<body>");

            sBuilder.append("<handleType>0</handleType>");
            sBuilder.append("<merchantName>LIBTEST1</merchantName>");
            sBuilder.append("<shortName>UNCLE HENRY(A)</shortName>");
            sBuilder.append("<city>344344</city>");
            sBuilder.append(
                    "<merchantAddress>UNIT C 15/FHUA CHIAO COMM CTR 678 NATHAN RD MONGKOK KL</merchantAddress>");
            sBuilder.append("<servicePhone>13250538964</servicePhone>");
            sBuilder.append("<orgCode></orgCode>");
            sBuilder.append("<merchantType>01</merchantType>");
            sBuilder.append("<category>5399</category>");
            sBuilder.append("<corpmanName>?</corpmanName>");
            sBuilder.append("<corpmanId>440103198112214218</corpmanId>");
            sBuilder.append("<corpmanPhone>13926015921</corpmanPhone>");
            sBuilder.append("<corpmanMobile>13926015921</corpmanMobile>");
            sBuilder.append("<corpmanEmail>>zhanglibo@sicpay.com</corpmanEmail>");
            sBuilder.append("<bankCode>105</bankCode>");
            sBuilder.append("<bankName></bankName>");
            sBuilder.append("<bankaccountNo>6250502002603958</bankaccountNo>");
            sBuilder.append("<bankaccountName>?</bankaccountName>");
            sBuilder.append("<autoCus>0</autoCus>");
            sBuilder.append("<remark></remark>");
            sBuilder.append("<licenseNo>91440184355798892G</licenseNo>");
            //         sBuilder.append("<taxRegisterNo></taxRegisterNo>");
            //         sBuilder.append("<subMerchantNo></subMerchantNo>");
            //         sBuilder.append("<inviteMerNo></inviteMerNo>");
            //         sBuilder.append("<county></county>");
            //         sBuilder.append("<appid>wx04df48e919ef7b28</appid>");
            //         sBuilder.append("<pid>2015062600009243</pid>");
            //         sBuilder.append("<childEnter>1</childEnter>");
            //         sBuilder.append("<ghtEnter>0</ghtEnter>");
            //         sBuilder.append("<addrType>BUSINESS_ADDRESS</addrType>");
            //         sBuilder.append("<contactType>LEGAL_PERSON</contactType>");
            //         sBuilder.append("<mcc>200101110640354</mcc>");
            //         sBuilder.append("<licenseType>NATIONAL_LEGAL_MERGE</licenseType>");
            //         sBuilder.append("<authPayDir>http://epay.gaohuitong.com/channel/|http://test.pengjv.com/channel/</authPayDir>");
            //         sBuilder.append("<scribeAppid>wx04df48e919ef7b28</scribeAppid>");
            //         sBuilder.append("<contactMan></contactMan>");
            //         sBuilder.append("<telNo>18675857506</telNo>");
            //         sBuilder.append("<mobilePhone>18675857506</mobilePhone>");
            //         sBuilder.append("<email>CSC@sicpay.com</email>");
            //         sBuilder.append("<licenseBeginDate>20150826</licenseBeginDate>");
            //         sBuilder.append("<licenseEndDate>20991231</licenseEndDate>");
            //         sBuilder.append("<licenseRange>?????????????</licenseRange>");

            sBuilder.append("</body>");
            sBuilder.append("</merchant>");

            String plainXML = sBuilder.toString();
            byte[] plainBytes = plainXML.getBytes("UTF-8");
            String keyStr = "4D22R4846VFJ8HH4";
            byte[] keyBytes = keyStr.getBytes("UTF-8");
            byte[] base64EncryptDataBytes = Base64.encodeBase64(
                    CryptoUtil.AESEncrypt(plainBytes, keyBytes, "AES", "AES/ECB/PKCS5Padding", null));
            String encryptData = new String(base64EncryptDataBytes, "UTF-8");
            byte[] base64SingDataBytes = Base64
                    .encodeBase64(CryptoUtil.digitalSign(plainBytes, hzfPriKey, "SHA1WithRSA"));
            String signData = new String(base64SingDataBytes, "UTF-8");
            byte[] base64EncyrptKeyBytes = Base64
                    .encodeBase64(CryptoUtil.RSAEncrypt(keyBytes, yhPubKey, 2048, 11, "RSA/ECB/PKCS1Padding"));
            String encrtptKey = new String(base64EncyrptKeyBytes, "UTF-8");
            List<NameValuePair> nvps = new LinkedList<NameValuePair>();
            nvps.add(new BasicNameValuePair("encryptData", encryptData));
            nvps.add(new BasicNameValuePair("encryptKey", encrtptKey));
            //         nvps.add(new BasicNameValuePair("agencyId", "549440155510001"));
            nvps.add(new BasicNameValuePair("agencyId", TestUtil.merchantId));
            nvps.add(new BasicNameValuePair("signData", signData));
            nvps.add(new BasicNameValuePair("tranCode", "100001"));
            //         nvps.add(new BasicNameValuePair("callBack","http://localhost:801/callback/ghtBindCard.do"));
            //          byte[] retBytes = httpClient4Util.doPost("http://localhost:8080/quickInter/channel/commonSyncInter.do", null, nvps, null);
            byte[] retBytes = httpClient4Util.doPost(url, null, nvps, null);
            //         byte[] retBytes =httpClient4Util.doPost("http://epay.gaohuitong.com:8082/quickInter/channel/commonSyncInter.do", null, nvps, null);
            //           byte[] retBytes = httpClient4Util.doPost("http://192.168.80.113:8080/quickInter/channel/commonSyncInter.do", null, nvps, null);

            String response = new String(retBytes, "UTF-8");
            System.out.println(" ||" + new String(retBytes, "UTF-8") + "||");
            TestEncype t = new TestEncype();
            System.out.println(": ||" + t.respDecryption(response) + "||");
            System.out.println("i" + i);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:Main.java

public static String bytes2String(byte[] b) throws Exception {
    String r = new String(b, "UTF-8");
    return r;//from  ww w.j a v a 2  s .  c  o  m
}

From source file:Main.java

public static String newString(byte[] b, String charset) {
    try {//from  w w w  . ja v  a2s  .  co m
        return new String(b, charset);
    } catch (Exception e) {
        return null;
    }
}

From source file:Main.java

public static String stringFromUtf8ByteArray(byte[] data) {
    try {/* w  w w .  j a  va 2  s  .c o m*/
        return new String(data, "UTF-8");
    } catch (Exception e) {
        return null;
    }
}