class CertificateFormatter {

  public static String derOf(final RSAPublicKey publicKey) throws IOException {
    final RSAPublicKey rsaPublicKey = publicKey;
    final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    final DataOutputStream dataStream = new DataOutputStream(byteStream);

    writeBytesToDataStream(SSH_RSA.getBytes(UTF_8), dataStream);
    writeBytesToDataStream(rsaPublicKey.getPublicExponent().toByteArray(), dataStream);
    writeBytesToDataStream(rsaPublicKey.getModulus().toByteArray(), dataStream);

    final String publicKeyEncoded = new String(Base64.encodeBase64(byteStream.toByteArray()), UTF_8);
    return SSH_RSA + " " + publicKeyEncoded;
  }

  private  CertificateFormatter();

}