Examples of CRole


Examples of org.sonatype.security.model.CRole

    return role;
  }

  protected CRole toRole(Role role) {
    CRole secRole = new CRole();

    secRole.setId(role.getRoleId());
    secRole.setName(role.getName());
    secRole.setDescription(role.getDescription());
    secRole.setReadOnly(role.isReadOnly());
    // null check
    if (role.getPrivileges() != null) {
      secRole.setPrivileges(new ArrayList<String>(role.getPrivileges()));
    }
    else {
      secRole.setPrivileges(new ArrayList<String>());
    }

    // null check
    if (role.getRoles() != null) {
      secRole.setRoles(new ArrayList<String>(role.getRoles()));
    }
    else {
      secRole.setRoles(new ArrayList<String>());
    }

    return secRole;
  }
View Full Code Here

Examples of org.sonatype.security.model.CRole

  public List<CRole> listRoles() {
    List<CRole> list = new ArrayList<CRole>(manager.listRoles());

    for (CRole item : (List<CRole>) getConfiguration().getRoles()) {
      CRole role = item;
      // ALL roles that come from StaticSecurityResources are NOT editable
      // only roles defined in the security.xml can be updated.
      item.setReadOnly(true);
      list.add(role);
    }
View Full Code Here

Examples of org.sonatype.security.model.CRole

    }
    if (roleB.getPrivileges() != null) {
      privs.addAll(roleB.getPrivileges());
    }

    CRole newRole = new CRole();
    newRole.setId(roleA.getId());
    newRole.setRoles(new ArrayList<String>(roles));
    newRole.setPrivileges(new ArrayList<String>(privs));

    // now for the name and description
    if (StringUtils.isNotEmpty(roleA.getName())) {
      newRole.setName(roleA.getName());
    }
    else {
      newRole.setName(roleB.getName());
    }

    if (StringUtils.isNotEmpty(roleA.getDescription())) {
      newRole.setDescription(roleA.getDescription());
    }
    else {
      newRole.setDescription(roleB.getDescription());
    }

    // and session timeout (which we don't use)
    if (roleA.getSessionTimeout() > roleB.getSessionTimeout()) {
      newRole.setSessionTimeout(roleA.getSessionTimeout());
    }
    else {
      newRole.setSessionTimeout(roleB.getSessionTimeout());
    }

    return newRole;
  }
View Full Code Here

Examples of org.sonatype.security.model.CRole

  }

  public CRole readRole(String id)
      throws NoSuchRoleException
  {
    final CRole role = getConfiguration().getRoleById(id);

    if (role != null) {
      role.setReadOnly(true);

      return role;
    }
    else {
      // nothing found in static, try the original source, will throw if nothing is found
View Full Code Here

Examples of org.sonatype.security.model.CRole

    for (CRole role : configuration.getRoles()) {
      roles.put(role.getId(), role);
    }

    for (Iterator<CRole> iterator = config.getRoles().iterator(); iterator.hasNext(); ) {
      CRole role = iterator.next();

      // need to check if we need to merge the static config
      CRole eachRole = roles.get(role.getId());
      if (eachRole != null) {
        role = this.mergeRolesContents(role, eachRole);
        configuration.removeRole(eachRole);
      }
View Full Code Here

Examples of org.sonatype.security.model.CRole

    delegate.addPrivilege(cp);
    id2privileges.put(cp.getId(), cp);
  }

  public void addRole(final CRole cRole) {
    final CRole cr = cRole.clone();
    delegate.addRole(cr);
    id2roles.put(cr.getId(), cr);
  }
View Full Code Here

Examples of org.sonatype.security.model.CRole

  public CRole getRoleById(final String id) {
    return getRoleById(id, true);
  }

  public CRole getRoleById(final String id, final boolean clone) {
    final CRole role = id2roles.get(id);
    if (role != null) {
      return clone ? role.clone() : role;
    }
    else {
      return null;
    }
  }
View Full Code Here

Examples of org.sonatype.security.model.CRole

      return null;
    }
  }

  public boolean removeRoleById(final String id) {
    final CRole role = getRoleById(id, false);
    if (role != null) {
      delegate.removeRole(role);
      return id2roles.remove(id) != null;
    }
    else {
View Full Code Here

Examples of org.sonatype.security.model.CRole

    role.addPrivilege("2");
    role.addPrivilege("4");

    authzManager.addRole(role);

    CRole secRole = this.getConfigurationManager().readRole(role.getRoleId());

    Assert.assertEquals(role.getRoleId(), secRole.getId());
    Assert.assertEquals(role.getName(), secRole.getName());
    Assert.assertEquals(role.getDescription(), secRole.getDescription());
    Assert.assertTrue(secRole.getPrivileges().contains("2"));
    Assert.assertTrue(secRole.getPrivileges().contains("4"));
    Assert.assertEquals(2, secRole.getPrivileges().size());

  }
View Full Code Here

Examples of org.sonatype.security.model.CRole

    permissions.add("2");
    role2.setPrivileges(permissions);

    authzManager.updateRole(role2);

    CRole secRole = this.getConfigurationManager().readRole(role2.getRoleId());

    Assert.assertEquals(role2.getRoleId(), secRole.getId());
    Assert.assertEquals(role2.getName(), secRole.getName());
    Assert.assertEquals(role2.getDescription(), secRole.getDescription());
    Assert.assertTrue(secRole.getPrivileges().contains("2"));
    Assert.assertEquals(1, secRole.getPrivileges().size());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.