Package org.teiid.adminapi.impl

Examples of org.teiid.adminapi.impl.DataPolicyMetadata


    else if (property.getName().equals("dataPolicies")) { //$NON-NLS-1$
      List<ManagedObject> policies = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
      for(ManagedObject managedPolicy:policies) {
        String policyName = ManagedUtil.getSimpleValue(managedPolicy, "name", String.class); //$NON-NLS-1$
        Boolean anyAuthenticated = ManagedUtil.getSimpleValue(managedPolicy, "anyAuthenticated", Boolean.class); //$NON-NLS-1$
        DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
        policy.setAnyAuthenticated(Boolean.TRUE.equals(anyAuthenticated));
            ManagedProperty mappedRoleNames = managedPolicy.getProperty("mappedRoleNames");//$NON-NLS-1$
            if (mappedRoleNames != null){
                List<String> roleNames = (List<String>)MetaValueFactory.getInstance().unwrap(mappedRoleNames.getValue());
                policy.setMappedRoleNames(roleNames);
            }       
      }
    }   
    else if (property.getName().equals("overrideTranslators")) { //$NON-NLS-1$
      List<ManagedObject> translators = (List<ManagedObject>)MetaValueFactory.getInstance().unwrap(property.getValue());
View Full Code Here


 
  public void testAnyAuthenticated() {
    DQPWorkContext message = new DQPWorkContext();
    message.setSession(Mockito.mock(SessionMetadata.class));
    VDBMetaData vdb = new VDBMetaData();
    DataPolicyMetadata dpm = new DataPolicyMetadata();
    dpm.setAnyAuthenticated(true);
    vdb.addDataPolicy(dpm);
    Mockito.stub(message.getSession().getVdb()).toReturn(vdb);
   
    Map<String, DataPolicy> map = message.getAllowedDataPolicies();
    assertEquals(1, map.size());
View Full Code Here

        return svc;
    }
   
    //allow by default
    private DataPolicyMetadata exampleAuthSvc2() {
      DataPolicyMetadata svc = new DataPolicyMetadata();
      svc.setName("test"); //$NON-NLS-1$
     
      svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm1.g2")); //$NON-NLS-1$
      svc.addPermission(addResource(DataPolicy.PermissionType.READ, "pm1.g2")); //$NON-NLS-1$
      svc.addPermission(addResource(DataPolicy.PermissionType.READ, "pm2.g1")); //$NON-NLS-1$
       
      // pm2.g2
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm2.g2.e1")); //$NON-NLS-1$
       
        // pm3.g2
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm3.g2.e1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm3.g2.e2")); //$NON-NLS-1$
        svc.setAllowCreateTemporaryTables(false);
        return svc;
    }
View Full Code Here

        svc.setAllowCreateTemporaryTables(false);
        return svc;
    }
   
    private DataPolicyMetadata examplePolicyBQT() {
      DataPolicyMetadata svc = new DataPolicyMetadata();
      svc.setName("test"); //$NON-NLS-1$
      svc.addPermission(addResource(DataPolicy.PermissionType.ALTER, "VQT.SmallA_2589")); //$NON-NLS-1$
        return svc;
    }
