io.ebean.config.dbplatform.AbstractDbEncrypt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebean.config.dbplatform;
import java.sql.Types;
/**
* Base type for DB platform specific Encryption.
*
* DB specific classes that extend this need to set their specific encryption
* functions for varchar, date and timestamp. If they are left null then that is
* treated as though that data type can not be encrypted in the DB and will
* instead use java client encryption.
*
*
* @author rbygrave
*/
public abstract class AbstractDbEncrypt implements DbEncrypt {
/**
* The encryption function for all String types (VARCHAR, CLOB, LONGVARCHAR,
* CHAR).
*/
protected DbEncryptFunction varcharEncryptFunction;
/**
* The encryption function for all Date types (java.sql.Date, Joda Date
* types).
*/
protected DbEncryptFunction dateEncryptFunction;
/**
* The encryption function for all Timestamp types (java.sql.Timestamp,
* java.util.Date, java.util.Calendar, Joda DateTime types etc).
*/
protected DbEncryptFunction timestampEncryptFunction;
/**
* Return the DB encryption function for the given JDBC type.
*
* Null is returned if DB encryption of the type is not supported.
*
*/
@Override
public DbEncryptFunction getDbEncryptFunction(int jdbcType) {
switch (jdbcType) {
case Types.VARCHAR:
return varcharEncryptFunction;
case Types.CLOB:
return varcharEncryptFunction;
case Types.CHAR:
return varcharEncryptFunction;
case Types.LONGVARCHAR:
return varcharEncryptFunction;
case Types.DATE:
return dateEncryptFunction;
case Types.TIMESTAMP:
return timestampEncryptFunction;
default:
return null;
}
}
/**
* Return the DB stored type for encrypted properties.
*/
@Override
public int getEncryptDbType() {
return Types.VARBINARY;
}
/**
* Generally encrypt function binding the data before the key (except h2).
*/
@Override
public boolean isBindEncryptDataFirst() {
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy