use of org.springframework.security.core.AuthenticationException in project spring-security by spring-projects.
the class HttpStatusServerEntryPointTests method setup.
@BeforeEach
public void setup() {
this.request = MockServerHttpRequest.get("/").build();
this.exchange = MockServerWebExchange.from(this.request);
this.authException = new AuthenticationException("") {
};
this.entryPoint = new HttpStatusServerEntryPoint(HttpStatus.UNAUTHORIZED);
}
use of org.springframework.security.core.AuthenticationException in project spring-security by spring-projects.
the class AuthenticationEventTests method testRejectsNullAuthentication.
@Test
public void testRejectsNullAuthentication() {
AuthenticationException exception = new DisabledException("TEST");
assertThatIllegalArgumentException().isThrownBy(() -> new AuthenticationFailureDisabledEvent(null, exception));
}
use of org.springframework.security.core.AuthenticationException in project spring-security by spring-projects.
the class AuthenticationFilter method doFilterInternal.
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
if (!this.requestMatcher.matches(request)) {
if (logger.isTraceEnabled()) {
logger.trace("Did not match request to " + this.requestMatcher);
}
filterChain.doFilter(request, response);
return;
}
try {
Authentication authenticationResult = attemptAuthentication(request, response);
if (authenticationResult == null) {
filterChain.doFilter(request, response);
return;
}
HttpSession session = request.getSession(false);
if (session != null) {
request.changeSessionId();
}
successfulAuthentication(request, response, filterChain, authenticationResult);
} catch (AuthenticationException ex) {
unsuccessfulAuthentication(request, response, ex);
}
}
use of org.springframework.security.core.AuthenticationException in project dhis2-core by dhis2.
the class DhisApiTokenAuthenticationEntryPoint method commence.
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
_commence(response);
HandlerExceptionResolver handlerExceptionResolver;
try {
handlerExceptionResolver = (HandlerExceptionResolver) applicationContext.getBean("handlerExceptionResolver");
handlerExceptionResolver.resolveException(request, response, null, authException);
} catch (Exception e) {
log.error("Could not find a HandlerExceptionResolver bean!");
}
}
use of org.springframework.security.core.AuthenticationException in project midpoint by Evolveum.
the class PageRegistrationConfirmation method init.
private void init(final PageParameters pageParameters) {
PageParameters params = pageParameters;
if (params == null) {
params = getPageParameters();
}
OperationResult result = new OperationResult(OPERATION_FINISH_REGISTRATION);
if (params == null) {
LOGGER.error("Confirmation link is not valid. No credentials provided in it");
String msg = createStringResource("PageSelfRegistration.invalid.registration.link").getString();
getSession().error(createStringResource(msg));
result.recordFatalError(msg);
initLayout(result);
return;
}
StringValue userNameValue = params.get(SchemaConstants.USER_ID);
Validate.notEmpty(userNameValue.toString());
StringValue tokenValue = params.get(SchemaConstants.TOKEN);
Validate.notEmpty(tokenValue.toString());
try {
UserType user = checkUserCredentials(userNameValue.toString(), tokenValue.toString(), result);
PrismObject<UserType> administrator = getAdministratorPrivileged(result);
assignDefaultRoles(user.getOid(), administrator, result);
result.computeStatus();
if (result.getStatus() == OperationResultStatus.FATAL_ERROR) {
LOGGER.error("Failed to assign default roles, {}", result.getMessage());
} else {
NonceType nonceClone = user.getCredentials().getNonce().clone();
removeNonceAndSetLifecycleState(user.getOid(), nonceClone, administrator, result);
assignAdditionalRoleIfPresent(user.getOid(), nonceClone, administrator, result);
result.computeStatus();
}
initLayout(result);
} catch (CommonException | AuthenticationException e) {
result.computeStatus();
initLayout(result);
}
}
Aggregations