모든 보안 공급자를 표시하는 간단한 Java 코드를 만들고 싶습니다.
import java.io.ObjectInputStream.GetField;
import java.security.Provider;
import java.security.Provider.Service;
import java.security.Security;
public class MainActivity {
public static void main(String[] args) {
System.out.println("Availble Providers are:");
Provider[] providerList = Security.getProviders();
for (int i = 0; i < providerList.length; i++) {
System.out.println("[" + (i + 1) + "] - Name: "
+ providerList[i].getName());
System.out.println("Information:\n" + providerList[i].getInfo());
System.out
.print("Here are all providers with types of service and algorithm provided:\n");
}
for (int i = 0; i < serviceList.length; i++) {
System.out.println("- Name: " + providerList[i].getName() + "\n");
System.out.print("Service Type: " + serviceList[i].getType()
+ "Algorithm: " + serviceList[i].getAlgorithm());
}
}
}
두 번째 for 루프 전에 서비스 유형과 알고리즘을 호출 할 수 있도록 서비스를 초기화해야합니다.
getServices
메서드를 호출 할 수 있도록 현재 공급자가 필요하므로 두 번째 루프가 첫 번째 루프 안에 있어야합니다 . 다음과 같은 것 :
import java.security.Provider;
import java.security.Provider.Service;
import java.security.Security;
import java.util.Set;
public class MainActivity
{
public static void main(String[] args)
{
Provider [] providerList = Security.getProviders();
for (Provider provider : providerList)
{
System.out.println("Name: " + provider.getName());
System.out.println("Information:\n" + provider.getInfo());
Set<Service> serviceList = provider.getServices();
for (Service service : serviceList)
{
System.out.println("Service Type: " + service.getType() + " Algorithm " + service.getAlgorithm());
}
}
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다