Search in sources :

Example 1 with PasswordReader

use of com.quorum.tessera.passwords.PasswordReader in project tessera by ConsenSys.

the class KeyUpdateCommandFactory method create.

@Override
public <K> K create(Class<K> cls) throws Exception {
    try {
        if (cls != KeyUpdateCommand.class) {
            throw new RuntimeException(this.getClass().getSimpleName() + " cannot create instance of type " + cls.getSimpleName());
        }
        KeyEncryptorFactory keyEncryptorFactory = KeyEncryptorFactory.newFactory();
        PasswordReader passwordReader = PasswordReaderFactory.create();
        return (K) new KeyUpdateCommand(keyEncryptorFactory, passwordReader);
    } catch (Exception e) {
        // fallback if missing
        return CommandLine.defaultFactory().create(cls);
    }
}
Also used : PasswordReader(com.quorum.tessera.passwords.PasswordReader) KeyEncryptorFactory(com.quorum.tessera.config.keys.KeyEncryptorFactory)

Example 2 with PasswordReader

use of com.quorum.tessera.passwords.PasswordReader in project tessera by ConsenSys.

the class FileKeyGeneratorTest method init.

@Before
public void init() {
    this.keyPair = new KeyPair(PublicKey.from(PUBLIC_KEY.getBytes(UTF_8)), PrivateKey.from(PRIVATE_KEY.getBytes(UTF_8)));
    this.encryptor = mock(Encryptor.class);
    this.keyEncryptor = mock(KeyEncryptor.class);
    this.passwordReader = mock(PasswordReader.class);
    when(passwordReader.requestUserPassword()).thenReturn(new char[0]);
    this.generator = new FileKeyGenerator(encryptor, keyEncryptor, passwordReader);
}
Also used : KeyPair(com.quorum.tessera.encryption.KeyPair) FilesystemKeyPair(com.quorum.tessera.config.keypairs.FilesystemKeyPair) PasswordReader(com.quorum.tessera.passwords.PasswordReader) KeyEncryptor(com.quorum.tessera.config.keys.KeyEncryptor) Encryptor(com.quorum.tessera.encryption.Encryptor) KeyEncryptor(com.quorum.tessera.config.keys.KeyEncryptor) Before(org.junit.Before)

Aggregations

PasswordReader (com.quorum.tessera.passwords.PasswordReader)2 FilesystemKeyPair (com.quorum.tessera.config.keypairs.FilesystemKeyPair)1 KeyEncryptor (com.quorum.tessera.config.keys.KeyEncryptor)1 KeyEncryptorFactory (com.quorum.tessera.config.keys.KeyEncryptorFactory)1 Encryptor (com.quorum.tessera.encryption.Encryptor)1 KeyPair (com.quorum.tessera.encryption.KeyPair)1 Before (org.junit.Before)1