public Authorizations getAuthorizations(User user) { Authorizations authorizations; authorizations = authorizationRepository.getGraphAuthorizations( user, VISIBILITY_STRING, UserRepository.VISIBILITY_STRING ); return authorizations; }
public SimpleOrmContext getSimpleOrmContext(User user) { Set<String> authorizationsSet = authorizationRepository.getAuthorizations(user); String[] authorizations = authorizationsSet.toArray(new String[authorizationsSet.size()]); return getSimpleOrmContext(authorizations); }
@Override public void updateUser(User user, AuthorizationContext authorizationContext) { Vertex userVertex = findByIdUserVertex(user.getUserId()); ExistingElementMutation<Vertex> m = userVertex.prepareMutation(); Date currentLoginDate = UserVisalloProperties.CURRENT_LOGIN_DATE.getPropertyValue(userVertex); if (currentLoginDate != null) { UserVisalloProperties.PREVIOUS_LOGIN_DATE.setProperty(m, currentLoginDate, VISIBILITY.getVisibility()); } String currentLoginRemoteAddr = UserVisalloProperties.CURRENT_LOGIN_REMOTE_ADDR.getPropertyValue(userVertex); if (currentLoginRemoteAddr != null) { UserVisalloProperties.PREVIOUS_LOGIN_REMOTE_ADDR.setProperty( m, currentLoginRemoteAddr, VISIBILITY.getVisibility() ); } UserVisalloProperties.CURRENT_LOGIN_DATE.setProperty(m, new Date(), VISIBILITY.getVisibility()); UserVisalloProperties.CURRENT_LOGIN_REMOTE_ADDR.setProperty( m, authorizationContext.getRemoteAddr(), VISIBILITY.getVisibility() ); int loginCount = UserVisalloProperties.LOGIN_COUNT.getPropertyValue(userVertex, 0); UserVisalloProperties.LOGIN_COUNT.setProperty(m, loginCount + 1, VISIBILITY.getVisibility()); m.save(authorizations); graph.flush(); getPrivilegeRepository().updateUser(user, authorizationContext); getAuthorizationRepository().updateUser(user, authorizationContext); fireUserLoginEvent(user, authorizationContext); }
@Inject public ReindexLongRunningProcessWorker( Graph graph, UserRepository userRepository, AuthorizationRepository authorizationRepository ) { this.graph = graph; this.authorizations = authorizationRepository.getGraphAuthorizations(userRepository.getSystemUser()); }
public JSONObject toJsonWithAuths(User user) { JSONObject json = toJson(user); JSONArray authorizations = new JSONArray(); for (String a : authorizationRepository.getAuthorizations(user)) { authorizations.put(a); } json.put("authorizations", authorizations); json.put("uiPreferences", user.getUiPreferences()); Set<String> privileges = privilegeRepository.getPrivileges(user); json.put("privileges", Privilege.toJson(privileges)); return json; }
public Authorizations getGraphAuthorizations(User user, String... authorizations) { return getAuthorizationRepository().getGraphAuthorizations(user, authorizations); }
/** * This is different from the non-private method in that it returns authorizations, * long running processes, etc for that user. */ public ClientApiUser toClientApiPrivate(User user) { ClientApiUser u = toClientApi(user); for (String a : authorizationRepository.getAuthorizations(user)) { u.addAuthorization(a); } for (JSONObject json : getLongRunningProcesses(user)) { u.getLongRunningProcesses().add(ClientApiConverter.toClientApiValue(json)); } u.setUiPreferences(JSONUtil.toJsonNode(user.getUiPreferences())); u.getProperties().putAll(user.getCustomProperties()); Set<String> privileges = privilegeRepository.getPrivileges(user); u.getPrivileges().addAll(privileges); return u; }
@Inject public Ping( UserRepository userRepository, Graph graph, WorkQueueRepository workQueueRepository, LongRunningProcessRepository longRunningProcessRepository, PingUtil pingUtil, AuthorizationRepository authorizationRepository ) { this.graph = graph; this.workQueueRepository = workQueueRepository; this.longRunningProcessRepository = longRunningProcessRepository; this.pingUtil = pingUtil; this.authorizations = authorizationRepository.getGraphAuthorizations(userRepository.getSystemUser()); }
public static Authorizations getAuthorizations( HttpServletRequest request, UserRepository userRepository, AuthorizationRepository authorizationRepository, WorkspaceRepository workspaceRepository ) { User user = VisalloBaseParameterProvider.getUser(request, userRepository); if (user == null) { return null; } String workspaceId = VisalloBaseParameterProvider.getActiveWorkspaceIdOrDefault(request, workspaceRepository, userRepository); if (workspaceId != null) { return authorizationRepository.getGraphAuthorizations(user, workspaceId); } return authorizationRepository.getGraphAuthorizations(user); }
protected void before() { graph = InMemoryGraph.create(); when(metricsManager.counter(any())).thenReturn(mockCounter); when(metricsManager.counter(any(), any())).thenReturn(mockCounter); when(metricsManager.timer(any())).thenReturn(mockTimer); when(metricsManager.timer(any(), any())).thenReturn(mockTimer); when(metricsManager.meter(any())).thenReturn(mockMeter); when(metricsManager.meter(any(), any())).thenReturn(mockMeter); when(userRepository.getSystemUser()).thenReturn(systemUser); when(authorizationRepository.getGraphAuthorizations(systemUser)).thenReturn(systemUserAuthorizations); }
@Handle public ClientApiEdgeMultipleResponse handle( @Required(name = "edgeIds[]") String[] edgeIdsParameter, @ActiveWorkspaceId(required = false) String workspaceId, HttpServletRequest request, User user ) throws Exception { Authorizations authorizations = workspaceId != null ? authorizationRepository.getGraphAuthorizations(user, workspaceId) : authorizationRepository.getGraphAuthorizations(user); return getEdges(request, workspaceId, Sets.newHashSet(edgeIdsParameter), authorizations); }
@Handle public JSONObject stats( User user ) { Authorizations authorizations = authorizationRepository.getGraphAuthorizations( user, PingUtil.VISIBILITY_STRING ); JSONObject json = new JSONObject(); int[] minutes = {1, 5, 15}; for (int i : minutes) { json.put(Integer.toString(i), pingUtil.getAverages(i, graph, authorizations)); } return json; } }
@Override public ClientApiSearchListResponse getSavedSearches(User user) { checkNotNull(user, "User is required"); Authorizations authorizations = authorizationRepository.getGraphAuthorizations( user, VISIBILITY_STRING, UserRepository.VISIBILITY_STRING ); ClientApiSearchListResponse result = new ClientApiSearchListResponse(); Iterables.addAll(result.searches, getGlobalSavedSearches(authorizations)); Iterables.addAll(result.searches, getUserSavedSearches(user, authorizations)); return result; }
protected Authorizations getAuthorizations() { if (this.authorizations == null) { this.authorizations = getAuthorizationRepository().getGraphAuthorizations(getUser()); } return this.authorizations; }
@Override public ClientApiSearch getSavedSearch(String id, User user) { Authorizations authorizations = authorizationRepository.getGraphAuthorizations( user, VISIBILITY_STRING, UserRepository.VISIBILITY_STRING ); Vertex searchVertex = graph.getVertex(id, authorizations); if (searchVertex == null) { return null; } return toClientApiSearch(searchVertex); }
private Authorizations getAuthorizations(IngestOptions ingestOptions) { return authorizationRepository.getGraphAuthorizations(ingestOptions.getIngestUser(), ingestOptions.getAdditionalAuthorizations()); }
private void ensureOntologyDefined() { try (InputStream graphOwl = GraphWebAppPlugin.class.getResourceAsStream("graph.owl")) { byte[] inFileData = IOUtils.toByteArray(graphOwl); IRI graphIRI = IRI.create(GraphProductOntology.IRI); Authorizations authorizations = authorizationRepository.getGraphAuthorizations(this.userRepository.getSystemUser()); ontologyRepository.importFileData(inFileData, graphIRI, null, authorizations); } catch (Exception e) { throw new VisalloException("Could not read graph.owl file", e); } } }
public Vertex getProductVertex(String workspaceId, String productId, User user) { Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations( user, VISIBILITY_STRING, workspaceId ); return getGraph().getVertex(productId, authorizations); }
@Test public void testPushWorkspaceChangeDifferentUser() { ClientApiWorkspace clientApiWorkspace = new ClientApiWorkspace(); clientApiWorkspace.setWorkspaceId("ws1"); List<ClientApiWorkspace.User> previousUsers = new ArrayList<>(); ClientApiWorkspace.User previousUser = new ClientApiWorkspace.User(); previousUser.setUserId("mockUser1"); previousUsers.add(previousUser); String changedByUserId = "mockUser2"; String changedBySourceGuid = "123-123-1234"; Authorizations mockUser1Auths = graph.createAuthorizations("mockUser1Auths"); when(userRepository.findById(changedByUserId)).thenReturn(mockUser2); when(workspaceRepository.findById(eq("ws1"), eq(mockUser2))).thenReturn(workspace); when(userRepository.findById(eq("mockUser1"))).thenReturn(mockUser1); when(authorizationRepository.getGraphAuthorizations(eq(mockUser1), eq("ws1"))).thenReturn(mockUser1Auths); when(workspaceRepository.toClientApi(eq(workspace), eq(mockUser1), any())).thenReturn(clientApiWorkspace); workQueueRepository.pushWorkspaceChange(clientApiWorkspace, previousUsers, changedByUserId, changedBySourceGuid); assertEquals(1, workQueueRepository.broadcastJsonValues.size()); JSONObject json = workQueueRepository.broadcastJsonValues.get(0); assertEquals("workspaceChange", json.getString("type")); assertEquals("mockUser2", json.getString("modifiedBy")); assertEquals(new JSONObject("{\"users\":[\"mockUser1\"]}").toString(), json.getJSONObject("permissions").toString()); assertEquals( new JSONObject("{\"editable\":false,\"users\":[],\"commentable\":false,\"workspaceId\":\"ws1\",\"sharedToUser\":false}").toString(), json.getJSONObject("data").toString() ); assertEquals("123-123-1234", json.getString("sourceGuid")); }
public Vertex getVertex(String workspaceId, User user) { String cacheKey = getUserWorkspaceVertexCacheKey(workspaceId, user); Vertex workspaceVertex = userWorkspaceVertexCache.getIfPresent(cacheKey); if (workspaceVertex != null) { return workspaceVertex; } Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations( user, UserRepository.VISIBILITY_STRING, VisalloVisibility.SUPER_USER_VISIBILITY_STRING, workspaceId ); workspaceVertex = getGraph().getVertex(workspaceId, authorizations); if (workspaceVertex != null) { userWorkspaceVertexCache.put(cacheKey, workspaceVertex); } return workspaceVertex; }