Package org.jresearch.flexess.core.model.uam

Examples of org.jresearch.flexess.core.model.uam.Permission


    }
    final EFactory securityFactory = securityModel.getEFactoryInstance();
    final EObject roInstance = securityFactory.create(role);
    final Set<IPermissionInstanceMetaInfo> permissionInstances = roleInst.getPermissionInstances();
    for (final IPermissionInstanceMetaInfo instance : permissionInstances) {
      final Permission permission = findPermission(securityModel, instance.getPermissionId());
      if (permission == null) {
        throw new InconsistentModelException("Inconsistent model. Permission " + instance.getPermissionId() //$NON-NLS-1$
            + " is not found. It can be caused by model upgrade on the server. Restart application to load new model."); //$NON-NLS-1$
      }
      final EReference permissionRef = EMFUtil.getPermission(role, permission);
View Full Code Here


    final Role role = UamFactory.eINSTANCE.createRole();
    role.setId(roleInst.getRoleId());
    role.setName(roleInst.getName());
    final Set<IPermissionInstanceMetaInfo> permissionInstances = roleInst.getPermissionInstances();
    for (final IPermissionInstanceMetaInfo info : permissionInstances) {
      final Permission permission = findPermission(model, info.getPermissionId());
      if (permission == null) {
        throw new InconsistentModelException(MessageFormat.format("Inconsistent model. Permission {0} is not found. It can be caused by model upgrade on the server. Restart application to load new model.", info.getPermissionId())); //$NON-NLS-1$
      }
      EMFUtil.addPermission(role, permission);
    }
View Full Code Here

        return true;
    return false;
  }

  private boolean checkPermission(EObject pObjectInstance, EObject permissionInstance) {
    Permission permission = (Permission) permissionInstance.eClass();
    permissionInstance.eSet(permission.getEStructuralFeature(IPermissionConstant.OBJECT), pObjectInstance);
    String expession = permission.getConstraint().getExpession();
    OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject> ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
    OCLHelper<EClassifier, ?, ?, Constraint> helper = ocl.createOCLHelper();
    helper.setContext(permission);
    try {
      Constraint constraint = helper.createInvariant(expession);
View Full Code Here

    // Create security model
    SecurityModel model = uamFactory.createSecurityModel();
    model.setName("com_security");

    // Create permission with region attribute
    Permission permission = uamFactory.createPermission();
    permission.setName("TestPermission");
    EAttribute permRegionAttr = getRegionAttr();
    permission.getEStructuralFeatures().add(permRegionAttr);
    Constraint constraint = uamFactory.createConstraint();
    permission.setConstraint(constraint);
    constraint.setExpession(expression);
    model.getEClassifiers().add(permission);

    // Create protected object with region attribute
    PObject pObject = uamFactory.createPObject();
View Full Code Here

    HashMap<String, Permission> permissions = new HashMap<String, Permission>();
    List<EStructuralFeature> structuralFeatures = role.getEStructuralFeatures();
    for (EStructuralFeature feature : structuralFeatures) {
      EClassifier type = feature.getEType();
      if (UamPackage.eINSTANCE.getPermission().isInstance(type)) {
        Permission perm = (Permission)type;
        permissions.put(perm.getId(), perm);
      }
    }
    return permissions;
  }
View Full Code Here

    super.testCode();
  }

  @Override
  protected SecurityModel modifyModel(SecurityModel pack) {
    Permission permission = null;
    Collection<Permission> permissions = EcoreUtil.getObjectsByType(pack.getEClassifiers(), UamPackage.eINSTANCE.getPermission());
    for (Permission object : permissions) {
      if (object.getId().equals("test_permission")) { //$NON-NLS-1$
        permission = object;
      }
    }
    if (permission == null) {
      throw new AssertionFailedError("No test permission defined"); //$NON-NLS-1$
    }
    EAttribute attr = (EAttribute) permission.getEStructuralFeature("attr2"); //$NON-NLS-1$
    permission.getEStructuralFeatures().remove(attr);

    attr = EcoreFactory.eINSTANCE.createEAttribute();
    attr.setName("wwattr2"); //$NON-NLS-1$
    EcoreUtil.setAnnotation(attr, UamPackage.eNS_URI, "#description", "test attr"); //$NON-NLS-1$ //$NON-NLS-2$
    attr.setEType(EcorePackage.eINSTANCE.getEString());
    attr.setDefaultValue("1"); //$NON-NLS-1$
    permission.getEStructuralFeatures().add(attr);

    return pack;
  }
View Full Code Here

public class ChangeModel3 {

  public static SecurityModel generateModel(SecurityModel pack) {

    Permission permission = null;
    Collection<Permission> permissions = EcoreUtil.getObjectsByType(pack.getEClassifiers(), UamPackage.eINSTANCE.getPermission());
    for (Permission object : permissions) {
      if (object.getId().equals("regional_permission")) {
        permission = object;
      }
    }
    if (permission == null) {
      throw new AssertionFailedError("No test permission defined");
    }
    List<Role> roles = EMFUtil.getRoles(permission);
    for (Role role : roles) {
      List<EStructuralFeature> features = role.getEStructuralFeatures();
      EStructuralFeature featureFound = null;
      for (EStructuralFeature feature : features) {
        if (feature.getName().equals(permission.getName())) {
          featureFound = feature;
          break;
        }
      }
      features.remove(featureFound);
View Full Code Here

  private List<RuleExecutionException> compareRoles(Role oldRole, Role newRole, HashMap<String, Permission> idToPermissions) {
    List<RuleExecutionException> exceptions = new ArrayList<RuleExecutionException>();
    List<Permission> oldPermissions = EMFUtil.getPermissions(oldRole);
    HashMap<String, Permission> newPermissions = EMFUtil.getPermissionsMap(newRole);
    for (Permission oldPermission : oldPermissions) {
      Permission newPermission = newPermissions.get(oldPermission.getId());
      // permission that matches was found
      if (newPermission != null) {
        // links remained
        // if permissions were not processed before, process them
        if (idToPermissions.get(newPermission.getId()) != null) {
          exceptions.addAll(comparePermissions(oldPermission, newPermission));
          idToPermissions.remove(newPermission.getId());
        }
      } else {
        // link was deleted
        try {
          fireModelChanged(oldRole, oldPermission, Operations.PERMISSION_DELETED);
View Full Code Here

  public void testCheck() {
    Constraint tested = getFixture();
    String iId = "testId";
    String iExpression = "testExpression";
    Permission iPermission = UamFactory.eINSTANCE.createPermission();
   
    tested.setId(iId);
    tested.setExpession(iExpression);
    tested.setPermission(iPermission);
   
View Full Code Here

public class CategoryTest extends TestCase {

  public void testCategories() throws Exception{
   
    SecurityModel pack = UamFactory.eINSTANCE.createSecurityModel();
    Permission perm1 = UamFactory.eINSTANCE.createPermission();
    Permission perm2 = UamFactory.eINSTANCE.createPermission();
    Permission perm3 = UamFactory.eINSTANCE.createPermission();
   
    perm1.setId("p1");
    perm2.setId("p2");
    perm3.setId("p3");
   
    perm1.setName("p1");
    perm2.setName("p2");
    perm3.setName("p3");
   
    pack.getEClassifiers().add(perm1);
    pack.getEClassifiers().add(perm2);
    pack.getEClassifiers().add(perm3);
   
View Full Code Here

TOP

Related Classes of org.jresearch.flexess.core.model.uam.Permission

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.