@Override public String hash(String plainText) throws Exception { return PasswordMaskingUtil.wrap(codec.encode(plainText)); }
/** * This main class is as documented on configuration-index.md, where the user can mask the password here. * * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Use: java -cp <classPath> org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec password-to-encode"); System.err.println("Error: no password on the args"); System.exit(-1); } DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); Map<String, String> params = new HashMap<>(); Properties properties = System.getProperties(); synchronized (properties) { for (final String name : properties.stringPropertyNames()) { params.put(name, properties.getProperty(name)); } } codec.init(params); Object encode = codec.encode(args[0]); System.out.println("Encoded password (without quotes): \"" + encode + "\""); }
@Override public String hash(String plainText) throws Exception { return PasswordMaskingUtil.wrap(codec.encode(plainText)); }
@Override public String hash(String plainText) throws Exception { return PasswordMaskingUtil.wrap(codec.encode(plainText)); }
@Override public String hash(String plainText) throws Exception { return PasswordMaskingUtil.wrap(codec.encode(plainText)); }
@Override public String hash(String plainText) throws Exception { return PasswordMaskingUtil.wrap(codec.encode(plainText)); }
@Override public String hash(String plainText) throws Exception { return PasswordMaskingUtil.wrap(codec.encode(plainText)); }
@Override public String hash(String plainText) throws Exception { return PasswordMaskingUtil.wrap(codec.encode(plainText)); }
@Override public Object execute(ActionContext context) throws Exception { Map<String, String> params = new HashMap<>(); if (hash) { params.put(DefaultSensitiveStringCodec.ALGORITHM, DefaultSensitiveStringCodec.ONE_WAY); } if (key != null) { if (hash) { context.out.println("Option --key ignored in case of hashing"); } else { params.put(DefaultSensitiveStringCodec.BLOWFISH_KEY, key); } } codec = PasswordMaskingUtil.getDefaultCodec(); codec.init(params); String masked = codec.encode(password); context.out.println("result: " + masked); return masked; }
/** * This main class is as documented on configuration-index.md, where the user can mask the password here. * * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Use: java -cp <classPath> org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec password-to-encode"); System.err.println("Error: no password on the args"); System.exit(-1); } DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); Map<String, String> params = new HashMap<>(); Properties properties = System.getProperties(); synchronized (properties) { for (final String name : properties.stringPropertyNames()) { params.put(name, properties.getProperty(name)); } } codec.init(params); Object encode = codec.encode(args[0]); System.out.println("Encoded password (without quotes): \"" + encode + "\""); }
/** * This main class is as documented on configuration-index.md, where the user can mask the password here. * * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Use: java -cp <classPath> org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec password-to-encode"); System.err.println("Error: no password on the args"); System.exit(-1); } DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); Map<String, String> params = new HashMap<>(); Properties properties = System.getProperties(); synchronized (properties) { for (final String name : properties.stringPropertyNames()) { params.put(name, properties.getProperty(name)); } } codec.init(params); Object encode = codec.encode(args[0]); System.out.println("Encoded password (without quotes): \"" + encode + "\""); }
@Override public Object execute(ActionContext context) throws Exception { Map<String, String> params = new HashMap<>(); if (hash) { params.put(DefaultSensitiveStringCodec.ALGORITHM, DefaultSensitiveStringCodec.ONE_WAY); } if (key != null) { if (hash) { context.out.println("Option --key ignored in case of hashing"); } else { params.put(DefaultSensitiveStringCodec.BLOWFISH_KEY, key); } } codec = PasswordMaskingUtil.getDefaultCodec(); codec.init(params); String masked = codec.encode(password); context.out.println("result: " + masked); return masked; }
/** * This main class is as documented on configuration-index.md, where the user can mask the password here. * * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Use: java -cp <classPath> org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec password-to-encode"); System.err.println("Error: no password on the args"); System.exit(-1); } DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); Map<String, String> params = new HashMap<>(); Properties properties = System.getProperties(); synchronized (properties) { for (final String name : properties.stringPropertyNames()) { params.put(name, properties.getProperty(name)); } } codec.init(params); Object encode = codec.encode(args[0]); System.out.println("Encoded password (without quotes): \"" + encode + "\""); }
/** * This main class is as documented on configuration-index.md, where the user can mask the password here. * * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Use: java -cp <classPath> org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec password-to-encode"); System.err.println("Error: no password on the args"); System.exit(-1); } DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); Map<String, String> params = new HashMap<>(); Properties properties = System.getProperties(); synchronized (properties) { for (final String name : properties.stringPropertyNames()) { params.put(name, properties.getProperty(name)); } } codec.init(params); Object encode = codec.encode(args[0]); System.out.println("Encoded password (without quotes): \"" + encode + "\""); }
/** * This main class is as documented on configuration-index.md, where the user can mask the password here. * * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Use: java -cp <classPath> org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec password-to-encode"); System.err.println("Error: no password on the args"); System.exit(-1); } DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); Map<String, String> params = new HashMap<>(); Properties properties = System.getProperties(); synchronized (properties) { for (final String name : properties.stringPropertyNames()) { params.put(name, properties.getProperty(name)); } } codec.init(params); Object encode = codec.encode(args[0]); System.out.println("Encoded password (without quotes): \"" + encode + "\""); }
@Test public void testTwowayAlgorithm() throws Exception { DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); Map<String, String> params = new HashMap<>(); params.put(DefaultSensitiveStringCodec.ALGORITHM, DefaultSensitiveStringCodec.TWO_WAY); codec.init(params); String plainText = "some_password"; String maskedText = codec.encode(plainText); System.out.println("encoded value: " + maskedText); String decoded = codec.decode(maskedText); System.out.println("encoded value: " + maskedText); assertEquals("decoded result not match: " + decoded, decoded, plainText); } }
@Test public void testOnewayAlgorithm() throws Exception { DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); Map<String, String> params = new HashMap<>(); params.put(DefaultSensitiveStringCodec.ALGORITHM, DefaultSensitiveStringCodec.ONE_WAY); codec.init(params); String plainText = "some_password"; String maskedText = codec.encode(plainText); System.out.println("encoded value: " + maskedText); //one way can't decode try { codec.decode(maskedText); fail("one way algorithm can't decode"); } catch (IllegalArgumentException expected) { } assertTrue(codec.verify(plainText.toCharArray(), maskedText)); String otherPassword = "some_other_password"; assertFalse(codec.verify(otherPassword.toCharArray(), maskedText)); }
@Test public void testMaskPassword() throws Exception { ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter(); qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY); ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext(); DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); String mask = codec.encode("helloworld"); qResourceAdapter.setUseMaskedPassword(true); qResourceAdapter.setPassword(mask); qResourceAdapter.start(ctx); assertEquals("helloworld", qResourceAdapter.getPassword()); ActiveMQActivationSpec spec = new ActiveMQActivationSpec(); spec.setResourceAdapter(qResourceAdapter); spec.setUseJNDI(false); spec.setDestinationType("javax.jms.Queue"); spec.setDestination(MDBQUEUE); mask = (String) codec.encode("mdbpassword"); spec.setPassword(mask); qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY); CountDownLatch latch = new CountDownLatch(1); DummyMessageEndpoint endpoint = new DummyMessageEndpoint(latch); DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, false); qResourceAdapter.endpointActivation(endpointFactory, spec); assertEquals("mdbpassword", spec.getPassword()); qResourceAdapter.stop(); assertTrue(endpoint.released); }
@Test public void testOneWaySSLwithURLandMaskedPasswordProperty() throws Exception { createCustomSslServer(); String text = RandomUtil.randomString(); DefaultSensitiveStringCodec codec = PasswordMaskingUtil.getDefaultCodec(); Map<String, String> params = new HashMap<>(); codec.init(params); String masked = codec.encode(PASSWORD); ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocator("tcp://127.0.0.1:61616?sslEnabled=true;trustStoreProvider=" + storeType + ";trustStorePath=" + CLIENT_SIDE_TRUSTSTORE + ";trustStorePassword=" + masked + ";activemq.usemaskedpassword=true")); ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator)); ClientSession session = addClientSession(sf.createSession(false, true, true)); session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE, false); ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE)); ClientMessage message = createTextMessage(session, text); producer.send(message); ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE)); session.start(); ClientMessage m = consumer.receive(1000); Assert.assertNotNull(m); Assert.assertEquals(text, m.getBodyBuffer().readString()); }
@Test public void testOneWaySSLwithURLandMaskedPasswordENCSyntax() throws Exception { createCustomSslServer(); String text = RandomUtil.randomString(); DefaultSensitiveStringCodec codec = PasswordMaskingUtil.getDefaultCodec(); Map<String, String> params = new HashMap<>(); codec.init(params); String masked = codec.encode(PASSWORD); ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocator("tcp://127.0.0.1:61616?sslEnabled=true;trustStoreProvider=" + storeType + ";trustStorePath=" + CLIENT_SIDE_TRUSTSTORE + ";trustStorePassword=ENC(" + masked + ")")); ClientSessionFactory sf = addSessionFactory(createSessionFactory(locator)); ClientSession session = addClientSession(sf.createSession(false, true, true)); session.createQueue(CoreClientOverOneWaySSLTest.QUEUE, CoreClientOverOneWaySSLTest.QUEUE, false); ClientProducer producer = addClientProducer(session.createProducer(CoreClientOverOneWaySSLTest.QUEUE)); ClientMessage message = createTextMessage(session, text); producer.send(message); ClientConsumer consumer = addClientConsumer(session.createConsumer(CoreClientOverOneWaySSLTest.QUEUE)); session.start(); ClientMessage m = consumer.receive(1000); Assert.assertNotNull(m); Assert.assertEquals(text, m.getBodyBuffer().readString()); }