Skip to content

Commit

Permalink
improved catches
Browse files Browse the repository at this point in the history
  • Loading branch information
melistik committed Feb 12, 2019
1 parent b93603a commit 4863787
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestClientException;

import java.util.Collection;

Expand All @@ -32,10 +33,12 @@ public Authentication authenticate(Authentication authentication) throws Authent
return new CommonsAuthenticationToken(authorities, login.getUser(), new JwtTokenStore(baseAuthApiUrl, login.getJwtTokenBundle()));
} catch (HttpClientErrorException e) {
if (e.getStatusCode().equals(HttpStatus.FORBIDDEN)) {
throw new BadCredentialsException("wrong username/password");
throw new BadCredentialsException("wrong username/password", e);
} else {
throw new InternalAuthenticationServiceException("got error http error with status: " + e.getRawStatusCode());
throw new InternalAuthenticationServiceException("got http error with status: " + e.getRawStatusCode(), e);
}
} catch (RestClientException e) {
throw new InternalAuthenticationServiceException("service is not available?", e);
}
}

Expand Down

0 comments on commit 4863787

Please sign in to comment.