public static DefaultSensitiveStringCodec getDefaultCodec() { return new DefaultSensitiveStringCodec(); }
/** * 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 + "\""); }
public static DefaultSensitiveStringCodec getDefaultCodec() { return new DefaultSensitiveStringCodec(); }
public static DefaultSensitiveStringCodec getDefaultCodec() { return new DefaultSensitiveStringCodec(); }
public static DefaultSensitiveStringCodec getDefaultCodec() { return new DefaultSensitiveStringCodec(); }
public static DefaultSensitiveStringCodec getDefaultCodec() { return new DefaultSensitiveStringCodec(); }
public static DefaultSensitiveStringCodec getDefaultCodec() { return new DefaultSensitiveStringCodec(); }
public static DefaultSensitiveStringCodec getDefaultCodec() { return new DefaultSensitiveStringCodec(); }
/** * 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 + "\""); }
/** * 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)); }
DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); String mask = (String) codec.encode("helloworld"); codec = new DefaultSensitiveStringCodec(); Map<String, String> prop = new HashMap<>(); prop.put("key", "newkey");
@Test public void testMaskPassword2ENC() throws Exception { ActiveMQResourceAdapter qResourceAdapter = new ActiveMQResourceAdapter(); qResourceAdapter.setConnectorClassName(INVM_CONNECTOR_FACTORY); ActiveMQRATestBase.MyBootstrapContext ctx = new ActiveMQRATestBase.MyBootstrapContext(); qResourceAdapter.setPasswordCodec(DefaultSensitiveStringCodec.class.getName() + ";key=anotherkey"); DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); Map<String, String> prop = new HashMap<>(); prop.put("key", "anotherkey"); codec.init(prop); String mask = codec.encode("helloworld"); qResourceAdapter.setPassword(PasswordMaskingUtil.wrap(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 = codec.encode("mdbpassword"); spec.setPassword(PasswordMaskingUtil.wrap(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 testMaskPasswordENC() 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.setPassword(PasswordMaskingUtil.wrap(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 = codec.encode("mdbpassword"); spec.setPassword(PasswordMaskingUtil.wrap(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 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); }