Package gov.nasa.arc.mct.services.internal.component

Examples of gov.nasa.arc.mct.services.internal.component.User


        Assert.assertEquals(comp.getClass(), TelemetryUserDropBoxComponent.class);
        Assert.assertEquals(comp.getOwner(), "*");
        Assert.assertEquals(comp.getCreator(), id);
       
        // Verify that policy allows Remove Manifestation here
        User mockUser = Mockito.mock(User.class);
        Mockito.when(mockPlatform.getCurrentUser()).thenReturn(mockUser);
        Mockito.when(mockUser.getUserId()).thenReturn(id);
       
        PolicyContext context = new PolicyContext();
        AbstractComponent mockChild = Mockito.mock(AbstractComponent.class);
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), comp);
        context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(), Collections.singleton(mockChild));
View Full Code Here


       
        return result;
    }

    public boolean isComposable(AbstractComponent component) {
        User currentUser = PlatformAccess.getPlatform().getCurrentUser();
        return component.getOwner().equals(ANY_USER) || RoleAccess.canChangeOwner(component, currentUser);
    }
View Full Code Here

            return new ExecutionResult(context, false, "Invalid component.");

        // "*" is the wildcard owner, so always allow this
        // Otherwise, check for a match on owner
        // Finally, check if there is Group ownership of this component
        User user = PlatformAccess.getPlatform().getCurrentUser();
        String owner = component.getOwner();
        if (!owner.equals("*") && !owner.equals(user.getUserId()) && !RoleAccess.hasRole(user, owner)) {
            Group group = component.getCapability(Group.class); // Check for group ownership
            String groupId = group != null ? group.getDiscipline() : null;
            if (groupId == null || !groupId.equals(PlatformAccess.getPlatform().getCurrentUser().getDisciplineId())) {
                return new ExecutionResult(context, false, "User does not own this component.");
            }
View Full Code Here

  }
 
  @Override
  public User getUser(String userId) {
    EntityManager em = entityManagerFactory.createEntityManager();
    User u = null;
    try {
      MctUsers users = em.find(MctUsers.class, userId);
      if (users != null) {
        final String discipline = users.getDisciplineId().getDisciplineId();
        final String uId = users.getUserId();
       
        u = new User() {
          @Override
          public String getDisciplineId() {
            return discipline;
          }
         
View Full Code Here

 
  private Date getCurrentTimeFromDatabase() {
    if (platform==null) {
      return null;
    }
    User currentUser = platform.getCurrentUser();
    if (currentUser == null)
      return null;
   
    String userId = currentUser.getUserId();
    EntityManager em = entityManagerFactory.createEntityManager();
    try {
      TypedQuery<Date> q = em.createQuery("SELECT CURRENT_TIMESTAMP FROM ComponentSpec c WHERE c.owner = :owner", Date.class);
      q.setParameter("owner", userId);
      return q.getSingleResult();
View Full Code Here

        Mockito.when(mockPlatform.getPersistenceProvider()).thenReturn(mockPersistence);
        Mockito.when(mockPlatform.getWindowManager()).thenReturn(mockWindowing);

        // Expose sample users/groups through persistence
        for (int i = 0; i < 3; i++) {
            User mockUser = Mockito.mock(User.class);
            Mockito.when(mockUser.getUserId()).thenReturn(users[i]);
            Mockito.when(mockUser.getDisciplineId()).thenReturn(groups[i]);
            Mockito.when(mockPersistence.getUser(users[i])).thenReturn(mockUser);
        }
        Set<String> userSet = new HashSet<String>();
        userSet.addAll(Arrays.<String>asList(users));       
        Mockito.when(mockPersistence.getAllUsers()).thenReturn(userSet);
View Full Code Here

    }
   
    @BeforeMethod
    protected void setup() {
        MockitoAnnotations.initMocks(this);
        GlobalContext.getGlobalContext().switchUser(new User() {

            @Override
            public String getUserId() {
                return "abc";
            }
View Full Code Here

        ViewInfo view = context.getProperty(PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);
        if (!view.getViewClass().equals(UsersManifestation.class))
            return trueResult;
       
        User currentUser = PlatformAccess.getPlatform().getCurrentUser();
        if (currentUser.getDisciplineId() == ADMIN && currentUser.getUserId() == ADMIN)
            return new ExecutionResult(context, false, "Only admin user can add new users to group " + component.getDisplayName());
        else
            return trueResult;
    }
View Full Code Here

    @Mock private Platform mockPlatform;
    @Mock private AbstractComponent rootComponent;

    @BeforeMethod
    protected void postSetup() {
        GlobalContext.getGlobalContext().switchUser(new User() {

            @Override
            public String getUserId() {
                return "abc";
            }
View Full Code Here

    }
   
    @BeforeMethod
    protected void postSetup() {
        MockitoAnnotations.initMocks(this);
        GlobalContext.getGlobalContext().switchUser(new User() {

            @Override
            public String getUserId() {
                return "abc";
            }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.services.internal.component.User

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.