AdminEntity entity = new AdminEntity(AdminEntity.WITH_COMMONNAME, AdminEntity.TYPE_EQUALCASEINS, "SuperAdmin", caid);
    public void initialize(Admin admin, int caid) throws AdminGroupExistsException {        // Check if admingroup table is empty, if so insert default superuser        // and create "special edit accessrules count group"        try {            Collection result = admingrouphome.findAll();            if (result.size() == 0) {                // Authorization table is empty, fill with default and special admingroups.                String admingroupname = "Temporary Super Administrator Group";                addAdminGroup(admin, admingroupname, caid);                ArrayList adminentities = new ArrayList();                AdminEntity entity = new AdminEntity(AdminEntity.WITH_COMMONNAME, AdminEntity.TYPE_EQUALCASEINS, "SuperAdmin", caid);                adminentities.add(new AdminEntity(AdminEntity.WITH_COMMONNAME, AdminEntity.TYPE_EQUALCASEINS, "SuperAdmin", caid));                addAdminEntities(admin, admingroupname, caid, adminentities);                ArrayList accessrules = new ArrayList();                accessrules.add(new AccessRule("/super_administrator", AccessRule.RULE_ACCEPT, false));                addAccessRules(admin, admingroupname, caid, accessrules);            }        } catch (FinderException e) {        }        // Add Special Admin Group        // Special admin group is a group that is not authenticated with client certificate, such as batch tool etc        try {            admingrouphome.findByGroupNameAndCAId(DEFAULTGROUPNAME, ILogSessionLocal.INTERNALCAID);        } catch (FinderException e) {            // Add Default Special Admin Group            try {                AdminGroupDataLocal agdl = admingrouphome.create(new Integer(findFreeAdminGroupId()), DEFAULTGROUPNAME, ILogSessionLocal.INTERNALCAID);                ArrayList adminentities = new ArrayList();                adminentities.add(new AdminEntity(AdminEntity.SPECIALADMIN_BATCHCOMMANDLINEADMIN));                adminentities.add(new AdminEntity(AdminEntity.SPECIALADMIN_CACOMMANDLINEADMIN));                adminentities.add(new AdminEntity(AdminEntity.SPECIALADMIN_RACOMMANDLINEADMIN));                adminentities.add(new AdminEntity(AdminEntity.SPECIALADMIN_INTERNALUSER));                agdl.addAdminEntities(adminentities);                ArrayList accessrules = new ArrayList();                accessrules.add(new AccessRule("/administrator", AccessRule.RULE_ACCEPT, true));                accessrules.add(new AccessRule("/super_administrator", AccessRule.RULE_ACCEPT, false));                accessrules.add(new AccessRule("/ca_functionality", AccessRule.RULE_ACCEPT, true));                accessrules.add(new AccessRule("/ra_functionality", AccessRule.RULE_ACCEPT, true));                accessrules.add(new AccessRule("/log_functionality", AccessRule.RULE_ACCEPT, true));                accessrules.add(new AccessRule("/system_functionality", AccessRule.RULE_ACCEPT, true));                accessrules.add(new AccessRule("/hardtoken_functionality", AccessRule.RULE_ACCEPT, true));                accessrules.add(new AccessRule("/ca", AccessRule.RULE_ACCEPT, true));                accessrules.add(new AccessRule("/endentityprofilesrules", AccessRule.RULE_ACCEPT, true));                agdl.addAccessRules(accessrules);                signalForAuthorizationTreeUpdate();            } catch (CreateException ce) {            }        }        // Add Public Web Group        try {            admingrouphome.findByGroupNameAndCAId(PUBLICWEBGROUPNAME, caid);            this.removeAdminGroup(admin, PUBLICWEBGROUPNAME, caid);        } catch (FinderException e) {        }        try {            admingrouphome.findByGroupNameAndCAId(PUBLICWEBGROUPNAME, caid);        } catch (FinderException e) {            try {                AdminGroupDataLocal agdl = admingrouphome.create(new Integer(findFreeAdminGroupId()), PUBLICWEBGROUPNAME, caid);                ArrayList adminentities = new ArrayList();                adminentities.add(new AdminEntity(AdminEntity.SPECIALADMIN_PUBLICWEBUSER));                agdl.addAdminEntities(adminentities);                ArrayList accessrules = new ArrayList();                accessrules.add(new AccessRule("/public_web_user", AccessRule.RULE_ACCEPT, false));                accessrules.add(new AccessRule("/ca_functionality/basic_functions", AccessRule.RULE_ACCEPT, false));                accessrules.add(new AccessRule("/ca_functionality/view_certificate", AccessRule.RULE_ACCEPT, false));                accessrules.add(new AccessRule("/ca_functionality/create_certificate", AccessRule.RULE_ACCEPT, false));                accessrules.add(new AccessRule("/ca_functionality/store_certificate", AccessRule.RULE_ACCEPT, false));                accessrules.add(new AccessRule("/ra_functionality/view_end_entity", AccessRule.RULE_ACCEPT, false));                accessrules.add(new AccessRule("/ca", AccessRule.RULE_ACCEPT, true));                accessrules.add(new AccessRule("/endentityprofilesrules", AccessRule.RULE_ACCEPT, true));                agdl.addAccessRules(accessrules);                signalForAuthorizationTreeUpdate();            } catch (CreateException ce) {            }        }    }