Java Code Examples for java.security.Provider#propertyNames()

The following examples show how to use java.security.Provider#propertyNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DProviderInfo.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
private String[] getServiceAlgorithms(String serviceType, Provider provider) {
	/*
	 * Match provider property names that start "<service type>." and do not
	 * contain a space. What follows the '.' is the algorithm name
	 */
	String match = serviceType + ".";

	ArrayList<String> algorithmList = new ArrayList<String>();

	for (Enumeration<?> names = provider.propertyNames(); names.hasMoreElements();) {
		String key = (String) names.nextElement();

		if (key.startsWith(match) && key.indexOf(' ') == -1) {
			String algorithm = key.substring(key.indexOf('.') + 1);
			algorithmList.add(algorithm);
		}
	}

	String[] algorithms = algorithmList.toArray(new String[algorithmList.size()]);
	Arrays.sort(algorithms);

	return algorithms;
}
 
Example 2
Source File: DProviderInfo.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
private String getAlgorithmClass(String algorithm, String serviceType, Provider provider) {
	/*
	 * Looking for the property name that matches
	 * "<service type>.<algorithm>". The value of the property is the class
	 * name
	 */
	String match = serviceType + "." + algorithm;

	for (Enumeration<?> names = provider.propertyNames(); names.hasMoreElements();) {
		String key = (String) names.nextElement();

		if (key.equals(match)) {
			return provider.getProperty(key);
		}
	}

	return null;
}
 
Example 3
Source File: DProviderInfo.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
private String[] getAlgorithmAliases(String algorithm, String serviceType, Provider provider) {
	/*
	 * Looking to match property names with key "Alg.Alias.<service type>."
	 * and value of algorithm. The alias is the text following the '.' in
	 * the property name. Return in alpha order
	 */
	String matchAlias = "Alg.Alias." + serviceType + ".";

	ArrayList<String> aliasList = new ArrayList<String>();

	for (Enumeration<?> names = provider.propertyNames(); names.hasMoreElements();) {
		String key = (String) names.nextElement();

		if (provider.getProperty(key).equals(algorithm)) {
			if (key.startsWith(matchAlias)) {
				String alias = key.substring(matchAlias.length());
				aliasList.add(alias);
			}
		}
	}

	String[] aliases = aliasList.toArray(new String[aliasList.size()]);
	Arrays.sort(aliases);

	return aliases;
}