当前位置: 首页>>代码示例>>Java>>正文


Java JOrphanUtils.baToHexString方法代码示例

本文整理汇总了Java中org.apache.jorphan.util.JOrphanUtils.baToHexString方法的典型用法代码示例。如果您正苦于以下问题:Java JOrphanUtils.baToHexString方法的具体用法?Java JOrphanUtils.baToHexString怎么用?Java JOrphanUtils.baToHexString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jorphan.util.JOrphanUtils的用法示例。


在下文中一共展示了JOrphanUtils.baToHexString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.apache.jorphan.util.JOrphanUtils; //导入方法依赖的package包/类
/**
 * Reads data until the defined EOM byte is reached.
 * If there is no EOM byte defined, then reads until
 * the end of the stream is reached.
 * Response data is converted to hex-encoded binary
 * @return hex-encoded binary string
 * @throws ReadException when reading fails
 */
@Override
public String read(InputStream is) throws ReadException {
    ByteArrayOutputStream w = new ByteArrayOutputStream();
    try {
        byte[] buffer = new byte[4096];
        int x = 0;
        while ((x = is.read(buffer)) > -1) {
            w.write(buffer, 0, x);
            if (useEolByte && (buffer[x - 1] == eolByte)) {
                break;
            }
        }

        IOUtils.closeQuietly(w); // For completeness
        final String hexString = JOrphanUtils.baToHexString(w.toByteArray());
        if(log.isDebugEnabled()) {
            log.debug("Read: " + w.size() + "\n" + hexString);
        }
        return hexString;
    } catch (IOException e) {
        throw new ReadException("", e, JOrphanUtils.baToHexString(w.toByteArray()));
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:32,代码来源:BinaryTCPClientImpl.java

示例2: read

import org.apache.jorphan.util.JOrphanUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String read(InputStream is) throws ReadException{
    byte[] msg = new byte[0];
    int msgLen = 0;
    byte[] lengthBuffer = new byte[lengthPrefixLen];
    try {
        if (is.read(lengthBuffer, 0, lengthPrefixLen) == lengthPrefixLen) {
            msgLen = byteArrayToInt(lengthBuffer);
            msg = new byte[msgLen];
            int bytes = JOrphanUtils.read(is, msg, 0, msgLen);
            if (bytes < msgLen) {
                log.warn("Incomplete message read, expected: "+msgLen+" got: "+bytes);
            }
        }

        String buffer = JOrphanUtils.baToHexString(msg);
        if(log.isDebugEnabled()) {
            log.debug("Read: " + msgLen + "\n" + buffer);
        }
        return buffer;
    } 
    catch(IOException e) {
        throw new ReadException("", e, JOrphanUtils.baToHexString(msg));
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:29,代码来源:LengthPrefixedBinaryTCPClientImpl.java

示例3: getCertificateDetails

import org.apache.jorphan.util.JOrphanUtils; //导入方法依赖的package包/类
public String[] getCertificateDetails()
{
    if (isDynamicMode())
    {
        try
        {
            X509Certificate caCert = (X509Certificate)sslKeyStore.getCertificate(KeyToolUtils.getRootCAalias());
            if (caCert == null)
            {
                return new String[] { "Could not find certificate" };
            }
            return new String[] { caCert.getSubjectX500Principal().toString(),
                    "Fingerprint(SHA1): " + JOrphanUtils.baToHexString(DigestUtils.sha1(caCert.getEncoded()), ' '),
                    "Created: " + caCert.getNotBefore().toString() };
        }
        catch (GeneralSecurityException e)
        {
            LOG.error("Problem reading root CA from keystore", e);
            return new String[] { "Problem with root certificate", e.getMessage() };
        }
    }
    return null; // should not happen
}
 
开发者ID:d0k1,项目名称:jsflight,代码行数:24,代码来源:JMeterProxyControl.java

示例4: read

import org.apache.jorphan.util.JOrphanUtils; //导入方法依赖的package包/类
/**
 * Reads data until the defined EOM byte is reached.
 * If there is no EOM byte defined, then reads until
 * the end of the stream is reached.
 * Response data is converted to hex-encoded binary
 * @return hex-encoded binary string
 * @throws ReadException 
 */
@Override
public String read(InputStream is) throws ReadException {
    ByteArrayOutputStream w = new ByteArrayOutputStream();
    try {
        byte[] buffer = new byte[4096];
        int x = 0;
        while ((x = is.read(buffer)) > -1) {
            w.write(buffer, 0, x);
            if (useEolByte && (buffer[x - 1] == eolByte)) {
                break;
            }
        }

        IOUtils.closeQuietly(w); // For completeness
        final String hexString = JOrphanUtils.baToHexString(w.toByteArray());
        if(log.isDebugEnabled()) {
            log.debug("Read: " + w.size() + "\n" + hexString);
        }
        return hexString;
    } catch (IOException e) {
        throw new ReadException("", e, JOrphanUtils.baToHexString(w.toByteArray()));
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:32,代码来源:BinaryTCPClientImpl.java

示例5: getCertificateDetails

import org.apache.jorphan.util.JOrphanUtils; //导入方法依赖的package包/类
public String[] getCertificateDetails() {
    if (isDynamicMode()) {
        try {
            X509Certificate caCert = (X509Certificate) keyStore.getCertificate(KeyToolUtils.getRootCAalias());
            if (caCert == null) {
                return new String[]{"Could not find certificate"};
            }
            return new String[]
                    {
                    caCert.getSubjectX500Principal().toString(),
                    "Fingerprint(SHA1): " + JOrphanUtils.baToHexString(DigestUtils.sha1(caCert.getEncoded()), ' '),
                    "Created: "+ caCert.getNotBefore().toString()
                    };
        } catch (GeneralSecurityException e) {
            log.error("Problem reading root CA from keystore", e);
            return new String[]{"Problem with root certificate", e.getMessage()};
        }
    }
    return null; // should not happen
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:21,代码来源:ProxyControl.java

示例6: baMD5Hex

import org.apache.jorphan.util.JOrphanUtils; //导入方法依赖的package包/类
static String baMD5Hex(byte[] ba) {
    byte[] md5Result = {};

    try {
        MessageDigest md = MessageDigest.getInstance("MD5");
        md5Result = md.digest(ba);
    } catch (NoSuchAlgorithmException e) {
        log.error("", e);
    }
    return JOrphanUtils.baToHexString(md5Result);
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:12,代码来源:MD5HexAssertion.java

示例7: getChecksumForPropertiesFile

import org.apache.jorphan.util.JOrphanUtils; //导入方法依赖的package包/类
private static String getChecksumForPropertiesFile()
        throws NoSuchAlgorithmException, IOException {
    MessageDigest md = MessageDigest.getInstance("SHA1");
    
    InputStream is = SaveService.class.getClassLoader().getResourceAsStream(SAVESERVICE_PROPERTIES_FILE);
    BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
    
    String line = null;
    while ((line = reader.readLine()) != null) {
        md.update(line.getBytes());
    }
    
    return JOrphanUtils.baToHexString(md.digest());
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:15,代码来源:SaveService.java

示例8: baMD5Hex

import org.apache.jorphan.util.JOrphanUtils; //导入方法依赖的package包/类
static String baMD5Hex(byte ba[]) {
    byte[] md5Result = {};

    try {
        MessageDigest md;
        md = MessageDigest.getInstance("MD5");
        md5Result = md.digest(ba);
    } catch (NoSuchAlgorithmException e) {
        log.error("", e);
    }
    return JOrphanUtils.baToHexString(md5Result);
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:13,代码来源:MD5HexAssertion.java


注:本文中的org.apache.jorphan.util.JOrphanUtils.baToHexString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。