@Override public User getUser() { return authService.getUser(); } }
@Produces @RequestScoped public User getIdentity() { try { return authenticationService.getUser(); } catch (final IllegalStateException ex) { return new UserImpl("system"); } } }
@Override @Produces @Default @ApplicationScoped public SessionInfo getSessionInfo(AuthenticationService authenticationService) { return new SessionInfoImpl("dummy-id", authenticationService.getUser()); }
public Path buildPath(final String serviceType, final String relativePath) { return userServicesBackend.buildPath(authService.getUser().getIdentifier(), serviceType, relativePath); } }
public Path buildPath(final String serviceType) { return userServicesBackend.buildPath(authService.getUser().getIdentifier(), serviceType); }
/** * Set the {@link KeycloakSecurityContext} used to generate the logged in Keycloak {@link User}. * * @param keycloakSecurityContext The context used to generate the logged in Keycloak {@link User}. */ void setSecurityContext(final KeycloakSecurityContext keycloakSecurityContext) { if (wrappedAuthService.isLoggedIn() && keycloakSecurityContext != null) { throw new AlreadyLoggedInException("Logged in as " + wrappedAuthService.getUser()); } this.keycloakSecurityContext = keycloakSecurityContext; keycloakUser = null; } }
private User getUser() { try { return authenticationService.getUser(); } catch (final IllegalStateException ex) { return new UserImpl("system", asList(new RoleImpl("admin"))); } } }
private User getUser() { try { return authenticationService.getUser(); } catch (final IllegalStateException ex) { return new UserImpl("system", asList(new RoleImpl("admin"))); } } }
@Override public User getUser() { if (keycloakIsLoggedIn()) { return getKeycloakUser(); } else if (wrappedAuthService.isLoggedIn()) { return wrappedAuthService.getUser(); } else { return User.ANONYMOUS; } }
private SessionInfo getSessionInfo( final String sessionId ) { return new SafeSessionInfo( new SessionInfoImpl( sessionId, authenticationService.getUser() ) ); }
private SessionInfo getSessionInfo( final String sessionId ) { return new SafeSessionInfo( new SessionInfoImpl( sessionId, authenticationService.getUser() ) ); }
@Before public void setup() throws IOException { when( authenticationService.getUser() ).thenReturn( user ); when( user.getIdentifier() ).thenReturn( "user" ); when( path.toURI() ).thenReturn( "default://p0/src/main/resources/dtable.xls" ); when( inputstream.read( anyObject() ) ).thenReturn( -1 ); when( ioService.newOutputStream( any( org.uberfire.java.nio.file.Path.class ), commentedOptionArgumentCaptor.capture() ) ).thenReturn( outputStream ); }
@Before public void setup() throws IOException { when( authenticationService.getUser() ).thenReturn( user ); when( user.getIdentifier() ).thenReturn( "user" ); when( path.toURI() ).thenReturn( "default://p0/src/main/resources/dtable.xls" ); when( inputstream.read( anyObject() ) ).thenReturn( -1 ); when( ioService.newOutputStream( any( org.uberfire.java.nio.file.Path.class ), commentedOptionArgumentCaptor.capture() ) ).thenReturn( outputStream ); }
@Before public void setup() { when(authService.getUser()).thenThrow(new AssertionError("Should not call authentication service")); when(threadMessage.getResource(QueueSession.class, "Session")).thenReturn(threadQueueSession); when(threadQueueSession.getSessionId()).thenReturn(sessionUser.getIdentifier()); RpcContext.set(null); }
@Before public void setup() { when(authService.getUser()).thenThrow(new AssertionError("Should not call authentication service")); when(threadMessage.getResource(QueueSession.class, "Session")).thenReturn(threadQueueSession); when(threadQueueSession.getSessionId()).thenReturn(sessionUser.getIdentifier()); RpcContext.set(null); }
@Test public void returnAuthenticatedUserInSessionThread() { when(userInstance.isAmbiguous()).thenReturn(false); when(userInstance.isUnsatisfied()).thenReturn(false); when(userInstance.get()).thenReturn(defaultUser); reset(authService); when(authService.getUser()).thenReturn(sessionUser); RpcContext.set(threadMessage); SessionInfo sessionInfo = factory.getSessionInfo(authService); assertSame(sessionUser, sessionInfo.getIdentity()); }
@Test public void returnAuthenticatedUserInSessionThread() { when(userInstance.isAmbiguous()).thenReturn(false); when(userInstance.isUnsatisfied()).thenReturn(false); when(userInstance.get()).thenReturn(defaultUser); reset(authService); when(authService.getUser()).thenReturn(sessionUser); RpcContext.set(threadMessage); SessionInfo sessionInfo = factory.getSessionInfo(authService); assertSame(sessionUser, sessionInfo.getIdentity()); }
@Test public void testExistingSessionNotInvalidated() throws Exception { SessionProvider sessionProvider = new SessionProvider(httpSession); when(authenticationService.getUser()).thenReturn(new UserImpl("testUser")); when(request.getSession(anyBoolean())).then((InvocationOnMock invocationOnMock) -> sessionProvider.provideSession()); final BasicAuthSecurityFilter filter = new BasicAuthSecurityFilter(); filter.authenticationService = authenticationService; filter.doFilter(request, response, chain); verify(httpSession, never()).invalidate(); }
@Test public void testExistingSessionNotInvalidated() throws Exception { SessionProvider sessionProvider = new SessionProvider(httpSession); when(authenticationService.getUser()).thenReturn(new UserImpl("testUser")); when(request.getSession(anyBoolean())).then((InvocationOnMock invocationOnMock) -> sessionProvider.provideSession()); final BasicAuthSecurityFilter filter = new BasicAuthSecurityFilter(); filter.authenticationService = authenticationService; filter.doFilter(request, response, chain); verify(httpSession, never()).invalidate(); }
@Test public void testIndependentSessionInvalidated() throws Exception { SessionProvider sessionProvider = new SessionProvider(httpSession, 1); when(authenticationService.getUser()).thenReturn(new UserImpl("testUser")); when(request.getSession(anyBoolean())).then((InvocationOnMock invocationOnMock) -> sessionProvider.provideSession()); final BasicAuthSecurityFilter filter = new BasicAuthSecurityFilter(); filter.authenticationService = authenticationService; filter.doFilter(request, response, chain); verify(httpSession, times(1)).invalidate(); }