use of org.apache.cayenne.crypto.transformer.value.ValueEncryptor in project cayenne by apache.
the class DefaultTransformerFactory method encryptor.
@Override
public BindingsTransformer encryptor(DbAttributeBinding[] bindings, ExtendedTypeMap extendedTypeMap) {
int len = bindings.length;
List<Integer> cryptoColumns = null;
for (int i = 0; i < len; i++) {
DbAttribute a = bindings[i].getAttribute();
if (columnMapper.isEncrypted(a)) {
if (cryptoColumns == null) {
cryptoColumns = new ArrayList<>(len - i);
}
cryptoColumns.add(i);
}
}
if (cryptoColumns != null) {
int dlen = cryptoColumns.size();
int[] positions = new int[dlen];
ValueEncryptor[] transformers = new ValueEncryptor[dlen];
for (int i = 0; i < dlen; i++) {
int pos = cryptoColumns.get(i);
DbAttributeBinding b = bindings[pos];
positions[i] = pos;
transformers[i] = transformerFactory.encryptor(b.getAttribute());
}
return new DefaultBindingsTransformer(positions, transformers, bytesTransformerFactory.encryptor(), extendedTypeMap);
}
return null;
}
Aggregations