hibernate-encrypt

Hibernate encryption library

License

License

Categories

Categories

Net Hibernate Data ORM
GroupId

GroupId

net.zubial
ArtifactId

ArtifactId

hibernate-encrypt
Last Version

Last Version

1.4
Release Date

Release Date

Type

Type

jar
Description

Description

hibernate-encrypt
Hibernate encryption library
Source Code Management

Source Code Management

https://github.com/zubial/hibernate-encrypt

Download hibernate-encrypt

How to add to project

<!-- https://jarcasting.com/artifacts/net.zubial/hibernate-encrypt/ -->
<dependency>
    <groupId>net.zubial</groupId>
    <artifactId>hibernate-encrypt</artifactId>
    <version>1.4</version>
</dependency>
// https://jarcasting.com/artifacts/net.zubial/hibernate-encrypt/
implementation 'net.zubial:hibernate-encrypt:1.4'
// https://jarcasting.com/artifacts/net.zubial/hibernate-encrypt/
implementation ("net.zubial:hibernate-encrypt:1.4")
'net.zubial:hibernate-encrypt:jar:1.4'
<dependency org="net.zubial" name="hibernate-encrypt" rev="1.4">
  <artifact name="hibernate-encrypt" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.zubial', module='hibernate-encrypt', version='1.4')
)
libraryDependencies += "net.zubial" % "hibernate-encrypt" % "1.4"
[net.zubial/hibernate-encrypt "1.4"]

Dependencies

compile (4)

Group / Artifact Type Version
commons-io : commons-io jar 2.3
org.apache.commons : commons-lang3 jar 3.2.1
org.hibernate : hibernate-core jar 5.1.0.Final
org.apache.logging.log4j : log4j-core jar 2.8.2

Project Modules

There are no modules declared in this project.

Java Hibernate Encryption library

This library brings new types field for hibernate mapping. These types allow encoding and decoding Text fields.

Searches on these fields remain possible, but only in equal (case-sensitive). It is advisable to manage the case at insertion.

Used with Spring 4 / Hibernate 5 / Oracle db

ChangeLogs

1.x

  • Initial commit

Usage

  • Dependency
    <dependency>
        <groupId>net.zubial</groupId>
        <artifactId>hibernate-encrypt</artifactId>
        <version>1.4</version>
    </dependency>
  • Declare the Encryptor pool as a new bean (Spring applicationContext)
    <bean id="hibernatePoolEncryptor"
          class="net.zubial.hibernate.encrypt.impl.PBEHibernatePoolStringEncryptor">
        <property name="registeredName">
            <value>hibernatePoolEncryptor</value>
        </property>
        <property name="algorithm">
            <value>[algorithm, default AES/CBC/PKCS5Padding]</value>
        </property>
        <property name="messageCharset">
            <value>[messageCharset, default UTF-8]</value>
        </property>
        <property name="passwordPathfile">
            <value>[textfile included password]</value>
        </property>
        <property name="password">
            <value>[if you don't use a textfile]</value>
        </property>
        <property name="poolSize">
            <value>[size of the pool, default 4]</value>
        </property>
        <property name="enable">
            <value>[true or false]</value>
        </property>
    </bean>
  • Declare new Hibernate type (package-info.java inside hibernate entities package)
    @TypeDefs({
            @TypeDef(name = "encryptedString", typeClass = PBEHibernateStringType.class, parameters = {
                    @Parameter(name = "encryptorRegisteredName", value = "hibernatePoolEncryptor")
            }),
            @TypeDef(name = "encryptedNationalized", typeClass = PBEHibernateNationalizedType.class, parameters = {
                    @Parameter(name = "encryptorRegisteredName", value = "hibernatePoolEncryptor")
            })
    })
    package com.your.package.hibernate;
  • Declare encrypted fields (Hibernate mapping)
    @Column(name = "USER_NAME")
    @Type(type = "encryptedString")
    private String userName;

Versions

Version
1.4