class RsaGenerator implements CredentialGenerator<RsaCredentialValue> {

  @Override
  public RsaCredentialValue generateCredential(final GenerationParameters p) {
    final RsaGenerationParameters params = (RsaGenerationParameters) p;
    try {
      final KeyPair keyPair = keyGenerator.generateKeyPair(params.getKeyLength());
      return new RsaCredentialValue(CertificateFormatter.pemOf(keyPair.getPublic()),
        CertificateFormatter.pemOf(keyPair.getPrivate()));
    } catch (final Exception e) {
      throw new RuntimeException(e);
    }
  }

  @Autowired  RsaGenerator(final RsaKeyPairGenerator keyGenerator);

}