Package org.sonatype.security.model

Examples of org.sonatype.security.model.CPrivilege


      for (Iterator roleIter = role.getPrivileges().iterator(); roleIter.hasNext(); ) {
        String privId = (String) roleIter.next();
        // PrivilegeBaseStatusResource priv = this.privUtil.getPrivilegeResource( privId );
        // privs.add( priv.getName() );
        CPrivilege priv = getSecurityConfigUtil().getCPrivilege(privId);
        if (priv != null) {
          privs.add(priv.getName());
        }
        else {
          PrivilegeStatusResource basePriv = this.privUtil.getPrivilegeResource(privId);
          privs.add(basePriv.getName());
        }
View Full Code Here


      throws IOException
  {
    for (Iterator<PrivilegeStatusResource> iter = privs.iterator(); iter.hasNext(); ) {
      PrivilegeStatusResource privResource = iter.next();

      CPrivilege secPriv = getCPrivilege(privResource.getId());

      Assert.assertNotNull(secPriv);

      Assert.assertEquals(secPriv.getId(), privResource.getId());
      Assert.assertEquals(secPriv.getName(), privResource.getName());
      Assert.assertEquals(secPriv.getDescription(), privResource.getDescription());

      for (CProperty prop : secPriv.getProperties()) {
        Assert.assertEquals(prop.getValue(), getPrivilegeProperty(privResource, prop.getKey()));
      }
    }
  }
View Full Code Here

  {
    Configuration securityConfig = getSecurityConfig();
    List<CPrivilege> secPrivs = securityConfig.getPrivileges();

    for (Iterator<CPrivilege> iter = secPrivs.iterator(); iter.hasNext(); ) {
      CPrivilege cPriv = iter.next();

      if (privilegeId.equals(cPriv.getId())) {
        return cPriv;
      }
    }
    return null;
  }
View Full Code Here

  {
    Configuration securityConfig = getSecurityConfig();
    List<CPrivilege> secPrivs = securityConfig.getPrivileges();

    for (Iterator<CPrivilege> iter = secPrivs.iterator(); iter.hasNext(); ) {
      CPrivilege cPriv = iter.next();

      if (privilegeName.equals(cPriv.getName())) {
        return cPriv;
      }
    }
    return null;
  }
View Full Code Here

    addStaticSecurity(configuration, staticConfiguration);
  }

  private void addStaticSecurity(Configuration configuration, Configuration staticConfiguration) {
    for (CPrivilege priv : staticConfiguration.getPrivileges()) {
      CPrivilege p = getPrivilege(priv.getId(), configuration.getPrivileges());
      if (p == null) {
        configuration.addPrivilege(priv);
      }
    }
View Full Code Here

    }
    return filtered;
  }

  protected CPrivilege buildPrivilege(String name, String description, String repoId) {
    CPrivilege priv = new CPrivilege();

    priv.setId(createPrivilegeId(repoId));
    priv.setName(name);
    priv.setDescription(description);
    priv.setType(RepositoryViewPrivilegeDescriptor.TYPE);

    CProperty prop = new CProperty();
    prop.setKey(RepositoryPropertyDescriptor.ID);
    prop.setValue(repoId);
    priv.addProperty(prop);

    return priv;
  }
View Full Code Here

  }

  public CPrivilege readPrivilege(String id)
      throws NoSuchPrivilegeException
  {
    CPrivilege privilege = getConfiguration().getPrivilegeById(id);

    if (privilege != null) {
      return privilege;
    }
    else {
View Full Code Here

    configCalledAfterSetDirty = true;

    setConfigCalledAfterSetDirty(true);
    Configuration config = new Configuration();

    CPrivilege priv = new CPrivilege();
    priv.setId(privId);
    priv.setName(privId);
    priv.setReadOnly(true);
    priv.setType(ApplicationPrivilegeDescriptor.TYPE);
    CProperty method = new CProperty();
    method.setKey(ApplicationPrivilegeMethodPropertyDescriptor.ID);
    method.setValue("read");
    priv.addProperty(method);

    CProperty permission = new CProperty();
    permission.setKey(ApplicationPrivilegePermissionPropertyDescriptor.ID);
    permission.setValue("foo:bar:" + privId);
    priv.addProperty(permission);

    config.addPrivilege(priv);

    return config;
  }
View Full Code Here

  {
    Configuration configuration =
        getConfigurationFromStream(getClass().getResourceAsStream(
            "/org/sonatype/security/realms/tools/cleaner-security.xml"));

    CPrivilege priv = (CPrivilege) configuration.getPrivileges().get(0);

    configuration.removePrivilege(priv);

    cleaner.privilegeRemoved(new EnhancedConfiguration(configuration), priv.getId());

    for (CRole role : (List<CRole>) configuration.getRoles()) {
      assertFalse(role.getPrivileges().contains(priv.getId()));
    }
  }
View Full Code Here

    return secRole;
  }

  protected CPrivilege toPrivilege(Privilege privilege) {
    CPrivilege secPriv = new CPrivilege();
    secPriv.setId(privilege.getId());
    secPriv.setName(privilege.getName());
    secPriv.setDescription(privilege.getDescription());
    secPriv.setReadOnly(privilege.isReadOnly());
    secPriv.setType(privilege.getType());

    if (privilege.getProperties() != null && privilege.getProperties().entrySet() != null) {
      for (Entry<String, String> entry : privilege.getProperties().entrySet()) {
        CProperty prop = new CProperty();
        prop.setKey(entry.getKey());
        prop.setValue(entry.getValue());
        secPriv.addProperty(prop);
      }
    }

    return secPriv;
  }
View Full Code Here

TOP

Related Classes of org.sonatype.security.model.CPrivilege

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.