congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
CryptoEngine
Code IndexAdd Tabnine to your IDE (free)

How to use
CryptoEngine
in
bitronix.tm.utils

Best Java code snippets using bitronix.tm.utils.CryptoEngine (Showing top 16 results out of 315)

origin: com.github.marcus-nl.btm/btm

public void testCrypt() throws Exception {
  String textToCrypt = "java";
  String cypherText = CryptoEngine.crypt("DES", textToCrypt);
  String decryptedText = CryptoEngine.decrypt("DES", cypherText);
  assertEquals(textToCrypt, decryptedText);
}
origin: bitronix/btm

/**
 * Main method of this class to be used as a command-line tool to get a crypted version of a resource password.
 * @param args the command-line arguments.
 * @throws Exception when an error occurs crypting the given resource password.
 */
public static void main(String[] args) throws Exception {
  System.out.println("Bitronix Transaction Manager " + Version.getVersion() + " password property crypter");
  System.out.flush();
  if (args.length < 1 || args.length > 2) {
    System.err.println("Usage: CryptoEngine <password> [cipher]");
    System.err.println("  where:");
    System.err.println("    <password> is mandatory and is the resource password to crypt");
    System.err.println("    [cipher]   is optional and is the cipher to be used to crypt the password");
    System.exit(1);
  }
  String data = args[0];
  String cipher = "DES";
  if (args.length > 1)
    cipher = args[1];
  String propertyValue = "{" + cipher + "}" + crypt(cipher, data);
  System.out.println("crypted password property value: " + propertyValue);
}
origin: org.mule.btm/mule-btm

private static String decrypt(String resourcePassword) throws Exception {
  int startIdx = resourcePassword.indexOf("{");
  int endIdx = resourcePassword.indexOf("}");
  if (startIdx != 0 || endIdx == -1)
    return resourcePassword;
  String cipher = resourcePassword.substring(1, endIdx);
  if (log.isDebugEnabled()) log.debug("resource password is encrypted, decrypting " + resourcePassword);
  return CryptoEngine.decrypt(cipher, resourcePassword.substring(endIdx + 1));
}
origin: org.codehaus.btm/btm

KeySpec keySpec = loadKeySpec(CRYPTO_PASSWORD.getBytes(), cipher);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(cipher);
SecretKey secretKey = keyFactory.generateSecret(keySpec);
origin: org.codehaus.btm/btm

/**
 * Main method of this class to be used as a command-line tool to get a crypted version of a resource password.
 * @param args the command-line arguments.
 * @throws Exception when an error occurs crypting the given resource password.
 */
public static void main(String[] args) throws Exception {
  System.out.println("Bitronix Transaction Manager " + Version.getVersion() + " password property crypter");
  System.out.flush();
  if (args.length < 1 || args.length > 2) {
    System.err.println("Usage: CryptoEngine <password> [cipher]");
    System.err.println("  where:");
    System.err.println("    <password> is mandatory and is the resource password to crypt");
    System.err.println("    [cipher]   is optional and is the cipher to be used to crypt the password");
    System.exit(1);
  }
  String data = args[0];
  String cipher = "DES";
  if (args.length > 1)
    cipher = args[1];
  String propertyValue = "{" + cipher + "}" + crypt(cipher, data);
  System.out.println("crypted password property value: " + propertyValue);
}
origin: bitronix/btm

  private static String decrypt(String resourcePassword) throws Exception {
    int startIdx = resourcePassword.indexOf("{");
    int endIdx = resourcePassword.indexOf("}");

    if (startIdx != 0 || endIdx == -1)
      return resourcePassword;

    String cipher = resourcePassword.substring(1, endIdx);
    if (log.isDebugEnabled()) { log.debug("resource password is encrypted, decrypting " + resourcePassword); }
    return CryptoEngine.decrypt(cipher, resourcePassword.substring(endIdx + 1));
  }
}
origin: org.mule.btm/mule-btm

KeySpec keySpec = loadKeySpec(CRYPTO_PASSWORD.getBytes(), cipher);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(cipher);
SecretKey secretKey = keyFactory.generateSecret(keySpec);
origin: bitronix/btm

public void testCrypt() throws Exception {
  String textToCrypt = "java";
  String cypherText = CryptoEngine.crypt("DES", textToCrypt);
  String decryptedText = CryptoEngine.decrypt("DES", cypherText);
  assertEquals(textToCrypt, decryptedText);
}
origin: org.mule.btm/mule-btm

/**
 * Main method of this class to be used as a command-line tool to get a crypted version of a resource password.
 * @param args the command-line arguments.
 * @throws Exception when an error occurs crypting the given resource password.
 */
public static void main(String[] args) throws Exception {
  System.out.println("Bitronix Transaction Manager " + Version.getVersion() + " password property crypter");
  System.out.flush();
  if (args.length < 1 || args.length > 2) {
    System.err.println("Usage: CryptoEngine <password> [cipher]");
    System.err.println("  where:");
    System.err.println("    <password> is mandatory and is the resource password to crypt");
    System.err.println("    [cipher]   is optional and is the cipher to be used to crypt the password");
    System.exit(1);
  }
  String data = args[0];
  String cipher = "DES";
  if (args.length > 1)
    cipher = args[1];
  String propertyValue = "{" + cipher + "}" + crypt(cipher, data);
  System.out.println("crypted password property value: " + propertyValue);
}
origin: org.codehaus.btm/btm

