@Override public boolean canCreate() { return authorizationManager.authorize(PLANNER_AVAILABLE, sessionInfo.getIdentity()); } }
private void setAssetsManagementGrant() { assetsManagementIsGranted = authorizationManager.authorize(CONFIGURE_REPOSITORY, sessionInfo.getIdentity()); view.enableManagedRepoCreation(assetsManagementIsGranted); } }
boolean hasAccessToPerspective(final String perspectiveId) { ResourceRef resourceRef = new ResourceRef(perspectiveId, ActivityResourceType.PERSPECTIVE); return authorizationManager.authorize(resourceRef, sessionInfo.getIdentity()); }
@Override public void deleteKey(final PortableSSHPublicKey portableKey) { SSHKeyStore keyStore = keyStoreService.keyStore(); Collection<SSHPublicKey> keys = keyStore.getUserKeys(sessionInfo.getIdentity().getIdentifier()); keys.stream() .filter(key -> key.getId().equals(portableKey.getId())) .findAny() .ifPresent(sshPublicKey -> keyStore.removeUserKey(sessionInfo.getIdentity().getIdentifier(), sshPublicKey)); }
@Override public boolean canEditContributors(final List<Contributor> contributors, final ContributorType type) { boolean canEdit = false; final Optional<Contributor> contributor = contributors.stream().filter(c -> c.getUsername().equals(sessionInfo.getIdentity().getIdentifier())).findFirst(); if (contributor.isPresent()) { final ContributorType userContributorType = contributor.get().getType(); canEdit = contributorsSecurityUtils.canUserEditContributorOfType(userContributorType, type); } canEdit = canEdit || organizationalUnitController.canUpdateOrgUnit(libraryPlaces.getActiveSpace()); return canEdit; }
@Override public boolean canEditContributors(final List<Contributor> contributors, final ContributorType type) { boolean canEdit = false; final Optional<Contributor> contributor = contributors.stream().filter(c -> c.getUsername().equals(sessionInfo.getIdentity().getIdentifier())).findFirst(); if (contributor.isPresent()) { final ContributorType userContributorType = contributor.get().getType(); canEdit = contributorsSecurityUtils.canUserEditContributorOfType(userContributorType, type); } canEdit = canEdit || projectController.canUpdateProject(libraryPlaces.getActiveWorkspace()); return canEdit; }
@Override public String get() { return sessionInfo.getIdentity().getIdentifier(); } }
private void fireNewBranchEvent(final Path targetRoot, final org.uberfire.java.nio.file.Path nioTargetRepositoryRoot) { final Repository repository = repoService.getRepository(targetRoot); final Optional<Branch> branch = repository.getBranch(Paths.convert(nioTargetRepositoryRoot.getRoot())); if (branch.isPresent()) { newBranchEvent.fire(new NewBranchEvent(repository, branch.get().getName(), sessionInfo.getIdentity())); } else { throw new IllegalStateException("Could not find a branch that was just created. The Path used was " + nioTargetRepositoryRoot.getRoot()); } }
@Test public void testNotLoggedUserName() { doThrow(new ContextNotActiveException()).when(sessionInfo).getIdentity(); final String username = serverUsernameProvider.get(); verify(sessionInfo).getIdentity(); assertEquals("not-logged-user", username); } }
public void recordOpeningEvent( @Observes final ResourceOpenedEvent event ) { checkNotNull( "event", event ); final org.uberfire.backend.vfs.Path resourcePath = event.getPath(); try { ioService.startBatch( bootstrapFS.getRootDirectories().iterator().next().getFileSystem() ); recordOpeningEvent( resourcePath.toURI(), resourcePath.getFileName().toString(), event.getSessionInfo().getIdentity().getIdentifier() ); } finally { ioService.endBatch(); } }
@Test public void testLoggedUserName() { final String username = serverUsernameProvider.get(); verify(sessionInfo).getIdentity(); assertEquals(sessionInfo.getIdentity().getIdentifier(), username); }
@Before public void setup() { setupRpcContext(); User testUser = new UserImpl("testUser"); when(sessionInfo.getIdentity()).thenReturn(testUser); when(queueSession.getAttribute(HttpSession.class, HttpSession.class.getName())).thenReturn(httpSession); }
@Test public void returnDefaultUserOutsideOfSessionThread() { when(userInstance.isAmbiguous()).thenReturn(false); when(userInstance.isUnsatisfied()).thenReturn(false); when(userInstance.get()).thenReturn(defaultUser); SessionInfo sessionInfo = factory.getSessionInfo(authService); assertSame(defaultUser, sessionInfo.getIdentity()); }
@Test public void testManagedRepositoryIsEnabledInNewRepoWizard() { reset(infoPageView); when(authorizationManager.authorize(RepositoryFeatures.CONFIGURE_REPOSITORY, sessionInfo.getIdentity())).thenReturn(true); createRepositoryWizard.setupPages(); verify(infoPageView).enabledManagedRepositoryCreation(true); verify(infoPageView, never()).enabledManagedRepositoryCreation(false); }
@Test public void testManagedRepositoryIsDisabledInCloneRepoDialog() { reset(view); when(authorizationManager.authorize(RepositoryFeatures.CONFIGURE_REPOSITORY, sessionInfo.getIdentity())).thenReturn(false); presenter.init(); verify(view, never()).enableManagedRepoCreation(true); verify(view).enableManagedRepoCreation(false); }
@Test public void testManagedRepositoryIsDisabledInNewRepoWizard() { reset(infoPageView); when(authorizationManager.authorize(RepositoryFeatures.CONFIGURE_REPOSITORY, sessionInfo.getIdentity())).thenReturn(false); createRepositoryWizard.setupPages(); verify(infoPageView, never()).enabledManagedRepositoryCreation(true); verify(infoPageView).enabledManagedRepositoryCreation(false); }
public void save() { final String name = view.getName(); final String defaultGroupId = "com." + view.getName().toLowerCase(); final String owner = sessionInfo.getIdentity().getIdentifier(); view.showBusyIndicator(view.getSavingMessage()); validateFields(() -> saveCreation(name, defaultGroupId, owner)); }
@Test public void testSourceEditorReadOnly() { //authorization manager sets sourceEditionEnabled to false when(authorizationManager.authorize(DataModelerFeatures.EDIT_SOURCES, sessionInfo.getIdentity())) .thenReturn(false); presenter.onStartup(path, placeRequest); verify(javaSourceEditor).setReadonly(true); presenter.loadContent(); verify(javaSourceEditor, times(2)).setReadonly(true); } }
@Before public void setup() { final SessionInfo sessionInfo = new SessionInfoMock(); final UsernameProvider usernameProvider = mock( UsernameProvider.class ); doReturn( sessionInfo.getIdentity().getIdentifier() ).when( usernameProvider ).get(); scopeTypes = new WorkbenchPreferenceScopeTypes( usernameProvider ); }
@Before public void initTest() { super.initTest(); initService(); when(sessionInfo.getIdentity()).thenAnswer((Answer<User>) invocationOnMock -> new UserImpl(userName)); service = new SSHKeyEditorServiceImpl(sessionInfo, keyStoreService); }