Package org.apache.openejb.cipher

Examples of org.apache.openejb.cipher.PasswordCipher


                return super.dataSource;
            }

            // check password codec if available
            if (null != passwordCipher) {
                final PasswordCipher cipher = PasswordCipherFactory.getPasswordCipher(passwordCipher);
                final 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) {
                final PasswordCipher cipher = PasswordCipherFactory.getPasswordCipher(passwordCipher);
                final String plainPwd = cipher.decrypt(password.toCharArray());

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

        if (passwordCipher != null && "PlainText".equals(passwordCipher)) { // no need to warn about it
            properties.remove("PasswordCipher");
        } else {
            final String password = properties.getProperty("Password");
            if (passwordCipher != null) {
                final PasswordCipher cipher = PasswordCipherFactory.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

            help(options);
            return;
        }

        try {
            final PasswordCipher cipher = PasswordCipherFactory.getPasswordCipher(cipherName);

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

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

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

            help(options);
            return;
        }

        try {
            final PasswordCipher cipher = PasswordCipherFactory.getPasswordCipher(cipherName);

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

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

        } catch (final RuntimeException 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() {
        final 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() {
        final PasswordCipher cipher = new StaticDESPasswordCipher();
        final char[] tmp = cipher.encrypt(PLAIN_PWD);
        assertEquals(PLAIN_PWD, cipher.decrypt(tmp));
    }
View Full Code Here

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

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

public class PasswordCodecTest extends TestCase {

    private static final String PLAIN_PWD = "david";

    public void testPlainCodec() {
        final 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() {
        final PasswordCipher cipher = new StaticDESPasswordCipher();
        final char[] tmp = cipher.encrypt(PLAIN_PWD);
        assertEquals(PLAIN_PWD, cipher.decrypt(tmp));
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.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.