/** * Decypts a message, delegating to wrapped encryptor * * @param encryptedMessage the message to be decrypted. * @return the result of decryption. */ public BigDecimal decrypt(final BigDecimal encryptedMessage) { if (this.encryptor == null) { throw new EncryptionInitializationException( "Encryptor has not been set into Hibernate wrapper"); } return this.encryptor.decrypt(encryptedMessage); }
/** * Encrypts a message, delegating to wrapped encryptor. * * @param message the message to be encrypted. * @return the encryption result. */ public BigDecimal encrypt(final BigDecimal message) { if (this.encryptor == null) { throw new EncryptionInitializationException( "Encryptor has not been set into Hibernate wrapper"); } return this.encryptor.encrypt(message); }
public void nullSafeSet(final PreparedStatement st, final Object value, final int index, final SessionImplementor session) throws HibernateException, SQLException { checkInitialization(); if (value == null) { st.setNull(index, sqlType); } else { final BigDecimal scaledValue = ((BigDecimal) value).setScale( this.decimalScale.intValue(), BigDecimal.ROUND_DOWN); final BigDecimal encryptedMessage = this.encryptor.encrypt(scaledValue); st.setBigDecimal(index, encryptedMessage); } }
public Object nullSafeGet(final ResultSet rs, final String[] names, final SessionImplementor session, final Object owner) throws HibernateException, SQLException { checkInitialization(); final BigDecimal storedEncryptedMessage = rs.getBigDecimal(names[0]); if (rs.wasNull()) { return null; } final BigDecimal scaledEncryptedMessage = storedEncryptedMessage.setScale( this.decimalScale.intValue(), BigDecimal.ROUND_UNNECESSARY); return this.encryptor.decrypt(scaledEncryptedMessage); }