Spring-security-oauth2 настраиваемая обработка ошибок - PullRequest
0 голосов
/ 04 августа 2020
• 1000 служба учетных данных клиента:
@service
public class MongoClientDetailsService implements ClientDetailsService {

private static final Logger logger = LogManager.getLogger(MongoClientDetailsService.class);

@Autowired
private IClientCredentialsRepository clientCredentialsRepo;

public MongoClientDetailsService() {
}

@Override
public ClientDetails loadClientByClientId(String clientId)
        throws ClientRegistrationException {
    try {
        Optional<ClientCredentials> retVal = clientCredentialsRepo.findByClientId(clientId);
        if (!retVal.isPresent()) {
            logger.error(new LocalizedMessage(ResourceBundle.getBundle(Consts.LOGGING_MSG),
                    "client-not-found-in-db", clientId));
            throw new InvalidGrantException("user is not present.");
        }
        return createClient();
    } catch (MongoException e) {
        logger.error(new LocalizedMessage(ResourceBundle.getBundle(Consts.LOGGING_MSG),
                "exception-on-load-client", clientId, e.fillInStackTrace()));
        throw new ClientRegistrationException("Error on loading client");
    }
}
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...