SUPPORT-9002: fixes
This commit is contained in:
parent
a5d3f55ff2
commit
339c3dc76d
5 changed files with 22 additions and 14 deletions
|
|
@ -2,22 +2,22 @@ package ru.micord.ervu.account_applications.component.field.dataconvert;
|
|||
|
||||
import component.field.dataconvert.DataConverter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import ru.micord.ervu.account_applications.security.service.AESEncryptionService;
|
||||
import ru.micord.ervu.account_applications.security.service.EncryptionService;
|
||||
|
||||
/**
|
||||
* @author Adel Kalimullin
|
||||
*/
|
||||
public class PasswordDecoder implements DataConverter<String, String> {
|
||||
private final AESEncryptionService aesEncryptionService;
|
||||
public class PasswordConverter implements DataConverter<String, String> {
|
||||
private final EncryptionService encryptionService;
|
||||
|
||||
@Autowired
|
||||
public PasswordDecoder(AESEncryptionService aesEncryptionService) {
|
||||
this.aesEncryptionService = aesEncryptionService;
|
||||
public PasswordConverter(EncryptionService encryptionService) {
|
||||
this.encryptionService = encryptionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertValueForSave(String s) {
|
||||
return aesEncryptionService.decrypt(s);
|
||||
return encryptionService.decrypt(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package ru.micord.ervu.account_applications.security.service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Base64;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.crypto.Cipher;
|
||||
|
|
@ -13,15 +15,21 @@ import ru.micord.ervu.account_applications.security.exception.EncryptionExceptio
|
|||
* @author Adel Kalimullin
|
||||
*/
|
||||
@Component
|
||||
public class AESEncryptionService {
|
||||
public class EncryptionService {
|
||||
private static final String ALGORITHM = "AES";
|
||||
@Value("${ervu.secret_key}")
|
||||
@Value("${ervu.pwd.sign.secret_key}")
|
||||
private String secretKey;
|
||||
private SecretKeySpec secretKeySpec;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
secretKeySpec = new SecretKeySpec(secretKey.getBytes(), ALGORITHM);
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] hash = digest.digest(secretKey.getBytes(StandardCharsets.UTF_8));
|
||||
secretKeySpec = new SecretKeySpec(hash, ALGORITHM);
|
||||
} catch (Exception e) {
|
||||
throw new EncryptionException("Ошибка инициализации ключа", e);
|
||||
}
|
||||
}
|
||||
|
||||
public String encrypt(String data) {
|
||||
|
|
@ -16,8 +16,8 @@ import org.springframework.web.socket.WebSocketMessage;
|
|||
import org.springframework.web.socket.WebSocketSession;
|
||||
import org.springframework.web.socket.handler.TextWebSocketHandler;
|
||||
import ru.micord.ervu.account_applications.security.context.SecurityContext;
|
||||
import ru.micord.ervu.account_applications.security.service.EncryptionService;
|
||||
import ru.micord.ervu.account_applications.service.UserApplicationListService;
|
||||
import ru.micord.ervu.account_applications.security.service.AESEncryptionService;
|
||||
import ru.micord.ervu.account_applications.websocket.dto.ProcessResponseDto;
|
||||
import ru.micord.ervu.account_applications.websocket.service.WebSocketService;
|
||||
|
||||
|
|
@ -31,13 +31,13 @@ public class ClientSocketHandler extends TextWebSocketHandler {
|
|||
|
||||
private final ObjectMapper objectMapper;
|
||||
private final UserApplicationListService applicationService;
|
||||
private final AESEncryptionService encryptionService;
|
||||
private final EncryptionService encryptionService;
|
||||
private final WebSocketService webSocketService;
|
||||
private final SecurityContext securityContext;
|
||||
|
||||
public ClientSocketHandler(ObjectMapper objectMapper,
|
||||
UserApplicationListService applicationService,
|
||||
AESEncryptionService encryptionService,
|
||||
EncryptionService encryptionService,
|
||||
@Lazy WebSocketService webSocketService,
|
||||
SecurityContext securityContext) {
|
||||
this.objectMapper = objectMapper;
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@ DB_SEC_NAME=account_applications
|
|||
|
||||
ERVU_URL=https://ervu-dev.pgs.rtlabs.ru
|
||||
ERVU_HTTP_TIMEOUT=30
|
||||
ERVU_SECRET_KEY=
|
||||
ERVU_PWD_SIGN_SECRET_KEY=
|
||||
|
|
@ -3454,7 +3454,7 @@
|
|||
<key>dataConverter</key>
|
||||
<value>
|
||||
<implRef type="JAVA">
|
||||
<className>PasswordDecoder</className>
|
||||
<className>PasswordConverter</className>
|
||||
<packageName>ru.micord.ervu.account_applications.component.field.dataconvert</packageName>
|
||||
</implRef>
|
||||
</value>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue