List of usage examples for org.springframework.security.authentication InternalAuthenticationServiceException InternalAuthenticationServiceException
public InternalAuthenticationServiceException(String message)
From source file:eu.freme.broker.security.ManagementEndpointAuthenticationFilter.java
private Authentication tryToAuthenticate(Authentication requestAuthentication) { Authentication responseAuthentication = authenticationManager.authenticate(requestAuthentication); if (responseAuthentication == null || !responseAuthentication.isAuthenticated()) { throw new InternalAuthenticationServiceException( "Unable to authenticate Backend Admin for provided credentials"); }/* w w w. j a va2 s . com*/ logger.debug("Backend Admin successfully authenticated"); return responseAuthentication; }
From source file:com.devicehive.auth.rest.HttpAuthenticationFilter.java
private void tryAuthenticate(Authentication requestAuth) { Authentication authentication = authenticationManager.authenticate(requestAuth); if (authentication == null || !authentication.isAuthenticated()) { throw new InternalAuthenticationServiceException( "Unable to authenticate user with provided credetials"); }/*w ww . j a va 2 s. c om*/ logger.debug("Successfully authenticated"); SecurityContextHolder.getContext().setAuthentication(authentication); }
From source file:org.verinice.rest.security.VeriniceAuthenticationProvider.java
@Override protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { UserDetails loadedUser;//from w w w . j a v a2 s . c o m try { loadedUser = this.getUserDetailsService().loadUserByUsername(username); } catch (UsernameNotFoundException notFound) { LOG.warn("user " + authentication + " not found"); throw notFound; } if (loadedUser == null) { throw new InternalAuthenticationServiceException( "UserDetailsService returned null, which is an interface contract violation"); } return loadedUser; }
From source file:eu.freme.broker.security.AuthenticationFilter.java
private Authentication tryToAuthenticate(Authentication requestAuthentication) { Authentication responseAuthentication = authenticationManager.authenticate(requestAuthentication); if (responseAuthentication == null || !responseAuthentication.isAuthenticated()) { throw new InternalAuthenticationServiceException( "Unable to authenticate Domain User for provided credentials"); }/*from w ww . j a v a 2 s . co m*/ logger.debug("User successfully authenticated"); return responseAuthentication; }
From source file:org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilterTests.java
/** * SEC-1919/*from w ww .j a v a 2 s . co m*/ */ @Test public void loginErrorWithInternAuthenticationServiceExceptionLogsError() throws Exception { MockHttpServletRequest request = createMockAuthenticationRequest(); MockFilterChain chain = new MockFilterChain(true); MockHttpServletResponse response = new MockHttpServletResponse(); Log logger = mock(Log.class); MockAuthenticationFilter filter = new MockAuthenticationFilter(false); ReflectionTestUtils.setField(filter, "logger", logger); filter.exceptionToThrow = new InternalAuthenticationServiceException("Mock requested to do so"); successHandler.setDefaultTargetUrl("https://monkeymachine.co.uk/"); filter.setAuthenticationSuccessHandler(successHandler); filter.doFilter(request, response, chain); verify(logger).error(anyString(), eq(filter.exceptionToThrow)); assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_UNAUTHORIZED); }