|
|
@ -42,8 +42,6 @@ public class CryptographySupport extends MybatisPlugin {
|
|
|
|
this.cryptos = cryptos.stream().collect(Collectors.toMap(Cryptography::name, crypto -> crypto));
|
|
|
|
this.cryptos = cryptos.stream().collect(Collectors.toMap(Cryptography::name, crypto -> crypto));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: 파라미터 추출 및 검사 방식 변경할 것: BoundSql, ParameterMapping을 사용하여 구분 및 추출
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected Object query(Executor executor, MappedStatement mappedStatement, Object obj, RowBounds rowBounds, ResultHandler<?> resultHandler) throws SQLException {
|
|
|
|
protected Object query(Executor executor, MappedStatement mappedStatement, Object obj, RowBounds rowBounds, ResultHandler<?> resultHandler) throws SQLException {
|
|
|
|
return encrypt(obj, () -> super.query(executor, mappedStatement, obj, rowBounds, resultHandler));
|
|
|
|
return encrypt(obj, () -> super.query(executor, mappedStatement, obj, rowBounds, resultHandler));
|
|
|
@ -145,44 +143,7 @@ public class CryptographySupport extends MybatisPlugin {
|
|
|
|
throw runtimeException(e);
|
|
|
|
throw runtimeException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
|
|
|
|
private void convert(Object obj, BiFunction<Cryptography, Object, Object> converter) {
|
|
|
|
|
|
|
|
List<Cryptography.TargetValue> targetValues = Cryptography.Config.get().getTargetValues(obj);
|
|
|
|
|
|
|
|
if (targetValues.isEmpty()) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
for (Cryptography.TargetValue target: targetValues) {
|
|
|
|
|
|
|
|
for (String cryptoDef: target.getCryptoDefs()) {
|
|
|
|
|
|
|
|
Cryptography crypto = cryptos.get(cryptoDef);
|
|
|
|
|
|
|
|
if (crypto == null) continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (obj instanceof Map) {
|
|
|
|
|
|
|
|
Map<String, Object> map = (Map<String, Object>)obj;
|
|
|
|
|
|
|
|
target.getMapKeys().stream()
|
|
|
|
|
|
|
|
.filter(key -> map.containsKey(key))
|
|
|
|
|
|
|
|
.forEach(key -> {
|
|
|
|
|
|
|
|
Object val = map.get(key);
|
|
|
|
|
|
|
|
map.put(key, converter.apply(crypto, val));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
target.getObjectProperties().stream()
|
|
|
|
|
|
|
|
.filter(property -> Property.readable(obj, property))
|
|
|
|
|
|
|
|
.forEach(property -> {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String val = Property.read(obj, property);
|
|
|
|
|
|
|
|
Property.write(obj, property, converter.apply(crypto, val));
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
throw runtimeException(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
throw runtimeException(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void decrypt(Object obj) {
|
|
|
|
private void decrypt(Object obj) {
|
|
|
|
if (!isEnabled(obj)) return;
|
|
|
|
if (!isEnabled(obj)) return;
|
|
|
|
|
|
|
|
|
|
|
|