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

org.adorsys.psd2.pop.PrivateKeyReader Maven / Gradle / Ivy

There is a newer version: 2.2.3
Show newest version
package org.adorsys.psd2.pop;

import java.security.Key;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

public class PrivateKeyReader {

	public static List exportKeys(KeyStore keyStore, char[] keypass){
		List result = new ArrayList<>();
		try {
			Enumeration aliases = keyStore.aliases();
			while (aliases.hasMoreElements()) {
				String alias = aliases.nextElement();
				Key privateKey = keyStore.getKey(alias, keypass);
				if(privateKey!=null) result.add(privateKey);
			}
		} catch (UnrecoverableKeyException | KeyStoreException | NoSuchAlgorithmException e) {
			throw new IllegalStateException(e);
		}
		
		return result;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy