public void test22DnOrder() throws Exception {
log.trace(">test22DnOrder()");
// Create a good certificate profile (good enough), using QC statement
certificateProfileSession.removeCertificateProfile(admin, "TESTDNORDER");
EndUserCertificateProfile certprof = new EndUserCertificateProfile();
certificateProfileSession.addCertificateProfile(admin, "TESTDNORDER", certprof);
int cprofile = certificateProfileSession.getCertificateProfileId(admin, "TESTDNORDER");
// Create a good end entity profile (good enough), allowing multiple UPN
// names
endEntityProfileSession.removeEndEntityProfile(admin, "TESTDNORDER");
EndEntityProfile profile = new EndEntityProfile();
profile.addField(DnComponents.COUNTRY);
profile.addField(DnComponents.ORGANIZATION);
profile.addField(DnComponents.COMMONNAME);
profile.setValue(EndEntityProfile.AVAILCAS, 0, Integer.toString(SecConst.ALLCAS));
profile.setValue(EndEntityProfile.AVAILCERTPROFILES, 0, Integer.toString(cprofile));
endEntityProfileSession.addEndEntityProfile(admin, "TESTDNORDER", profile);
int eeprofile = endEntityProfileSession.getEndEntityProfileId(admin, "TESTDNORDER");
UserDataVO user = new UserDataVO("foo", "C=SE,O=PrimeKey,CN=dnorder", rsacaid, null, "foo@primekey.se", SecConst.USER_ENDUSER, eeprofile, cprofile,
SecConst.TOKEN_SOFT_PEM, 0, null);
user.setStatus(UserDataConstants.STATUS_NEW);
// Change a user that we know...
userAdminSession.changeUser(admin, user, false);
log.debug("created user: foo, foo123, C=SE,O=PrimeKey,CN=dnorder");
X509Certificate cert = (X509Certificate) signSession.createCertificate(admin, "foo", "foo123", rsakeys.getPublic());
assertNotNull("Failed to create certificate", cert);
String dn = cert.getSubjectDN().getName();
// This is the reverse order than what is displayed by openssl
assertEquals("C=SE, O=PrimeKey, CN=dnorder", dn);
// Change to X509 DN order
certprof.setUseLdapDnOrder(false);
certificateProfileSession.changeCertificateProfile(admin, "TESTDNORDER", certprof);
userAdminSession.changeUser(admin, user, false);
cert = (X509Certificate) signSession.createCertificate(admin, "foo", "foo123", rsakeys.getPublic());
assertNotNull("Failed to create certificate", cert);
dn = cert.getSubjectDN().getName();