How to Print System Security Information in Java

import java.security.Provider;
import java.security.Security;
import java.util.Set;
import java.util.HashSet;

public class SecurityProvider {
public static void main(String[] args) {
//
// Create a set so that we can have a unique result.
//
Set result = new HashSet();

//
// Returns an array containing all the installed providers.
//
Provider[] providers = Security.getProviders();

for (Provider provider : providers) {

//
// Get provider’s property keys
//
Set keys = provider.keySet();
for (Object key : keys) {
String data = (String) key;
data = data.split(” “)[0];

//
// Service type started by the “Alg.Alias” string
//
if (data.startsWith(“Alg.Alias”)) {
data = data.substring(10);
}

data = data.substring(0, data.indexOf(‘.’));
result.add(data);
}
}

for (Object o : result) {
System.out.println(“Service Type = ” + o);
}
}
}

About ashokabhat

I am a C,C ,JAVA,Adobe Flex,.NET Programmer Currently working as a Software Developer
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s