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

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


  }

  public static SecurityModel generateModel() {

    // This is creates base package
    SecurityModel pack = UamFactory.eINSTANCE.createSecurityModel();
    pack.setId("com.jresearchsoft.flexess.examples.orders.test"); //$NON-NLS-1$
    pack.setName("orders"); //$NON-NLS-1$
    pack.setNsPrefix("ord"); //$NON-NLS-1$
    pack.setNsURI("http://www.jresearchsoft.com/schemas/orders"); //$NON-NLS-1$
    EcoreUtil.setAnnotation(pack, UamPackage.eNS_URI, "#description", "test application"); //$NON-NLS-1$ //$NON-NLS-2$

    PObject order = UamFactory.eINSTANCE.createPObject();
    order.setId("order_pobject"); //$NON-NLS-1$
    order.setName("order"); //$NON-NLS-1$

    EcoreUtil.setAnnotation(order, UamPackage.eNS_URI, "#class_name", "com.jresearchsoft.uam.client.tests.Order"); //$NON-NLS-1$ //$NON-NLS-2$
    EcoreUtil.setAnnotation(order, UamPackage.eNS_URI, "#mapper_name", "com.jresearchsoft.uam.client.mappers.impl.JavaInstanceMapper"); //$NON-NLS-1$ //$NON-NLS-2$
    EcoreUtil.setAnnotation(order, UamPackage.eNS_URI, "#description", "customer order"); //$NON-NLS-1$ //$NON-NLS-2$
    pack.getEClassifiers().add(order);

    // region is an attribute for pObject and
    EAttribute region = EcoreFactory.eINSTANCE.createEAttribute();
    region.setName("region"); //$NON-NLS-1$
    EcoreUtil.setAnnotation(region, UamPackage.eNS_URI, "#description", "region where the order comes"); //$NON-NLS-1$ //$NON-NLS-2$
    region.setEType(EcorePackage.eINSTANCE.getEString());

    order.getEStructuralFeatures().add(region);
    // user id is an attribute - id of the current user
    EAttribute userID = EcoreFactory.eINSTANCE.createEAttribute();
    EcoreUtil.setAnnotation(userID, UamPackage.eNS_URI, IAttributeConstant.ANNOTATION_KEY_RUNTIME, "true"); //$NON-NLS-1$
    userID.setName("userId"); //$NON-NLS-1$
    userID.setEType(EcorePackage.eINSTANCE.getEString());
    order.getEStructuralFeatures().add(userID);

    // Now we create basic operations and add them to order
    POperation createOp = UamFactory.eINSTANCE.createPOperation();
    createOp.setId("create_operation"); //$NON-NLS-1$
    createOp.setName("create"); //$NON-NLS-1$

    POperation viewOp = UamFactory.eINSTANCE.createPOperation();
    viewOp.setId("view_operation"); //$NON-NLS-1$
    viewOp.setName("view"); //$NON-NLS-1$

    POperation deleteOp = UamFactory.eINSTANCE.createPOperation();
    deleteOp.setId("delete_operation"); //$NON-NLS-1$
    deleteOp.setName("delete"); //$NON-NLS-1$

    POperation updateOp = UamFactory.eINSTANCE.createPOperation();
    updateOp.setId("update_operation"); //$NON-NLS-1$
    updateOp.setName("update"); //$NON-NLS-1$

    order.getEOperations().add(createOp);
    order.getEOperations().add(viewOp);
    order.getEOperations().add(deleteOp);
    order.getEOperations().add(updateOp);

    final String USER_EXPRESSION = "context orders::user_permission inv: login=object.userId"; //$NON-NLS-1$
    final String REGION_EXPRESSION = "context orders::regional_permission inv: region=object.region"; //$NON-NLS-1$

    Permission regionalPermission = UamFactory.eINSTANCE.createPermission();
    regionalPermission.setId("regional_permission"); //$NON-NLS-1$
    regionalPermission.setName("regional_permission"); //$NON-NLS-1$
    Constraint constraint = UamFactory.eINSTANCE.createConstraint();
    regionalPermission.setConstraint(constraint);
    constraint.setExpession(REGION_EXPRESSION);
    region = EcoreFactory.eINSTANCE.createEAttribute();
    region.setName("region"); //$NON-NLS-1$
    EcoreUtil.setAnnotation(region, UamPackage.eNS_URI, "#description", "region where the order comes"); //$NON-NLS-1$ //$NON-NLS-2$
    region.setEType(EcorePackage.eINSTANCE.getEString());
    regionalPermission.getEStructuralFeatures().add(region);
    regionalPermission.setPObject(order);
    // EMFUtil.addPobject(regionalPermission, order);
    pack.getEClassifiers().add(regionalPermission);

    // viewOp.getPermission().add(regionalPermission);
    // createOp.getPermission().add(regionalPermission);
    // deleteOp.getPermission().add(regionalPermission);
    // updateOp.getPermission().add(regionalPermission);

    Permission userPermission = UamFactory.eINSTANCE.createPermission();
    userPermission.setId("user_permission"); //$NON-NLS-1$
    userPermission.setName("user_permission"); //$NON-NLS-1$
    Constraint userConstraint = UamFactory.eINSTANCE.createConstraint();
    userPermission.setConstraint(userConstraint);
    userConstraint.setExpession(USER_EXPRESSION);
    userID = EcoreFactory.eINSTANCE.createEAttribute();
    EcoreUtil.setAnnotation(userID, UamPackage.eNS_URI, IAttributeConstant.ANNOTATION_KEY_RUNTIME, "true"); //$NON-NLS-1$
    userID.setName("login"); //$NON-NLS-1$
    userID.setEType(EcorePackage.eINSTANCE.getEString());
    userPermission.getEStructuralFeatures().add(userID);
    pack.getEClassifiers().add(userPermission);

    Role manager = UamFactory.eINSTANCE.createRole();
    manager.setId("manager_role"); //$NON-NLS-1$
    manager.setName("regional manager"); //$NON-NLS-1$
    EcoreUtil.setAnnotation(manager, UamPackage.eNS_URI, "#description", "orders manager"); //$NON-NLS-1$ //$NON-NLS-2$
    pack.getEClassifiers().add(manager);
    EMFUtil.addPermission(manager, regionalPermission);

    Role customer = UamFactory.eINSTANCE.createRole();
    customer.setId("customer_role"); //$NON-NLS-1$
    customer.setName("customer"); //$NON-NLS-1$
    EcoreUtil.setAnnotation(customer, UamPackage.eNS_URI, "#description", "orders customer"); //$NON-NLS-1$ //$NON-NLS-2$
    pack.getEClassifiers().add(customer);
    userPermission.setPObject(order);
    // EMFUtil.addPobject(userPermission, order);
    // order.getPermission().add(userPermission);
    EMFUtil.addPermission(customer, userPermission);
    return pack;
View Full Code Here


    // TODO Cathy - fix tests
    // Collection<SecurityModel> securityModels =
    // getDeployService().getSecurityModels();
    Collection<SecurityModel> securityModels = Collections.emptyList();
    assertEquals(securityModels.size(), 1);
    SecurityModel sm1 = securityModels.iterator().next();
    assertNotNull(sm1);
    SecurityModel sm = ChangeModel3.generateModel(sm1);
    getDeployService().putModel(sm, null);
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Override
  public SecurityModel rawConvert() throws LoadModelException {
    SecurityModel result = super.rawConvert();
    for (ProtectedObjectType object : getXmlElement().getProtectedObject()) {
      PObject pObject = new PObjectConverter(object, getConverted()).convert();
      result.getEClassifiers().add(pObject);
      for (Permission permission : (EList<Permission>)pObject.getPermission()) {
        result.getEClassifiers().add(permission);
      }
    }
    for (RoleTemplateType role : getXmlElement().getRoleTemplate()) {
      result.getEClassifiers().add(new RoleTemplateConverter(role, getConverted()).convert());
    }
    return result;
  }
View Full Code Here

      }
    }
    for (Resource modelResource : localXmlModels) {
      if (modelResource.exists() && modelResource.isReadable()) {
        try {
          SecurityModel securityModel = uamXmlLoader.load(modelResource.getInputStream());
          if (result.containsKey(securityModel.getId())) {
            logger.debug("Ignore an XML UAM model {} from {}: already loaded.", modelResource.getFilename(), modelResource.getURI().toString()); //$NON-NLS-1$
            continue;
          }
          String modelString = securityContainerFactory.getSecurityContainer(securityModel).getModelAsString();
          result.put(securityModel.getId(), modelString);
          logger.debug("Found an XML UAM model {} in {}", modelResource.getFilename(), modelResource.getURI().toString()); //$NON-NLS-1$
        } catch (Exception e) {
          logger.error("Can't load the model {}: {}. Skip it.", modelResource.getDescription(), e.getLocalizedMessage()); //$NON-NLS-1$
          logger.debug(e.getLocalizedMessage(), e);
        }
View Full Code Here

    Collection<String> models = loadLocalModels();
    if (serverAvailabilityLock.tryLock()) {
      try {
        modelService.unloadModels();
        for (String modelString : models) {
          SecurityModel model = securityContainerFactory.getSecurityContainer(modelString).getModel();
          try {
            putModel(model, modelString);
            applicationContext.publishEvent(new DeployedModelEvent(model.getId()));
            logger.info("The model {} has been loaded", model.getId()); //$NON-NLS-1$
          } catch (ModelChangeException e) {
            logger.warn("Can't load the model {}: {}", model.getId(), e.getLocalizedMessage()); //$NON-NLS-1$
          }
        }
      } finally {
        serverAvailabilityLock.unlock();
      }
View Full Code Here

    return modelDAO.getSecurityModels();
  }

  @Override
  public IElementDescription getModelDescription(String modelId) {
    SecurityModel model = modelDAO.getSecurityModel(modelId);
    if (model == null) {
      return null;
    }
    return makeDescription(model);
  }
View Full Code Here

  private ISecurityContainerFactory securityContainerFactory;

  private void loadRegistry() {
    List<ModelMetaInfo> models = getAll();
    for (IModelMetaInfo modelMetaInfo : models) {
      SecurityModel smodel = securityContainerFactory.getSecurityContainer(modelMetaInfo.getModel()).getModel();
      modelRegistry.addModel(smodel, modelMetaInfo.getModel());
    }

    //    List<IModelMetaInfo> models = getHibernateTemplate().find(MessageFormat.format("from {0}", ModelMetaInfo.class.getName())); //$NON-NLS-1$
    // for (IModelMetaInfo modelMetaInfo : models) {
View Full Code Here

  private IModelMetaInfo makeModel(String id) {
    String secModel = modelRegistry.getOriginalModel(id);
    if (secModel == null) {
      return null;
    }
    SecurityModel model = modelRegistry.getModel(id);
    ModelMetaInfo mm = new ModelMetaInfo();
    mm.setId(id);
    mm.setModel(secModel);
    mm.setDescription(EcoreUtil.getAnnotation(model, UamPackage.eNS_URI, IPObjectConstant.DESCRIPTION_ATTR));
    return mm;
View Full Code Here

  @Override
  public void saveModel(ModelMetaInfo model) {
    save(model);
    // getHibernateTemplate().saveOrUpdate(model);
    String modelStr = model.getModel();
    SecurityModel smodel = securityContainerFactory.getSecurityContainer(modelStr).getModel();
    modelRegistry.addModel(smodel, model.getModel());
  }
View Full Code Here

  public void addModel(ModelMetaInfo model) {
    if (modelRegistry.isEmpty()) {
      loadRegistry();
    }
    String modelStr = model.getModel();
    SecurityModel smodel = securityContainerFactory.getSecurityContainer(modelStr).getModel();
    modelRegistry.addModel(smodel, modelStr);
  }
View Full Code Here

TOP

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

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.