View Full Code Here

    PermissionMetaData addResource(PermissionType type, String resource) {
      return addResource(type, true, resource);
    }

    private DataPolicyMetadata exampleAuthSvc1() {
      DataPolicyMetadata svc = new DataPolicyMetadata();
      svc.setName("test"); //$NON-NLS-1$
       
        // pm1.g1
        svc.addPermission(addResource(PermissionType.DELETE, "pm1.g1")); //$NON-NLS-1$
       
        svc.addPermission(addResource(DataPolicy.PermissionType.READ, "pm1.g1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.READ, "pm1.g1.e1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.READ, false, "pm1.g1.e2")); //$NON-NLS-1$

        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm1.g1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm1.g1.e1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm1.g1.e2")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm1.g1.e3")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm1.g1.e4")); //$NON-NLS-1$

        svc.addPermission(addResource(DataPolicy.PermissionType.UPDATE, "pm1.g1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.UPDATE, false, "pm1.g1.e1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.UPDATE, "pm1.g1.e2")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.UPDATE, "pm1.g1.e3")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.UPDATE, "pm1.g1.e4")); //$NON-NLS-1$
       

        // pm1.g2
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm1.g2")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, false, "pm1.g2.e1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm1.g2.e2")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm1.g2.e3")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.CREATE, "pm1.g2.e4")); //$NON-NLS-1$

        svc.addPermission(addResource(DataPolicy.PermissionType.UPDATE, "pm1.g2")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.UPDATE, false, "pm1.g2.e1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.UPDATE, "pm1.g2.e2")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.UPDATE, "pm1.g2.e3")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.UPDATE, "pm1.g2.e4")); //$NON-NLS-1$

        // pm1.g4
        svc.addPermission(addResource(DataPolicy.PermissionType.DELETE, "pm1.g4")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.DELETE, "pm1.g4.e1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.DELETE, "pm1.g4.e2")); //$NON-NLS-1$

        svc.addPermission(addResource(DataPolicy.PermissionType.READ, "pm1.sq1")); //$NON-NLS-1$
        svc.addPermission(addResource(DataPolicy.PermissionType.READ, "foo.xyz")); //$NON-NLS-1$
       
        return svc;
    }
View Full Code Here

    t1.addProperty("my-property", "my-value");
    List<Translator> list = new ArrayList<Translator>();
    list.add(t1);
    vdb.setOverrideTranslators(list);
   
    DataPolicyMetadata roleOne = new DataPolicyMetadata();
    roleOne.setName("roleOne");
    roleOne.setDescription("roleOne described");
   
    PermissionMetaData perm1 = new PermissionMetaData();
    perm1.setResourceName("myTable.T1");
    perm1.setAllowRead(true);
    roleOne.addPermission(perm1);
   
    PermissionMetaData perm2 = new PermissionMetaData();
    perm2.setResourceName("myTable.T2");
    perm2.setAllowRead(false);
    perm2.setAllowDelete(true);
    roleOne.addPermission(perm2);
   
    roleOne.setMappedRoleNames(Arrays.asList("ROLE1", "ROLE2"))
   
    vdb.addDataPolicy(roleOne);
   
    // convert to managed object and build the VDB out of MO
    ManagedObjectFactory mof = ManagedObjectFactoryBuilder.create();
    ManagedObject mo = mof.initManagedObject(vdb, null, null);
    vdb = AdminObjectBuilder.buildAO(mo, VDBMetaData.class);
   
    assertEquals("myVDB", vdb.getName());
    assertEquals("vdb description", vdb.getDescription());
    assertEquals(1, vdb.getVersion());
    assertEquals("vdb-value", vdb.getPropertyValue("vdb-property"))
   
    assertNotNull(vdb.getModel("model-one"));
    assertNotNull(vdb.getModel("model-two"));
    assertNull(vdb.getModel("model-unknown"));
   
    modelOne = vdb.getModel("model-one");
    assertEquals("model-one", modelOne.getName());
    assertEquals("s1", modelOne.getSourceNames().get(0));
    assertEquals(Model.Type.PHYSICAL, modelOne.getModelType());
    assertEquals("model-value-override", modelOne.getPropertyValue("model-prop"))
    assertFalse(modelOne.isVisible());
    assertEquals("model description", modelOne.getDescription());
   
    modelTwo = vdb.getModel("model-two");
    assertEquals("model-two", modelTwo.getName());
    assertTrue(modelTwo.getSourceNames().contains("s1"));
    assertTrue(modelTwo.getSourceNames().contains("s2"));
    assertEquals(Model.Type.VIRTUAL, modelTwo.getModelType()); // this is not persisted in the XML
    assertEquals("model-value", modelTwo.getPropertyValue("model-prop"))
   
   
    assertTrue(vdb.getValidityErrors().contains("There is an error in VDB"));
   
    List<Translator> translators = vdb.getOverrideTranslators();
    assertTrue(translators.size() == 1);
   
    Translator translator = translators.get(0);
    assertEquals("oracleOverride", translator.getName());
    assertEquals("oracle", translator.getType());
    assertEquals("my-value", translator.getPropertyValue("my-property"));
       
    List<DataPolicy> roles = vdb.getDataPolicies();
   
    assertTrue(roles.size() == 1);
   
    DataPolicyMetadata role = vdb.getDataPolicy("roleOne");
    assertEquals("roleOne described", role.getDescription());
    assertNotNull(role.getMappedRoleNames());
    assertTrue(role.getMappedRoleNames().contains("ROLE1"));
    assertTrue(role.getMappedRoleNames().contains("ROLE2"));
   
    List<DataPolicy.DataPermission> permissions = role.getPermissions();
    assertEquals(2, permissions.size());
   
    for (DataPolicy.DataPermission p: permissions) {
      if (p.getResourceName().equalsIgnoreCase("myTable.T1")) {
        assertTrue(p.getAllowRead());
View Full Code Here

      Collection<GroupSymbol> symbols, Context context) {
    logRequest(resources, context);
       
      boolean allowed = false;
      for(DataPolicy p:this.allowedPolicies.values()) {
      DataPolicyMetadata policy = (DataPolicyMetadata)p;
     
      if (policy.isAllowCreateTemporaryTables() == null) {
        if (allowCreateTemporaryTablesDefault) {
          allowed = true;
          break;
        }
      } else if (policy.isAllowCreateTemporaryTables()) {
        allowed = true;
        break;
      }
    }
     
View Full Code Here

        logRequest(resources, context);
       
        HashSet<String> results = new HashSet<String>(resources);
       
    for(DataPolicy p:this.allowedPolicies.values()) {
      DataPolicyMetadata policy = (DataPolicyMetadata)p;
     
      if (results.isEmpty()) {
        break;
      }
     
      Iterator<String> i = results.iterator();
      while (i.hasNext()) {       
        if (policy.allows(i.next(), action)) {
          i.remove();
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.teiid.adminapi.impl.DataPolicyMetadata

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.