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

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


    final List<SecurityModel> securityModels = modelId == null ? getSecurityModels() : Collections.singletonList(getSecurityModel(modelId));
    checkAllModels(securityModels, object, operation, new SimpleCheckerFlow(object));
  }

  private List<EObject> loadRoles(final String applicationId, final String modelId, final String userId) throws UamClientException {
    final SecurityModel securityModel = getSecurityModel(modelId);
    final IUser user = userManager.getUser(userId);
    if (user == null) {
      throw new UamClientException(MessageFormat.format("User {0} is not found.", userId)); //$NON-NLS-1$
    }
    try {
View Full Code Here


    try {
      final IModelMetaInfo modelMetaInfo = applicationService.getModelMetaInfo(applicationId);
      if (modelMetaInfo == null) {
        throw new UamClientException(MessageFormat.format("Application {0} is not found or doesn't contain the model information.", applicationId)); //$NON-NLS-1$
      }
      final SecurityModel model = securityContainerFactory.getSecurityContainer(modelMetaInfo.getModel()).getModel();
      if (model == null) {
        throw new UamClientException(MessageFormat.format("Model {0} is not found", modelMetaInfo.getId())); //$NON-NLS-1$
      }
      return model;
    } catch (final RemoteAccessException e) {
View Full Code Here

    if (applicationIds.isEmpty()) {
      applicationIds.addAll(applicationService.getApplicationIds());
    }
    for (final String applicationId : applicationIds) {
      try {
        final SecurityModel securityModel = loadSecurityModel(applicationId);
        final String modelId = securityModel.getId();
        final String prevApplication = userContext.addApplication(modelId, applicationId);
        if (prevApplication != null) {
          throw new UamClientException(MessageFormat.format("Error in Flexess client initializing: the client can''t work with application ({0} and {1}), which contain the same model", applicationId, //$NON-NLS-1$
              prevApplication));
        }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  public boolean evaluate(String expression) {
    // 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();
    pObject.setName("TestProtectedObject");
    EAttribute pObjectRegionAttr = getRegionAttr();
    pObject.getEStructuralFeatures().add(pObjectRegionAttr);
    pObject.getPermission().add(permission);
    // permission.setPObject(pObject);
    // EMFUtil.addPobject(permission, pObject);
    model.getEClassifiers().add(pObject);

    // create operation
    POperation operation = UamFactory.eINSTANCE.createPOperation();
    operation.setName("TestOperation");
    pObject.getEOperations().add(operation);

    // Create role
    Role role = uamFactory.createRole();
    role.setName("TestRole");
    EReference permissionRef = EMFUtil.addPermission(role, permission);
    model.getEClassifiers().add(role);

    // get factory to create instances
    EFactory instanceFactory = model.getEFactoryInstance();

    // Create PObject instance
    EObject pObjectInstance = instanceFactory.create(pObject);
    pObjectInstance.eSet(pObjectRegionAttr, "EU");
View Full Code Here

  @Override
  public void checkModel(SecurityModel securityModel) throws ModelChangeException {
    ModelChangeException modelException = new ModelChangeException();
    List<RuleExecutionException> rulEx = modelException.getRuleExceptions();
    rulEx.addAll(checkModelData(securityModel));
    SecurityModel oldModel = modelDao.getSecurityModel(securityModel.getId());
    if (oldModel != null) {
      rulEx.addAll(processRoles(securityModel, oldModel));
    }
    if (modelException.getRuleExceptions().size() != 0) {
      throw modelException;
View Full Code Here

    resourceSet.getPackageRegistry().put(ExpressionPackage.eNS_URI, ExpressionPackage.eINSTANCE);
    URI securityFileURI = URI.createFileURI(secFile.getAbsolutePath());

    Resource secResource = resourceSet.getResource(securityFileURI, true);

    SecurityModel model = (SecurityModel)secResource.getContents().get(0);
    getDeployService().putModel(model, null);
  }
View Full Code Here

public class PutModelTest extends BaseDeployTest {

  @Test
  public void testPutModel() throws Exception {
    SecurityModel sm = OrdersModelGenerator.generateModel();
    String modelString = securityContainerFactory.getSecurityContainer(sm).getModelAsString();
    getDeployService().putModel(sm, modelString);
  }
View Full Code Here

  protected void tearDown() throws Exception {
    setFixture(null);
  }

  public void testCheck() {   
    SecurityModel tested = getFixture();
 
    String iId = "testId";   
    tested.setId(iId);
    assertEquals(iId, tested.getId());
  }
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);
   
    ICategoryManager manager = CategoryManager.getInstance();
    manager.addCategory("q1", perm1);
    assertEquals(true, manager.hasCategory("q1", perm1));
    manager.addCategory("q2", perm2);
View Full Code Here

  public Collection<PObject> getAllPObjects(String modelId) throws ObjectNotFoundException {
    if (!modelDao.hasModel(modelId)) {
      throw new ObjectNotFoundException("Model not found", modelId); //$NON-NLS-1$
    }
    SecurityModel securityModel = modelDao.getSecurityModel(modelId);
    return EcoreUtil.getObjectsByType(securityModel.getEClassifiers(), UamPackage.eINSTANCE.getPObject());
  }
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.