use of org.apache.cayenne.crypto.transformer.value.ValueDecryptor in project cayenne by apache.
the class DefaultTransformerFactory method decryptor.
@Override
public MapTransformer decryptor(ColumnDescriptor[] columns, Object sampleRow) {
if (!(sampleRow instanceof Map)) {
return null;
}
int len = columns.length;
List<Integer> cryptoColumns = null;
for (int i = 0; i < len; i++) {
DbAttribute a = columns[i].getAttribute();
if (a != null && columnMapper.isEncrypted(a)) {
if (cryptoColumns == null) {
cryptoColumns = new ArrayList<>(len - i);
}
cryptoColumns.add(i);
}
}
if (cryptoColumns != null) {
int dlen = cryptoColumns.size();
String[] mapKeys = new String[dlen];
ValueDecryptor[] transformers = new ValueDecryptor[dlen];
for (int i = 0; i < dlen; i++) {
ColumnDescriptor cd = columns[cryptoColumns.get(i)];
mapKeys[i] = cd.getDataRowKey();
transformers[i] = transformerFactory.decryptor(cd.getAttribute());
}
return new DefaultMapTransformer(mapKeys, transformers, bytesTransformerFactory.decryptor());
}
return null;
}
Aggregations