本文整理汇总了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()));
}
}
示例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));
}
}
示例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
}
示例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()));
}
}
示例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
}
示例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);
}
示例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());
}
示例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);
}