All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.saphyra.encryption.base.AbstractEncryptor Maven / Gradle / Ivy

package com.github.saphyra.encryption.base;

public abstract class AbstractEncryptor implements Encryptor{
    @Override
    public T encryptEntity(T entity, String key) {
        validateKey(key);
        if(entity == null){
            return null;
        }
        return encrypt(entity, key);
    }

    @Override
    public T decryptEntity(T entity, String key) {
        validateKey(key);
        if(entity == null){
            return null;
        }
        return decrypt(entity, key);
    }

    private void validateKey(String key) {
        if(key == null){
            throw new IllegalArgumentException("Key must not be null.");
        }
    }

    protected abstract T encrypt(T entity, String key);

    protected abstract T decrypt(T entity, String key);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy