RSAUtil { public static String buildDN(String country, String state, String locality, String org, String orgUnit, String commonName) { StringBuilder sb = new StringBuilder(); sb.append("C=").append(country).append(", "); sb.append("ST=").append(state).append(", "); sb.append("L=").append(locality).append(", "); sb.append("O=").append(org).append(", "); if (orgUnit != null) sb.append("OU=").append(orgUnit).append(", "); sb.append("CN=").append(commonName); return sb.toString(); }  static KeyPair generateRSAKeyPair(); static KeyPair generateRSAKeyPair(int size); static String buildDN(String country, String state, String locality, String org, String orgUnit, String commonName); static CertificatePair generateCertificate(String DN, SerialNum serial, int days, int keySize, KeyType type, CertificatePair issuer); static CertificatePair generateCertificate(String DN, SerialNum serial, int days, int keySize, KeyType type, PublicKey key, CertificatePair issuer);  }
@Test public void testBuildDN() { String dn = RSAUtil.buildDN("GB", "SomeState", "SomeLocality", "MyOrg", "Basement", "testing.123"); assertThat(dn, is(notNullValue())); assertThat(dn, is(equalTo("C=GB, ST=SomeState, L=SomeLocality, O=MyOrg, OU=Basement, CN=testing.123"))); }