Search in sources :

Example 1 with Mask

use of org.apache.activemq.artemis.cli.commands.Mask in project activemq-artemis by apache.

the class ArtemisTest method testMaskCommand.

@Test
public void testMaskCommand() throws Exception {
    String password1 = "password";
    String encrypt1 = "3a34fd21b82bf2a822fa49a8d8fa115d";
    String newKey = "artemisfun";
    String encrypt2 = "-2b8e3b47950b9b481a6f3100968e42e9";
    TestActionContext context = new TestActionContext();
    Mask mask = new Mask();
    mask.setPassword(password1);
    String result = (String) mask.execute(context);
    System.out.println(context.getStdout());
    assertEquals(encrypt1, result);
    context = new TestActionContext();
    mask = new Mask();
    mask.setPassword(password1);
    mask.setHash(true);
    result = (String) mask.execute(context);
    System.out.println(context.getStdout());
    DefaultSensitiveStringCodec codec = mask.getCodec();
    codec.verify(password1.toCharArray(), result);
    context = new TestActionContext();
    mask = new Mask();
    mask.setPassword(password1);
    mask.setKey(newKey);
    result = (String) mask.execute(context);
    System.out.println(context.getStdout());
    assertEquals(encrypt2, result);
}
Also used : Mask(org.apache.activemq.artemis.cli.commands.Mask) DefaultSensitiveStringCodec(org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Test(org.junit.Test)

Aggregations

SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 Mask (org.apache.activemq.artemis.cli.commands.Mask)1 DefaultSensitiveStringCodec (org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec)1 Test (org.junit.Test)1