class RsaCredentialHelper {

  public int getKeyLength() {
    final String publicKey = rsaCredentialData.getPublicKey();

    if (StringUtils.isEmpty(publicKey)) {
      return 0;
    }

    try {
      final String key = publicKey
        .replaceFirst(RSA_START, "")
        .replaceFirst(RSA_END, "")
        .replaceAll(NEW_LINE, "");
      final byte[] byteKey = Base64.decodeBase64(key.getBytes(UTF_8));
      final X509EncodedKeySpec x509publicKey = new X509EncodedKeySpec(byteKey);
      final KeyFactory kf = KeyFactory.getInstance("RSA");
      return ((RSAPublicKey) kf.generatePublic(x509publicKey)).getModulus().bitLength();
    } catch (final NoSuchAlgorithmException | InvalidKeySpecException e) {
      throw new RuntimeException(e);
    }
  }

  public  RsaCredentialHelper(final RsaCredentialVersionData rsaCredentialData);

}