private static String decrypt(String resourcePassword) throws Exception {
  int startIdx = resourcePassword.indexOf("{");
  int endIdx = resourcePassword.indexOf("}");
  if (startIdx != 0 || endIdx == -1)
    return resourcePassword;
  String cipher = resourcePassword.substring(1, endIdx);
  if (log.isDebugEnabled()) log.debug("resource password is encrypted, decrypting " + resourcePassword);
  return CryptoEngine.decrypt(cipher, resourcePassword.substring(endIdx + 1));
}
origin: org.codehaus.btm/btm

KeySpec keySpec = loadKeySpec(CRYPTO_PASSWORD.getBytes(), cipher);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(cipher);
SecretKey secretKey = keyFactory.generateSecret(keySpec);
origin: com.github.marcus-nl.btm/btm

/**
 * Main method of this class to be used as a command-line tool to get a crypted version of a resource password.
 * @param args the command-line arguments.
 * @throws Exception when an error occurs crypting the given resource password.
 */
public static void main(String[] args) throws Exception {
  System.out.println("Bitronix Transaction Manager " + Version.getVersion() + " password property crypter");
  System.out.flush();
  if (args.length < 1 || args.length > 2) {
    System.err.println("Usage: CryptoEngine <password> [cipher]");
    System.err.println("  where:");
    System.err.println("    <password> is mandatory and is the resource password to crypt");
    System.err.println("    [cipher]   is optional and is the cipher to be used to crypt the password");
    System.exit(1);
  }
  String data = args[0];
  String cipher = "DES";
  if (args.length > 1)
    cipher = args[1];
  String propertyValue = "{" + cipher + "}" + crypt(cipher, data);
  System.out.println("crypted password property value: " + propertyValue);
}
origin: com.github.marcus-nl.btm/btm

  private static String decrypt(String resourcePassword) throws Exception {
    int startIdx = resourcePassword.indexOf("{");
    int endIdx = resourcePassword.indexOf("}");

    if (startIdx != 0 || endIdx == -1)
      return resourcePassword;

    String cipher = resourcePassword.substring(1, endIdx);
    if (log.isDebugEnabled()) { log.debug("resource password is encrypted, decrypting " + resourcePassword); }
    return CryptoEngine.decrypt(cipher, resourcePassword.substring(endIdx + 1));
  }
}
origin: org.mule.btm/mule-btm

KeySpec keySpec = loadKeySpec(CRYPTO_PASSWORD.getBytes(), cipher);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(cipher);
SecretKey secretKey = keyFactory.generateSecret(keySpec);
origin: bitronix/btm

public void testBuildXAFactory() throws Exception {
  ResourceBean rb = new ResourceBean() {};
  rb.setMaxPoolSize(1);
  rb.setClassName(MockitoXADataSource.class.getName());
  rb.getDriverProperties().setProperty("userName", "java");
  rb.getDriverProperties().setProperty("password", "{DES}" + CryptoEngine.crypt("DES", "java"));
  XAPool<DummyResourceHolder, DummyStatefulHolder> xaPool = new XAPool<DummyResourceHolder, DummyStatefulHolder>(null, rb, null);
  assertEquals(0, xaPool.totalPoolSize());
  assertEquals(0, xaPool.inPoolSize());
  MockitoXADataSource xads = (MockitoXADataSource) xaPool.getXAFactory();
  assertEquals("java", xads.getUserName());
  assertEquals("java", xads.getPassword());
}
origin: com.github.marcus-nl.btm/btm

public void testBuildXAFactory() throws Exception {
  ResourceBean rb = new ResourceBean() {};
  rb.setMaxPoolSize(1);
  rb.setClassName(MockitoXADataSource.class.getName());
  rb.getDriverProperties().setProperty("userName", "java");
  rb.getDriverProperties().setProperty("password", "{DES}" + CryptoEngine.crypt("DES", "java"));
  XAPool<DummyResourceHolder, DummyStatefulHolder> xaPool = new XAPool<DummyResourceHolder, DummyStatefulHolder>(null, rb, null);
  assertEquals(0, xaPool.totalPoolSize());
  assertEquals(0, xaPool.inPoolSize());
  MockitoXADataSource xads = (MockitoXADataSource) xaPool.getXAFactory();
  assertEquals("java", xads.getUserName());
  assertEquals("java", xads.getPassword());
}
bitronix.tm.utilsCryptoEngine

Javadoc

Simple crypto helper that uses symetric keys to crypt and decrypt resources passwords.

Most used methods

  • crypt
    Crypt the given data using the given cipher. The crypted result is base64-encoded before it is retur
  • decrypt
    Decrypt using the given cipher the given base64-encoded, crypted data.
  • loadKeySpec

Popular in Java

  • Start an intent from android
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getExternalFilesDir (Context)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Collectors (java.util.stream)
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now