Search in sources :

Example 1 with ValueEncryptor

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;
}
Also used : DbAttribute(org.apache.cayenne.map.DbAttribute) DbAttributeBinding(org.apache.cayenne.access.translator.DbAttributeBinding) ValueEncryptor(org.apache.cayenne.crypto.transformer.value.ValueEncryptor)

Aggregations

DbAttributeBinding (org.apache.cayenne.access.translator.DbAttributeBinding)1 ValueEncryptor (org.apache.cayenne.crypto.transformer.value.ValueEncryptor)1 DbAttribute (org.apache.cayenne.map.DbAttribute)1