public static BinaryType digest(byte[] plainText, String algorithm) throws NoSuchAlgorithmException { MessageDigest messageDigest = MessageDigest.getInstance(algorithm); return new BinaryType(messageDigest.digest(plainText)); }
@TeiidFunction(category=FunctionCategoryConstants.SECURITY, nullOnNull=true) public static BinaryType aes_encrypt(BinaryType dataBytes, BinaryType keyBytes) throws FunctionExecutionException { try { byte[] encryptResult = SymmetricCryptor.getSymmectricCryptor(padkey(keyBytes.getBytesDirect()), "AES", "AES/CBC/PKCS5Padding", new IvParameterSpec(iv)).encrypt(dataBytes.getBytesDirect()); //$NON-NLS-1$ //$NON-NLS-2$ return new BinaryType(encryptResult); } catch (CryptoException e) { throw new FunctionExecutionException(e); } }
@Override protected void writeObject(ObjectOutput out, Object obj, Map<Object, Integer> cache, byte version) throws IOException { //uses object serialization for compatibility with legacy clients super.writeObject(out, ((BinaryType)obj).getBytesDirect(), cache, version); }
@Override protected void writeObject(ObjectOutput out, Object obj, Map<Object, Integer> cache, byte version) throws IOException { byte[] bytes = ((BinaryType)obj).getBytes(); out.writeInt(bytes.length); //in theory this could be a short, but we're not strictly enforcing the length out.write(bytes); }
/** * This method transforms a value of the source type into a value * of the target type. * @param value Incoming value of source type * @return Outgoing value of target type * @throws TransformationException if value is an incorrect input type or * the transformation fails */ public Object transformDirect(Object value) throws TransformationException { BinaryType contents = (BinaryType)value; return contents.toBlob(); }
@Override protected void writeObject(ObjectOutput out, Object obj, Map<Object, Integer> cache, byte version) throws IOException { //uses object serialization for compatibility with legacy clients super.writeObject(out, ((BinaryType)obj).getBytesDirect(), cache, version); }
@Override protected void writeObject(ObjectOutput out, Object obj, Map<Object, Integer> cache, byte version) throws IOException { byte[] bytes = ((BinaryType)obj).getBytes(); out.writeInt(bytes.length); //in theory this could be a short, but we're not strictly enforcing the length out.write(bytes); }
/** * This method transforms a value of the source type into a value * of the target type. * @param value Incoming value of source type * @return Outgoing value of target type * @throws TransformationException if value is an incorrect input type or * the transformation fails */ public Object transformDirect(Object value) throws TransformationException { BinaryType contents = (BinaryType)value; return contents.toBlob(); }
public static BinaryType digest(byte[] plainText, String algorithm) throws NoSuchAlgorithmException { MessageDigest messageDigest = MessageDigest.getInstance(algorithm); return new BinaryType(messageDigest.digest(plainText)); }
@TeiidFunction(category=FunctionCategoryConstants.SECURITY, nullOnNull=true) public static BinaryType aes_encrypt(BinaryType dataBytes, BinaryType keyBytes) throws FunctionExecutionException { try { byte[] encryptResult = SymmetricCryptor.getSymmectricCryptor(padkey(keyBytes.getBytesDirect()), "AES", "AES/CBC/PKCS5Padding", new IvParameterSpec(iv)).encrypt(dataBytes.getBytesDirect()); //$NON-NLS-1$ //$NON-NLS-2$ return new BinaryType(encryptResult); } catch (CryptoException e) { throw new FunctionExecutionException(e); } }
@TeiidFunction(category=FunctionCategoryConstants.SECURITY, nullOnNull=true) public static BinaryType sha1(BinaryType plainText) throws NoSuchAlgorithmException { return digest(plainText.getBytesDirect(), "sha-1"); //$NON-NLS-1$ }
return new Binary(((BinaryType)value).getBytes());
public static BinaryType digest(byte[] plainText, String algorithm) throws NoSuchAlgorithmException { MessageDigest messageDigest = MessageDigest.getInstance(algorithm); return new BinaryType(messageDigest.digest(plainText)); }
@TeiidFunction(category=FunctionCategoryConstants.SECURITY, nullOnNull=true) public static BinaryType aes_decrypt(BinaryType dataBytes, BinaryType keyBytes) throws FunctionExecutionException { try { byte[] decryptResult = SymmetricCryptor.getSymmectricCryptor(padkey(keyBytes.getBytesDirect()), "AES", "AES/CBC/PKCS5Padding", new IvParameterSpec(iv)).decrypt(dataBytes.getBytesDirect()); //$NON-NLS-1$ //$NON-NLS-2$ return new BinaryType(decryptResult); } catch (CryptoException e) { throw new FunctionExecutionException(e); } }
@TeiidFunction(category=FunctionCategoryConstants.SECURITY, nullOnNull=true) public static BinaryType sha2_256(BinaryType plainText) throws NoSuchAlgorithmException { return digest(plainText.getBytesDirect(), "sha-256"); //$NON-NLS-1$ }
int length = ((BinaryType)obj).getLength(); if (length > 0) { return alignMemory(16 + length);
@Override protected Object readObject(ObjectInput in, List<Object> cache, byte version) throws IOException, ClassNotFoundException { int length = in.readInt(); byte[] bytes = new byte[length]; in.readFully(bytes); return new BinaryType(bytes); } }
@TeiidFunction(category=FunctionCategoryConstants.SECURITY, nullOnNull=true) public static BinaryType aes_encrypt(BinaryType dataBytes, BinaryType keyBytes) throws FunctionExecutionException { try { byte[] encryptResult = SymmetricCryptor.getSymmectricCryptor(padkey(keyBytes.getBytesDirect()), "AES", "AES/CBC/PKCS5Padding", new IvParameterSpec(iv)).encrypt(dataBytes.getBytesDirect()); //$NON-NLS-1$ //$NON-NLS-2$ return new BinaryType(encryptResult); } catch (CryptoException e) { throw new FunctionExecutionException(e); } }