Package org.ejbca.core.model.authorization

Examples of org.ejbca.core.model.authorization.AdminGroup


  private AccessRulesView accessRulesViewCache = null;

  /** @return a cached list of all the available access rules holding the current state */
  private AccessRulesView getAccessRules() {
    if (accessRulesViewCache == null) {
      AdminGroup adminGroup = getCurrentAdminGroupObject();
      Collection<AccessRule> usedAccessRules = adminGroup.getAccessRules();
      Collection<AccessRule> unusedAccessRules = adminGroup.nonUsedAccessRuleObjects(getAuthorizationDataHandler().getAvailableAccessRules());
      usedAccessRules.addAll(unusedAccessRules);
      accessRulesViewCache = new AccessRulesView(usedAccessRules);
    }
    return accessRulesViewCache;
  }
View Full Code Here


    return current;
  }

  /** @return the current admin group sent with POST, GET or injected through the backing value */
  public AdminGroup getCurrentAdminGroupObject() {
    AdminGroup adminGroup = null;
    try {
      adminGroup = getAuthorizationDataHandler().getAdminGroup(getCurrentAdminGroup());
    } catch (AuthorizationDeniedException e) {
      addErrorMessage("AUTHORIZATIONDENIED");
    }
View Full Code Here

    public TreeMap<String, Integer> getAuthorizedAdminGroups(){
      if(authgroups == null){
        authgroups = new TreeMap<String, Integer>();
        Iterator<AdminGroup> iter = this.adminGroupSession.getAuthorizedAdminGroupNames(administrator, caSession.getAvailableCAs(administrator)).iterator();
        while(iter.hasNext()){
          AdminGroup admingroup = iter.next()
          authgroups.put(admingroup.getAdminGroupName(),Integer.valueOf(admingroup.getAdminGroupId()));
        }                 
      }
      return authgroups;  
    }
View Full Code Here

        Admin admin = new Admin(Admin.TYPE_CACOMMANDLINE_USER);
        // Initialize with a new CA
        adminGroupSession.init(admin, caid, DEFAULT_SUPERADMIN_CN);

        // Retrieve access rules and check that they were added
        AdminGroup ag = adminGroupSession.getAdminGroup(admin, AdminGroup.PUBLICWEBGROUPNAME);
        assertNotNull(ag);
        Collection<AccessRule> rules = ag.getAccessRules();
        assertEquals("Number of available access rules for AdminGroup.PUBLICWEBGROUPNAME was not the expected.", 8, rules.size());

        // Add some new strange access rules
        ArrayList<AccessRule> accessrules = new ArrayList<AccessRule>();
        accessrules.add(new AccessRule("/public_foo_user", AccessRule.RULE_ACCEPT, false));
        accessrules.add(new AccessRule("/foo_functionality/basic_functions", AccessRule.RULE_ACCEPT, false));
        accessrules.add(new AccessRule("/foo_functionality/view_certificate", AccessRule.RULE_ACCEPT, false));
        adminGroupSession.addAccessRules(admin, AdminGroup.PUBLICWEBGROUPNAME, accessrules);

        // Retrieve the access rules and check that they were added
        ag = adminGroupSession.getAdminGroup(admin, AdminGroup.PUBLICWEBGROUPNAME);
        assertNotNull(ag);
        rules = ag.getAccessRules();
        assertEquals(11, rules.size()); // We have added three rules
        Iterator<AccessRule> iter = rules.iterator();
        boolean found = false;
        while (iter.hasNext()) {
            AccessRule rule = iter.next();
            if (rule.getAccessRule().equals("/foo_functionality/view_certificate")) {
                found = true;
            }
        }
        assertTrue(found);

        // Initialize the same CA again, this will remove old default Public Web
        // rules and create new ones.
        // This had some troubles with glassfish before, hence the creation of
        // this test
        adminGroupSession.init(admin, caid, DEFAULT_SUPERADMIN_CN);
        // Retrieve access rules and check that we only have the default ones
        ag = adminGroupSession.getAdminGroup(admin, AdminGroup.PUBLICWEBGROUPNAME);
        assertNotNull(ag);
        rules = ag.getAccessRules();
        assertEquals(8, rules.size());
        iter = rules.iterator();
        found = false;
        while (iter.hasNext()) {
            AccessRule rule = (AccessRule) iter.next();
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.authorization.AdminGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.