Merge branch 'master' into develop
# Conflicts: # backend/pom.xml # backend/src/main/java/ervu/client/okopf/EsnsiOkopfClient.java # backend/src/main/java/ervu/dao/okopf/OkopfDaoImpl.java # backend/src/main/java/ervu/service/scheduler/EsnsiOkopfSchedulerServiceImpl.java # backend/src/main/java/ru/micord/ervu/kafka/controller/ErvuKafkaController.java # backend/src/main/java/ru/micord/ervu/kafka/model/Data.java # backend/src/main/java/ru/micord/ervu/security/esia/service/EsiaAuthService.java # backend/src/main/java/ru/micord/ervu/security/esia/service/UlDataService.java # config.md # config/micord.env # config/standalone/dev/standalone.xml # distribution/pom.xml # frontend/pom.xml # pom.xml # resources/pom.xml
This commit is contained in:
commit
3f04f84c7f
7 changed files with 65 additions and 41 deletions
|
|
@ -9,6 +9,7 @@ import ervu_lkrp_ul.ervu_lkrp_ul.db_beans.public_.tables.records.OkopfRecordsRec
|
|||
import org.jooq.DSLContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static ervu_lkrp_ul.ervu_lkrp_ul.db_beans.public_.Tables.OKOPF_RECORDS;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
|||
import java.util.stream.Stream;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import ervu.client.okopf.EsnsiOkopfClient;
|
||||
import ervu.dao.okopf.OkopfDao;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package ru.micord.ervu.kafka.controller;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
|
@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.micord.ervu.exception.JsonParsingException;
|
||||
|
|
@ -17,8 +18,8 @@ import ru.micord.ervu.kafka.exception.ExcerptException;
|
|||
import ru.micord.ervu.kafka.model.Data;
|
||||
import ru.micord.ervu.kafka.model.ExcerptResponse;
|
||||
import ru.micord.ervu.kafka.service.ReplyingKafkaService;
|
||||
import ru.micord.ervu.security.webbpm.jwt.model.Token;
|
||||
import ru.micord.ervu.security.webbpm.jwt.service.JwtTokenService;
|
||||
import ru.micord.ervu.security.webbpm.jwt.UserIdsPair;
|
||||
import ru.micord.ervu.security.webbpm.jwt.util.SecurityUtil;
|
||||
|
||||
/**
|
||||
* @author Eduard Tihomirov
|
||||
|
|
@ -32,9 +33,6 @@ public class ErvuKafkaController {
|
|||
@Autowired
|
||||
private WebDavClient webDavClient;
|
||||
|
||||
@Autowired
|
||||
private JwtTokenService jwtTokenService;
|
||||
|
||||
@Value("${ervu.kafka.excerpt.reply.topic}")
|
||||
private String requestReplyTopic;
|
||||
|
||||
|
|
@ -45,20 +43,21 @@ public class ErvuKafkaController {
|
|||
private ObjectMapper objectMapper;
|
||||
|
||||
@RequestMapping(value = "/kafka/excerpt")
|
||||
public ResponseEntity<Resource> getExcerptFile(HttpServletRequest request) {
|
||||
public ResponseEntity<Resource> getExcerptFile(
|
||||
@RequestHeader("Client-Time-Zone") String clientTimeZone) {
|
||||
|
||||
try {
|
||||
String authToken = getAuthToken(request);
|
||||
Token token = jwtTokenService.getToken(authToken);
|
||||
String[] split = token.getUserAccountId().split(":");
|
||||
String prnOid = split[0];
|
||||
String ervuId = split[1];
|
||||
UserIdsPair userIdsPair = SecurityUtil.getUserIdsPair();
|
||||
Data data = new Data();
|
||||
data.setErvuOrgId(ervuId);
|
||||
data.setPrnOid(prnOid);
|
||||
String kafkaResponse = replyingKafkaService.sendMessageAndGetReply(requestTopic, requestReplyTopic,
|
||||
objectMapper.writeValueAsString(data)
|
||||
);
|
||||
data.setErvuId(userIdsPair.getErvuId());
|
||||
data.setPrnOid(userIdsPair.getEsiaUserId());
|
||||
String offset = ZonedDateTime.now(TimeZone.getTimeZone(clientTimeZone).toZoneId())
|
||||
.getOffset().getId();
|
||||
data.setTimeZone(offset);
|
||||
String kafkaResponse = replyingKafkaService.sendMessageAndGetReply(requestTopic,
|
||||
requestReplyTopic, objectMapper.writeValueAsString(data));
|
||||
ExcerptResponse excerptResponse = objectMapper.readValue(kafkaResponse, ExcerptResponse.class);
|
||||
|
||||
if (!excerptResponse.getSuccess()) {
|
||||
throw new ExcerptException("Error with getting excerpt url " + excerptResponse.getMessage());
|
||||
}
|
||||
|
|
@ -72,16 +71,4 @@ public class ErvuKafkaController {
|
|||
throw new JsonParsingException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getAuthToken(HttpServletRequest request) {
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if (cookies != null) {
|
||||
for (Cookie cookie : cookies) {
|
||||
if (cookie.getName().equals("auth_token")) {
|
||||
return cookie.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,16 +11,18 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Data implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@JsonProperty("orgId_ERVU")
|
||||
private String ervuOrgId;
|
||||
private String prnOid;
|
||||
|
||||
public String getErvuOrgId() {
|
||||
return ervuOrgId;
|
||||
@JsonProperty("orgId_ERVU")
|
||||
private String ervuId;
|
||||
private String prnOid;
|
||||
private String timeZone;
|
||||
|
||||
public String getErvuId() {
|
||||
return ervuId;
|
||||
}
|
||||
|
||||
public void setErvuOrgId(String ervuOrgId) {
|
||||
this.ervuOrgId = ervuOrgId;
|
||||
public void setErvuId(String ervuId) {
|
||||
this.ervuId = ervuId;
|
||||
}
|
||||
|
||||
public String getPrnOid() {
|
||||
|
|
@ -30,4 +32,12 @@ public class Data implements Serializable {
|
|||
public void setPrnOid(String prnOid) {
|
||||
this.prnOid = prnOid;
|
||||
}
|
||||
|
||||
public String getTimeZone() {
|
||||
return timeZone;
|
||||
}
|
||||
|
||||
public void setTimeZone(String timeZone) {
|
||||
this.timeZone = timeZone;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import ervu.service.okopf.OkopfService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.micord.ervu.security.esia.exception.EsiaException;
|
||||
import ru.micord.ervu.security.esia.model.*;
|
||||
import ru.micord.ervu.security.esia.token.EsiaTokensStore;
|
||||
|
|
@ -389,7 +390,7 @@ public class EsiaAuthService {
|
|||
requestReplyTopic, objectMapper.writeValueAsString(orgInfo)
|
||||
);
|
||||
ErvuOrgResponse ervuOrgResponse = objectMapper.readValue(kafkaResponse, ErvuOrgResponse.class);
|
||||
String ervuId = ervuOrgResponse.getData().getErvuOrgId();
|
||||
String ervuId = ervuOrgResponse.getData().getErvuId();
|
||||
|
||||
if (!StringUtils.hasText(ervuId)) {
|
||||
throw new EsiaException("No ervuId for prnOid = " + prnOid);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,13 @@ import ru.micord.ervu.security.esia.config.EsiaConfig;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.micord.ervu.security.esia.model.*;
|
||||
import ru.micord.ervu.security.esia.exception.EsiaException;
|
||||
import ru.micord.ervu.security.esia.model.BrhsModel;
|
||||
import ru.micord.ervu.security.esia.model.EmployeeModel;
|
||||
import ru.micord.ervu.security.esia.model.EsiaAccessToken;
|
||||
import ru.micord.ervu.security.esia.model.EsiaHeader;
|
||||
import ru.micord.ervu.security.esia.model.OrganizationModel;
|
||||
import ru.micord.ervu.security.esia.model.PersonModel;
|
||||
|
||||
/**
|
||||
* @author Eduard Tihomirov
|
||||
|
|
@ -166,6 +172,25 @@ public class UlDataServiceImpl implements UlDataService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EsiaHeader readHeader(String accessToken) {
|
||||
try {
|
||||
byte[] decodedBytes = Base64.getDecoder()
|
||||
.decode(
|
||||
accessToken.substring(0, accessToken.indexOf('.'))
|
||||
.replace('-', '+')
|
||||
.replace('_', '/'));
|
||||
String decodedString = new String(decodedBytes);
|
||||
EsiaHeader esiaHeader = objectMapper.readValue(decodedString,
|
||||
EsiaHeader.class
|
||||
);
|
||||
return esiaHeader;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new EsiaException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private OrganizationModel getOrgModel(String orgOid, String accessToken) {
|
||||
try {
|
||||
String url = esiaConfig.getEsiaBaseUri() + "rs/orgs/" + orgOid;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef} from "@angular/core";
|
||||
import {AbstractButton, MessagesService, NotNull, ObjectRef} from "@webbpm/base-package";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {HttpClient, HttpHeaders} from "@angular/common/http";
|
||||
import {InMemoryStaticGrid} from "../grid/InMemoryStaticGrid";
|
||||
import {Subscription} from "rxjs";
|
||||
|
||||
|
|
@ -60,6 +60,7 @@ export class ErvuDownloadFileButton extends AbstractButton {
|
|||
public doClickActions(): Promise<any> {
|
||||
return this.httpClient.get('kafka/excerpt', {
|
||||
responseType: 'blob',
|
||||
headers: new HttpHeaders({'Client-Time-Zone' : Intl.DateTimeFormat().resolvedOptions().timeZone}),
|
||||
observe: 'response'
|
||||
}).toPromise().then((response) => {
|
||||
if (response.status == 204) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue