SUPPORT-8830 remove sensitive data from args 3.2
This commit is contained in:
parent
2d2a07bb0c
commit
84683a4e2d
4 changed files with 72 additions and 57 deletions
|
|
@ -1,18 +1,11 @@
|
|||
package ru.micord.ervu.controller;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import org.apache.kafka.common.utils.Bytes;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import ru.micord.ervu.converter.SummonsResponseDataConverter;
|
||||
import ru.micord.ervu.dto.SubpoenaRequestDto;
|
||||
import ru.micord.ervu.dto.SubpoenaResponseDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import proto.ervu.rp.summons.SummonsResponseData;
|
||||
import ru.micord.ervu.kafka.service.ReplyingKafkaService;
|
||||
import ru.micord.ervu.security.webbpm.jwt.util.SecurityUtil;
|
||||
import ru.micord.ervu.dto.SubpoenaResponseDto;
|
||||
import ru.micord.ervu.service.SubpoenaService;
|
||||
|
||||
/**
|
||||
* @author gulnaz
|
||||
|
|
@ -20,41 +13,15 @@ import ru.micord.ervu.security.webbpm.jwt.util.SecurityUtil;
|
|||
@RestController
|
||||
public class ErvuDataController {
|
||||
|
||||
private final ReplyingKafkaService<Object, Bytes> replyingKafkaService;
|
||||
private final SummonsResponseDataConverter converter;
|
||||
private final SubpoenaService subpoenaService;
|
||||
|
||||
@Value("${ervu.kafka.recruit.request.topic}")
|
||||
private String recruitRequestTopic;
|
||||
@Value("${ervu.kafka.recruit.reply.topic}")
|
||||
private String recruitReplyTopic;
|
||||
|
||||
public ErvuDataController(
|
||||
@Qualifier("recruit") ReplyingKafkaService<Object, Bytes> replyingKafkaService,
|
||||
SummonsResponseDataConverter converter) {
|
||||
this.replyingKafkaService = replyingKafkaService;
|
||||
this.converter = converter;
|
||||
@Autowired
|
||||
public ErvuDataController(SubpoenaService subpoenaService) {
|
||||
this.subpoenaService = subpoenaService;
|
||||
}
|
||||
|
||||
@GetMapping(
|
||||
value = "/recruit",
|
||||
produces = MediaType.APPLICATION_JSON_VALUE
|
||||
)
|
||||
@GetMapping(value = "/recruit", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public SubpoenaResponseDto getData() {
|
||||
String ervuId = SecurityUtil.getErvuId();
|
||||
|
||||
if (ervuId == null) {
|
||||
return new SubpoenaResponseDto.Builder().build();
|
||||
}
|
||||
SubpoenaRequestDto subpoenaRequestDto = new SubpoenaRequestDto(ervuId);
|
||||
byte[] reply = replyingKafkaService.sendMessageAndGetReply(recruitRequestTopic,
|
||||
recruitReplyTopic, subpoenaRequestDto).get();
|
||||
|
||||
try {
|
||||
SummonsResponseData responseData = SummonsResponseData.parseFrom(reply);
|
||||
return converter.convert(responseData);
|
||||
}
|
||||
catch (InvalidProtocolBufferException e) {
|
||||
throw new RuntimeException("Failed to parse data", e);
|
||||
}
|
||||
return subpoenaService.getSubpoenaData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
package ru.micord.ervu.service;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import org.apache.kafka.common.utils.Bytes;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import proto.ervu.rp.summons.SummonsResponseData;
|
||||
import ru.micord.ervu.converter.SummonsResponseDataConverter;
|
||||
import ru.micord.ervu.dto.SubpoenaRequestDto;
|
||||
import ru.micord.ervu.dto.SubpoenaResponseDto;
|
||||
import ru.micord.ervu.kafka.service.ReplyingKafkaService;
|
||||
import ru.micord.ervu.security.webbpm.jwt.util.SecurityUtil;
|
||||
|
||||
@Service
|
||||
public class SubpoenaService {
|
||||
|
||||
private final ReplyingKafkaService<Object, Bytes> replyingKafkaService;
|
||||
private final SummonsResponseDataConverter converter;
|
||||
|
||||
@Value("${ervu.kafka.recruit.request.topic}")
|
||||
private String recruitRequestTopic;
|
||||
@Value("${ervu.kafka.recruit.reply.topic}")
|
||||
private String recruitReplyTopic;
|
||||
|
||||
public SubpoenaService(
|
||||
@Qualifier("recruit") ReplyingKafkaService<Object, Bytes> replyingKafkaService,
|
||||
SummonsResponseDataConverter converter) {
|
||||
this.replyingKafkaService = replyingKafkaService;
|
||||
this.converter = converter;
|
||||
}
|
||||
|
||||
public SubpoenaResponseDto getSubpoenaData() {
|
||||
String ervuId = SecurityUtil.getErvuId();
|
||||
|
||||
if (ervuId == null) {
|
||||
return new SubpoenaResponseDto.Builder().build();
|
||||
}
|
||||
SubpoenaRequestDto subpoenaRequestDto = new SubpoenaRequestDto(ervuId);
|
||||
byte[] reply = replyingKafkaService.sendMessageAndGetReply(recruitRequestTopic,
|
||||
recruitReplyTopic, subpoenaRequestDto).get();
|
||||
|
||||
try {
|
||||
SummonsResponseData responseData = SummonsResponseData.parseFrom(reply);
|
||||
return converter.convert(responseData);
|
||||
}
|
||||
catch (InvalidProtocolBufferException e) {
|
||||
throw new RuntimeException("Failed to parse data", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,9 @@ package ru.micord.ervu.service.rpc;
|
|||
import java.util.List;
|
||||
|
||||
import model.FieldData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import ru.micord.ervu.dto.SubpoenaResponseDto;
|
||||
import ru.micord.ervu.service.SubpoenaService;
|
||||
import service.container.FormService;
|
||||
|
||||
import ru.cg.webbpm.modules.standard_annotations.validation.NotNull;
|
||||
|
|
@ -19,8 +22,13 @@ public class LoadFormRpcService extends Behavior {
|
|||
@NotNull
|
||||
public FormService formService;
|
||||
|
||||
//todo: Remove this shit
|
||||
@Autowired
|
||||
public SubpoenaService subpoenaService;
|
||||
|
||||
@RpcCall
|
||||
public List<FieldData> loadData(Object dto) {
|
||||
return formService.loadData(dto);
|
||||
public List<FieldData> loadData() {
|
||||
SubpoenaResponseDto subpoenaData = subpoenaService.getSubpoenaData();
|
||||
return formService.loadData(subpoenaData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {Form} from "@webbpm/base-package";
|
||||
import {ChangeDetectionStrategy, Component} from "@angular/core";
|
||||
import {ErvuDataService} from "../../../modules/app/service/ervu-data.service";
|
||||
import {Subscription} from "rxjs";
|
||||
import {LoadFormRpcService} from "../../../generated/ru/micord/ervu/service/rpc/LoadFormRpcService";
|
||||
|
||||
@Component({
|
||||
|
|
@ -14,25 +13,16 @@ export class LoadForm extends Form {
|
|||
|
||||
private formRpcService: LoadFormRpcService;
|
||||
private ervuDataService: ErvuDataService;
|
||||
private subscription: Subscription;
|
||||
|
||||
private valuesData: string;
|
||||
|
||||
initialize() {
|
||||
super.initialize();
|
||||
this.formRpcService = this.getScript(LoadFormRpcService);
|
||||
this.ervuDataService = this.injector.get(ErvuDataService);
|
||||
this.subscription = this.ervuDataService.message.subscribe(value => {
|
||||
if (value) {
|
||||
this.valuesData = value;
|
||||
this.loadData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadData(): Promise<any> {
|
||||
return this.formRpcService
|
||||
.loadData(this.valuesData)
|
||||
.loadData()
|
||||
.then(fieldDataList => this.setData(fieldDataList))
|
||||
.catch(reason => {
|
||||
throw new Error(reason);
|
||||
|
|
@ -49,6 +39,5 @@ export class LoadForm extends Form {
|
|||
|
||||
ngOnDestroy() {
|
||||
super.ngOnDestroy();
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue