public byte[] decode(byte[] buf) { return JOrphanUtils.baToHexString(buf).getBytes(); } }
public byte[] decode(byte[] buf) { return JOrphanUtils.baToHexString(buf).getBytes(); } }
private static String md5Hex(byte[] bytes) { byte[] md5Result = {}; try { md5Result = MessageDigest.getInstance("MD5").digest(bytes); } catch (NoSuchAlgorithmException e) { log.error("Message digestion failed.", e); } return JOrphanUtils.baToHexString(md5Result); } }
private static String getChecksumForPropertiesFile() throws NoSuchAlgorithmException, IOException { MessageDigest md = MessageDigest.getInstance("SHA1"); File saveServiceFile = getSaveServiceFile(); try (BufferedReader reader = Files.newBufferedReader(saveServiceFile.toPath(), Charset.defaultCharset())) { String line = null; while ((line = reader.readLine()) != null) { md.update(line.getBytes()); } } return JOrphanUtils.baToHexString(md.digest()); } private static void initProps() {
@Override public byte[] decode(byte[] buf) { Message m; try { m = new Message(buf); } catch (IOException ex) { throw new RuntimeException("Cannot decode DNS message: " + JOrphanUtils.baToHexString(buf), ex); } return m.toString().getBytes(); } }
@Override public byte[] decode(byte[] buf) { Message m; try { m = new Message(buf); } catch (IOException ex) { throw new RuntimeException("Cannot decode DNS message: "+JOrphanUtils.baToHexString(buf), ex); } return m.toString().getBytes(); } }
final String hexString = JOrphanUtils.baToHexString(w.toByteArray()); if(log.isDebugEnabled()) { log.debug("Read: " + w.size() + "\n" + hexString); throw new ReadException("", e, JOrphanUtils.baToHexString(w.toByteArray()));
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 new String[0]; // should not happen } // Package protected to allow test case access
private synchronized String readNextChunk(int capacity) throws IOException { if (capacity == 0) { throw new EndOfFileException("Zero chunk size, possibly end of file reached."); } ByteBuffer buf = ByteBuffer.allocateDirect(capacity); byte[] dst = new byte[capacity]; int cnt = file.read(buf); //log.debug("Read " + cnt); if (cnt != capacity) { throw new IOException("Expected chunk size (" + capacity + ") differs from read bytes count (" + cnt + ")"); } buf.flip(); buf.get(dst); if (log.isDebugEnabled()) { log.debug("Chunk : " + new String(dst)); } if (isHexEncode()) { return JOrphanUtils.baToHexString(dst); } else { return new String(dst, binaryCharset); } }
/** * {@inheritDoc} */ @Override public String read(InputStream is, SampleResult sampleResult) throws ReadException{ byte[] msg = new byte[0]; int msgLen = 0; byte[] lengthBuffer = new byte[lengthPrefixLen]; try { if (is.read(lengthBuffer, 0, lengthPrefixLen) == lengthPrefixLen) { sampleResult.latencyEnd(); msgLen = byteArrayToInt(lengthBuffer); msg = new byte[msgLen]; int bytes = JOrphanUtils.read(is, msg, 0, msgLen); if (bytes < msgLen) { log.warn("Incomplete message read, expected: {} got: {}", msgLen, 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)); } }
private synchronized String readNextChunk(int capacity) throws IOException { if (capacity == 0) { throw new EndOfFileException("Zero chunk size, possibly end of file reached."); } ByteBuffer buf = ByteBuffer.allocateDirect(capacity); byte[] dst = new byte[capacity]; int cnt = file.read(buf); //log.debug("Read " + cnt); if (cnt != capacity) { throw new IOException("Expected chunk size (" + capacity + ") differs from read bytes count (" + cnt + ")"); } buf.flip(); buf.get(dst); if (log.isDebugEnabled()) { log.debug("Chunk : " + new String(dst)); } if (isHexEncode()) { return JOrphanUtils.baToHexString(dst); } else { return new String(dst, binaryCharset); } }
/** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); String str = ((CompoundVariable) values[0]).execute(); MessageDigest digest; try { digest = MessageDigest.getInstance("md5"); } catch (NoSuchAlgorithmException ex) { return "Error creating digest: " + ex; } String res = JOrphanUtils.baToHexString(digest.digest(str.getBytes())); if (vars != null && values.length > 1) { String varName = ((CompoundVariable) values[1]).execute().trim(); vars.put(varName, res); } return res; }
/** * {@inheritDoc} */ @Override public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException { JMeterVariables vars = getVariables(); String str = ((CompoundVariable) values[0]).execute(); MessageDigest digest; try { digest = MessageDigest.getInstance("md5"); } catch (NoSuchAlgorithmException ex) { return "Error creating digest: " + ex; } String res = JOrphanUtils.baToHexString(digest.digest(str.getBytes())); if (vars != null && values.length > 1) { String varName = ((CompoundVariable) values[1]).execute().trim(); vars.put(varName, res); } return res; }