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

usn.net.ssl.util.KeyStoreWrapper Maven / Gradle / Ivy

Go to download

A utility to add certs to the trust store from a connection attempt, originially written by Oracle

There is a newer version: 1.0.16
Show newest version
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package usn.net.ssl.util;

import java.io.File;
import java.security.KeyStore;

/**
 *
 * @author AO
 */
public class KeyStoreWrapper {

    private KeyStore store;
    private File keyStoreLocation;
    private char[] keyStorePassword;

    public KeyStore getStore() {
        return store;
    }

    public void clear() {

        for (int i = 0; i < keyStorePassword.length; i++) {
            keyStorePassword[i] = (char) 0;
        }
        keyStorePassword = null;
        keyStoreLocation = null;
    }

    public void setStore(KeyStore store) {
        this.store = store;
    }

    public File getKeyStoreLocation() {
        return keyStoreLocation;
    }

    public void setKeyStoreLocation(File keyStoreLocation) {
        this.keyStoreLocation = keyStoreLocation;
    }

    public char[] getKeyStorePassword() {
        return keyStorePassword;
    }

    public void setKeyStorePassword(char[] keyStorePassword) {
        this.keyStorePassword = keyStorePassword;
    }

    @Override
    public boolean equals(Object other) {
        if (other instanceof KeyStoreWrapper) {
            return keyStoreLocation.equals(((KeyStoreWrapper) other).keyStoreLocation);
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 41 * hash + (this.keyStoreLocation != null ? this.keyStoreLocation.hashCode() : 0);
        return hash;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy