Package org.sonatype.security.model

Examples of org.sonatype.security.model.CPrivilege


   * NEXUS-5040: Creating a role with an unknown privilege should not result in a validation error, just a warning.
   */
  public void testValidationOfRoleWithUnknownPrivilege() {
    SecurityValidationContext context = new SecurityValidationContext();

    CPrivilege priv = new CPrivilege();
    priv.setId("priv");
    priv.setName("priv");
    priv.setType("invalid");
    context.addExistingPrivilegeIds();
    context.getExistingPrivilegeIds().add("priv");

    CRole role1 = new CRole();
    role1.setId("role1");
    role1.setName("role1");
    role1.setDescription("desc");
    role1.setSessionTimeout(50);
    role1.addPrivilege(priv.getId());
    role1.addPrivilege("foo");

    context.addExistingRoleIds();
    context.getExistingRoleIds().add("role1");

View Full Code Here


  public void testPrivsMerging()
      throws Exception
  {
    List<CPrivilege> privs = manager.listPrivileges();

    CPrivilege priv = manager.readPrivilege("1-test");
    assertTrue(priv != null);

    priv = manager.readPrivilege("2-test");
    assertTrue(priv != null);
View Full Code Here

    CProperty methodProp = new CProperty();
    methodProp.setKey(ApplicationPrivilegeMethodPropertyDescriptor.ID);
    methodProp.setValue("read");

    CPrivilege priv = new CPrivilege();
    priv.setId("priv-" + Math.random());
    priv.setName("somepriv");
    priv.setType(ApplicationPrivilegeDescriptor.TYPE);
    priv.setDescription("somedescription");
    priv.addProperty(permissionProp);
    priv.addProperty(methodProp);

    this.lookup(DefaultConfigurationManager.class).createPrivilege(priv);

    return priv.getId();
  }
View Full Code Here

  }

  private void buildTestAuthenticationConfig(String status, String hash)
      throws InvalidConfigurationException
  {
    CPrivilege priv = new CPrivilege();
    priv.setId("priv");
    priv.setName("name");
    priv.setDescription("desc");
    priv.setType("method");

    CProperty prop = new CProperty();
    prop.setKey("method");
    prop.setValue("read");
    priv.addProperty(prop);

    prop = new CProperty();
    prop.setKey("permission");
    prop.setValue("somevalue");
    priv.addProperty(prop);

    configurationManager.createPrivilege(priv);

    CRole role = new CRole();
    role.setName("name");
View Full Code Here

    privilege.setReadOnly(true);
    privilege.setType("TEST");

    authzManager.addPrivilege(privilege);

    CPrivilege secPriv = this.getConfigurationManager().readPrivilege(privilege.getId());

    Assert.assertEquals(privilege.getId(), secPriv.getId());
    Assert.assertEquals(privilege.getName(), secPriv.getName());
    Assert.assertEquals(privilege.getDescription(), secPriv.getDescription());
    Assert.assertEquals(privilege.getType(), secPriv.getType());
    Assert.assertEquals(privilege.getProperties().size(), secPriv.getProperties().size());

    Map<String, String> props = this.getPropertyMap(secPriv);
    Assert.assertEquals("bar2", props.get("foo1"));
    Assert.assertEquals("foo2", props.get("bar1"));
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.