}
public void testIsAuthorizedCertUserRegularApproveIdentity() throws Exception {
String adminusername = genRandomUserName();
Admin intadmin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
int caid = getTestCAId();
UserDataVO userdata = new UserDataVO(adminusername, "CN=" + adminusername, caid, null, null, 1, SecConst.EMPTY_ENDENTITYPROFILE,
SecConst.CERTPROFILE_FIXED_ENDUSER, SecConst.TOKEN_SOFT_P12, 0, null);
userdata.setPassword("foo123");
userAdminSession.addUser(intadmin, userdata, true);
File tmpfile = File.createTempFile("ejbca", "p12");
BatchMakeP12 makep12 = new BatchMakeP12();
makep12.setMainStoreDir(tmpfile.getParent());
makep12.createAllNew();
tmpfile.delete();
List<AdminEntity> adminEntities = new ArrayList<AdminEntity>();
adminEntities.add(new AdminEntity(AdminEntity.WITH_COMMONNAME, AdminEntity.TYPE_EQUALCASEINS, adminusername, caid));
adminEntitySession.addAdminEntities(intadmin, AdminGroup.TEMPSUPERADMINGROUP, adminEntities);
authorizationSession.forceRuleUpdate(intadmin);
X509Certificate admincert = (X509Certificate) certificateStoreSession.findCertificatesByUsername(intadmin, adminusername).iterator().next();
Admin admin = new Admin(admincert, adminusername, null);
assertTrue("Could not authorize certificate user with AccessRulesConstants.REGULAR_APPROVEENDENTITY",
authorizationSession.isAuthorized(admin, AccessRulesConstants.REGULAR_APPROVEENDENTITY));
}