All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.bdeploy.common.security.OnDiscKeyStore Maven / Gradle / Ivy

Go to download

Public API including dependencies, ready to be used for integrations and plugins.

There is a newer version: 7.3.6
Show newest version
package io.bdeploy.common.security;

import java.io.IOException;
import java.nio.file.Path;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.util.Arrays;

/**
 * Wraps around an actual (JCEKS) keystore on disc.
 *
 * @see SecurityHelper#loadPublicKeyStore(Path, char[])
 */
public class OnDiscKeyStore implements KeyStoreProvider {

    private final char[] pp;
    private final KeyStore ks;

    public OnDiscKeyStore(Path file, String passphrase) {
        this.pp = passphrase.toCharArray();
        try {
            this.ks = SecurityHelper.getInstance().loadPublicKeyStore(file, pp);
        } catch (GeneralSecurityException | IOException e) {
            throw new IllegalStateException("Cannot load keystore from " + file, e);
        }
    }

    @Override
    public KeyStore getStore() {
        return ks;
    }

    @Override
    public char[] getPass() {
        return Arrays.copyOf(pp, pp.length);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy