Search in sources :

Example 1 with Security

use of com.dexels.navajo.functions.security.Security in project navajo by Dexels.

the class DecryptString method evaluate.

@Override
public Object evaluate() throws TMLExpressionException {
    String result = null;
    String key = (String) getOperand(0);
    String message = (String) getOperand(1);
    try {
        Security s = new Security(key);
        result = s.decrypt(message);
    } catch (Exception e) {
        throw new TMLExpressionException(e.getMessage(), e);
    }
    return result;
}
Also used : Security(com.dexels.navajo.functions.security.Security) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Example 2 with Security

use of com.dexels.navajo.functions.security.Security in project navajo by Dexels.

the class DecryptBinary method evaluate.

@Override
public Object evaluate() throws TMLExpressionException {
    Binary result = null;
    String key = (String) getOperand(0);
    String message = (String) getOperand(1);
    try {
        Security s = new Security(key);
        result = s.decryptBinary(message);
    } catch (Exception e) {
        throw new TMLExpressionException(e.getMessage());
    }
    return result;
}
Also used : Binary(com.dexels.navajo.document.types.Binary) Security(com.dexels.navajo.functions.security.Security) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Example 3 with Security

use of com.dexels.navajo.functions.security.Security in project navajo by Dexels.

the class EncryptString method evaluate.

@Override
public Object evaluate() throws TMLExpressionException {
    String result = null;
    String key = (String) getOperand(0);
    String message = (String) getOperand(1);
    try {
        Security s = new Security(key);
        result = s.encrypt(message).replace("\n", "");
    } catch (Exception e) {
        throw new TMLExpressionException(e.getMessage());
    }
    return result;
}
Also used : Security(com.dexels.navajo.functions.security.Security) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Example 4 with Security

use of com.dexels.navajo.functions.security.Security in project navajo by Dexels.

the class EncryptBinary method evaluate.

@Override
public Object evaluate() throws TMLExpressionException {
    String result = null;
    String key = (String) getOperand(0);
    Binary image = (Binary) getOperand(1);
    try {
        Security s = new Security(key);
        result = s.encrypt(image).replace("\n", "");
    } catch (Exception e) {
        throw new TMLExpressionException(e.getMessage());
    }
    return result;
}
Also used : Binary(com.dexels.navajo.document.types.Binary) Security(com.dexels.navajo.functions.security.Security) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException)

Example 5 with Security

use of com.dexels.navajo.functions.security.Security in project navajo by Dexels.

the class TestEncryptBinary method testEncryptBinary.

@Test
public void testEncryptBinary() throws Exception {
    Security s = new Security("A");
    File f = new File("test");
    FileOutputStream fos = new FileOutputStream(f);
    fos.write("Content".getBytes());
    fos.close();
    Binary b = new Binary(new FileInputStream(f));
    String enc = s.encrypt(b);
    System.err.println("enc: " + enc);
    Binary b2 = s.decryptBinary(enc);
    BufferedReader is = new BufferedReader(new InputStreamReader(b2.getDataAsStream(), "UTF-8"));
    String l = is.readLine();
    is.close();
    Assert.assertEquals("Content", l);
    f.delete();
}
Also used : InputStreamReader(java.io.InputStreamReader) FileOutputStream(java.io.FileOutputStream) BufferedReader(java.io.BufferedReader) Binary(com.dexels.navajo.document.types.Binary) Security(com.dexels.navajo.functions.security.Security) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

Security (com.dexels.navajo.functions.security.Security)5 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)4 Binary (com.dexels.navajo.document.types.Binary)3 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 Test (org.junit.Test)1