SUPPORT-8702: fix notification display
This commit is contained in:
parent
b1d8ab0381
commit
26fad332b0
6 changed files with 43 additions and 25 deletions
|
|
@ -0,0 +1,18 @@
|
|||
package ru.micord.ervu.kafka.exception;
|
||||
|
||||
import org.springframework.context.support.MessageSourceAccessor;
|
||||
|
||||
import ru.cg.webbpm.modules.core.runtime.api.LocalizedException;
|
||||
import ru.cg.webbpm.modules.core.runtime.api.MessageBundleUtils;
|
||||
|
||||
/**
|
||||
* @author Emir Suleimanov
|
||||
*/
|
||||
public class KafkaMessageReplyTimeoutException extends LocalizedException {
|
||||
private static final MessageSourceAccessor MESSAGE_SOURCE = MessageBundleUtils.createAccessor("messages/common_errors_messages");
|
||||
private static final String KAFKA_REPLY_TIMEOUT = "kafka_reply_timeout";
|
||||
|
||||
public KafkaMessageReplyTimeoutException(Throwable cause) {
|
||||
super(KAFKA_REPLY_TIMEOUT, MESSAGE_SOURCE, cause);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.kafka.requestreply.ReplyingKafkaTemplate;
|
||||
import org.springframework.kafka.requestreply.RequestReplyFuture;
|
||||
import ru.micord.ervu.kafka.exception.KafkaMessageReplyTimeoutException;
|
||||
import ru.micord.ervu.kafka.service.ReplyingKafkaService;
|
||||
|
||||
/**
|
||||
|
|
@ -35,7 +36,7 @@ public abstract class BaseReplyingKafkaService<T, V> implements ReplyingKafkaSer
|
|||
catch (InterruptedException | ExecutionException e) {
|
||||
LOGGER.error("Thread {} - KafkaSendMessageAndGetReply: {} ms",
|
||||
Thread.currentThread().getId(), System.currentTimeMillis() - startTime);
|
||||
throw new RuntimeException("Failed to get kafka response", e);
|
||||
throw new KafkaMessageReplyTimeoutException(e);
|
||||
}
|
||||
}
|
||||
protected abstract ReplyingKafkaTemplate<String, T, V> getTemplate();
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ public class EsiaController {
|
|||
}
|
||||
|
||||
@GetMapping(value = "/esia/auth")
|
||||
public ResponseEntity<?> esiaAuth(@RequestParam(value = "code", required = false) String code,
|
||||
public void esiaAuth(@RequestParam(value = "code", required = false) String code,
|
||||
@RequestParam(value = "error", required = false) String error, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
return esiaAuthService.getEsiaTokensByCode(code, error, request, response);
|
||||
esiaAuthService.authEsiaTokensByCode(code, error, request, response);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/esia/refresh")
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.context.support.MessageSourceAccessor;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import ru.micord.ervu.audit.constants.AuditConstants;
|
||||
import ru.micord.ervu.audit.service.AuditService;
|
||||
|
|
@ -52,6 +51,7 @@ import ru.micord.ervu.security.webbpm.jwt.service.JwtTokenService;
|
|||
import ru.micord.ervu.security.webbpm.jwt.model.Token;
|
||||
|
||||
import static ru.micord.ervu.security.webbpm.jwt.util.SecurityUtil.getCurrentUserEsiaId;
|
||||
import ru.cg.webbpm.modules.core.runtime.api.MessageBundleUtils;
|
||||
|
||||
/**
|
||||
* @author Eduard Tihomirov
|
||||
|
|
@ -59,7 +59,8 @@ import static ru.micord.ervu.security.webbpm.jwt.util.SecurityUtil.getCurrentUse
|
|||
@Service
|
||||
public class EsiaAuthService {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
private static final MessageSourceAccessor MESSAGE_SOURCE = MessageBundleUtils.createAccessor(
|
||||
"messages/common_errors_messages");
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
|
|
@ -156,13 +157,10 @@ public class EsiaAuthService {
|
|||
return uriBuilder.toString();
|
||||
}
|
||||
|
||||
public ResponseEntity<?> getEsiaTokensByCode(String esiaAuthCode, String error,
|
||||
public void authEsiaTokensByCode(String esiaAuthCode, String error,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
if (error != null && !error.equals("null")) {
|
||||
return new ResponseEntity<>(
|
||||
"Произошла неизвестная ошибка. Обратитесь к системному администратору",
|
||||
HttpStatus.FORBIDDEN
|
||||
);
|
||||
throw new EsiaException(error);
|
||||
}
|
||||
String esiaAccessTokenStr = null;
|
||||
String prnOid = null;
|
||||
|
|
@ -244,29 +242,26 @@ public class EsiaAuthService {
|
|||
Thread.currentThread().getId(), signSecret, requestAccessToken, verifySecret);
|
||||
}
|
||||
PersonModel personModel = null;
|
||||
String ervuId = null, status = null;
|
||||
try {
|
||||
personModel = personalDataService.getPersonModel(esiaAccessTokenStr);
|
||||
Response ervuIdResponse = getErvuIdResponse(personModel);
|
||||
createTokenAndAddCookie(response, prnOid, ervuIdResponse.getErvuId(), expiresIn);
|
||||
auditService.processAuthEvent(
|
||||
request, personModel, AuditConstants.SUCCESS_STATUS, AuditConstants.LOGIN_EVENT_TYPE
|
||||
);
|
||||
return ResponseEntity.ok("Authentication successful");
|
||||
ervuId = ervuIdResponse.getErvuId();
|
||||
status = AuditConstants.SUCCESS_STATUS;
|
||||
}
|
||||
catch (Exception e) {
|
||||
createTokenAndAddCookie(response, prnOid, null, expiresIn);
|
||||
String messageId = getMessageId(e);
|
||||
String messageWithId = String.format("[%s] %s", messageId, e.getMessage());
|
||||
status = AuditConstants.FAILURE_STATUS;
|
||||
if (e instanceof EsiaException || e instanceof JsonProcessingException) {
|
||||
throw new EsiaException(e);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (personModel != null) {
|
||||
auditService.processAuthEvent(
|
||||
request, personModel, AuditConstants.FAILURE_STATUS, AuditConstants.LOGIN_EVENT_TYPE
|
||||
request, personModel, status, AuditConstants.LOGIN_EVENT_TYPE
|
||||
);
|
||||
}
|
||||
LOGGER.error(messageWithId, e);
|
||||
return new ResponseEntity<>(
|
||||
"Произошла ошибка " + messageId + ". Обратитесь к системному администратору",
|
||||
HttpStatus.FORBIDDEN
|
||||
);
|
||||
createTokenAndAddCookie(response, prnOid, ervuId, expiresIn);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
kafka_reply_timeout=Превышено время ожидания ответа от сервера. Попробуйте повторить запрос позже или обратитесь к системному администратору
|
||||
access_denied=Доступ запрещен. Пользователь должен быть включен в группу "Сотрудник, ответственный за военно-учетную работу" в ЕСИА
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
kafka_reply_timeout=Превышено время ожидания ответа от сервера. Попробуйте повторить запрос позже или обратитесь к системному администратору
|
||||
access_denied=Доступ запрещен. Пользователь должен быть включен в группу "Сотрудник, ответственный за военно-учетную работу" в ЕСИА
|
||||
Loading…
Add table
Add a link
Reference in a new issue