LoginContext loginContext = token.getLoginContext(); boolean debug = this.log.isDebugEnabled(); if (loginContext != null) {
LoginContext loginContext = token.getLoginContext(); boolean debug = this.log.isDebugEnabled(); if (loginContext != null) {
@Test public void logout() throws Exception { SessionDestroyedEvent event = mock(SessionDestroyedEvent.class); SecurityContext securityContext = mock(SecurityContext.class); JaasAuthenticationToken token = mock(JaasAuthenticationToken.class); LoginContext context = mock(LoginContext.class); when(event.getSecurityContexts()).thenReturn(Arrays.asList(securityContext)); when(securityContext.getAuthentication()).thenReturn(token); when(token.getLoginContext()).thenReturn(context); provider.onApplicationEvent(event); verify(event).getSecurityContexts(); verify(securityContext).getAuthentication(); verify(token).getLoginContext(); verify(context).logout(); verifyNoMoreInteractions(event, securityContext, token, context); }
@Test public void logoutNullLoginContext() throws Exception { SessionDestroyedEvent event = mock(SessionDestroyedEvent.class); SecurityContext securityContext = mock(SecurityContext.class); JaasAuthenticationToken token = mock(JaasAuthenticationToken.class); when(event.getSecurityContexts()).thenReturn(Arrays.asList(securityContext)); when(securityContext.getAuthentication()).thenReturn(token); provider.onApplicationEvent(event); verify(event).getSecurityContexts(); verify(securityContext).getAuthentication(); verify(token).getLoginContext(); verifyNoMoreInteractions(event, securityContext, token); }
@Test public void logoutLoginException() throws Exception { SessionDestroyedEvent event = mock(SessionDestroyedEvent.class); SecurityContext securityContext = mock(SecurityContext.class); JaasAuthenticationToken token = mock(JaasAuthenticationToken.class); LoginContext context = mock(LoginContext.class); LoginException loginException = new LoginException("Failed Login"); when(event.getSecurityContexts()).thenReturn(Arrays.asList(securityContext)); when(securityContext.getAuthentication()).thenReturn(token); when(token.getLoginContext()).thenReturn(context); doThrow(loginException).when(context).logout(); provider.onApplicationEvent(event); verify(event).getSecurityContexts(); verify(securityContext).getAuthentication(); verify(token).getLoginContext(); verify(context).logout(); verify(log).warn(anyString(), eq(loginException)); verifyNoMoreInteractions(event, securityContext, token, context); }
@Test // http@jaas-api-provision public void configureWhenJaasApiIntegrationFilterAddedThenJaasSubjectObtained() throws Exception { LoginContext loginContext = mock(LoginContext.class); when(loginContext.getSubject()).thenReturn(new Subject()); JaasAuthenticationToken authenticationToken = mock(JaasAuthenticationToken.class); when(authenticationToken.isAuthenticated()).thenReturn(true); when(authenticationToken.getLoginContext()).thenReturn(loginContext); this.spring.register(JaasApiProvisionConfig.class).autowire(); this.mockMvc.perform(get("/").with(authentication(authenticationToken))); verify(loginContext, times(1)).getSubject(); }
LoginContext loginContext = token.getLoginContext(); if (loginContext == null) { return null;
LoginContext loginContext = token.getLoginContext(); boolean debug = log.isDebugEnabled(); if (loginContext != null) {
LoginContext loginContext = token.getLoginContext(); boolean debug = this.log.isDebugEnabled(); if (loginContext != null) {