Package org.apache.openejb.resource.jdbc.cipher

Examples of org.apache.openejb.resource.jdbc.cipher.PasswordCipher


                throw new SQLException(message, t);
            }
        }

        // Create an instance
        PasswordCipher cipher;
        try {
            cipher = pwdCipher.newInstance();
        } catch (Throwable t) {
            String message = "Cannot create password cipher instance";
            throw new SQLException(message, t);
View Full Code Here


                return super.dataSource;
            }

            // check password codec if available
            if (null != passwordCipher) {
                PasswordCipher cipher = BasicDataSourceUtil.getPasswordCipher(passwordCipher);
                String plainPwd = cipher.decrypt(password.toCharArray());

                // override previous password value
                super.setPassword(plainPwd);
            }
View Full Code Here

                return super.dataSource;
            }

            // check password codec if available
            if (null != passwordCipher) {
                PasswordCipher cipher = BasicDataSourceUtil.getPasswordCipher(passwordCipher);
                String plainPwd = cipher.decrypt(password.toCharArray());

                // override previous password value
                super.setPassword(plainPwd);
            }
View Full Code Here

            help(options);
            return;
        }

        try {
            PasswordCipher cipher = BasicDataSourceUtil.getPasswordCipher(cipherName);

            if (line.hasOption("decrypt")) {
                String pwdArg = (String) line.getArgList().get(0);
                char[] encryptdPassword = pwdArg.toCharArray();
                System.out.println(cipher.decrypt(encryptdPassword));

            } else { // if option neither encrypt/decrypt is specified, we assume
                     // it is encrypt.
                String plainPassword = (String) line.getArgList().get(0);
                System.out.println(new String(cipher.encrypt(plainPassword)));
            }

        } catch (SQLException e) {
            System.out.println("Could not load password cipher implementation class. Check your classpath.");
View Full Code Here

public class PasswordCodecTest extends TestCase {
 
  private static final String PLAIN_PWD = "david";
 
    public void testPlainCodec() {
      PasswordCipher cipher = new PlainTextPasswordCipher();
      assertEquals(PLAIN_PWD, new String(cipher.encrypt(PLAIN_PWD)));
      assertEquals(PLAIN_PWD, cipher.decrypt(PLAIN_PWD.toCharArray()));
    }
View Full Code Here

      assertEquals(PLAIN_PWD, new String(cipher.encrypt(PLAIN_PWD)));
      assertEquals(PLAIN_PWD, cipher.decrypt(PLAIN_PWD.toCharArray()));
    }
 
  public void testStaticDesCodec() {
    PasswordCipher cipher = new StaticDESPasswordCipher();
    char[] tmp = cipher.encrypt(PLAIN_PWD);
    assertEquals(PLAIN_PWD, cipher.decrypt(tmp));
    }
View Full Code Here

        // try the FQN of the target codec
        assertNotNull(BasicDataSourceUtil.getPasswordCipher(PlainTextPasswordCipher.class.getName()));
    }

    private void assertPluginClass(String pluginName, Class<? extends PasswordCipher> pluginClass) throws SQLException {
        PasswordCipher plugin = BasicDataSourceUtil.getPasswordCipher(pluginName);
        assertNotNull(plugin);
        assertSame(pluginClass, plugin.getClass());
    }
View Full Code Here

            properties.remove("PasswordCipher");
        } else {
            String password = properties.getProperty("Password");
            if (passwordCipher != null) {
                try {
                    final PasswordCipher cipher = BasicDataSourceUtil.getPasswordCipher(passwordCipher);
                    final String plainPwd = cipher.decrypt(password.toCharArray());
                    converted.setProperty("password", plainPwd);

                    // all went fine so remove it to avoid errors later
                    properties.remove("PasswordCipher");
                    properties.remove("Password");
View Full Code Here

                return super.dataSource;
            }

            // check password codec if available
            if (null != passwordCipher) {
                PasswordCipher cipher = BasicDataSourceUtil.getPasswordCipher(passwordCipher);
                String plainPwd = cipher.decrypt(password.toCharArray());

                // override previous password value
                super.setPassword(plainPwd);
            }
View Full Code Here

                return super.dataSource;
            }

            // check password codec if available
            if (null != passwordCipher) {
                PasswordCipher cipher = BasicDataSourceUtil.getPasswordCipher(passwordCipher);
                String plainPwd = cipher.decrypt(password.toCharArray());

                // override previous password value
                super.setPassword(plainPwd);
            }
View Full Code Here

TOP

Related Classes of org.apache.openejb.resource.jdbc.cipher.PasswordCipher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.