@Test public void shouldGetSessionId() { given(mockSession.getId()).willReturn(new byte[]{ -1, 0, 1 }); assertThat(sslInfo.getSessionId()).isEqualTo("ff0001"); }
@Nullable @Override public String getSessionId() { byte[] bytes = session.getId(); if (bytes == null) { return null; } StringBuilder sb = new StringBuilder(); for (byte b : bytes) { String digit = Integer.toHexString(b); if (digit.length() < 2) { sb.append('0'); } if (digit.length() > 2) { digit = digit.substring(digit.length() - 2); } sb.append(digit); } return sb.toString(); }
SslInfoImpl implements SslInfo { @Nullable @Override public String getSessionId() { byte[] bytes = session.getId(); if (bytes == null) { return null; } StringBuilder sb = new StringBuilder(); for (byte b : bytes) { String digit = Integer.toHexString(b); if (digit.length() < 2) { sb.append('0'); } if (digit.length() > 2) { digit = digit.substring(digit.length() - 2); } sb.append(digit); } return sb.toString(); } }
SslInfoImpl implements SslInfo { @Nullable @Override public String getSessionId() { byte[] bytes = session.getId(); if (bytes == null) { return null; } StringBuilder sb = new StringBuilder(); for (byte b : bytes) { String digit = Integer.toHexString(b); if (digit.length() < 2) { sb.append('0'); } if (digit.length() > 2) { digit = digit.substring(digit.length() - 2); } sb.append(digit); } return sb.toString(); } SslInfoImpl(SSLSession session); }
SslInfoImpl implements SslInfo { @Nullable @Override public String getSessionId() { byte[] bytes = session.getId(); if (bytes == null) { return null; } StringBuilder sb = new StringBuilder(); for (byte b : bytes) { String digit = Integer.toHexString(b); if (digit.length() < 2) { sb.append('0'); } if (digit.length() > 2) { digit = digit.substring(digit.length() - 2); } sb.append(digit); } return sb.toString(); } SslInfoImpl(SSLSession session); @Nullable @Override String getSessionId(); @Nullable @Override X509Certificate[] getPeerCertificates(); }
SslInfoImpl implements SslInfo { @Nullable @Override public String getSessionId() { byte[] bytes = session.getId(); if (bytes == null) { return null; } StringBuilder sb = new StringBuilder(); for (byte b : bytes) { String digit = Integer.toHexString(b); if (digit.length() < 2) { sb.append('0'); } if (digit.length() > 2) { digit = digit.substring(digit.length() - 2); } sb.append(digit); } return sb.toString(); } SslInfoImpl(SSLSession session); @Nullable @Override String getSessionId(); @Nullable @Override X509Certificate[] getPeerCertificates();  }