Java如何获取加密安全提供程序
package org.nhooo.example.security;
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) {
//创建一个集合,以便我们获得独特的结果。
Set result = new HashSet();
//返回包含所有已安装的提供程序的数组。
Provider[] providers = Security.getProviders();
for (Provider provider : providers) {
//获取提供者的属性密钥
Set keys = provider.keySet();
for (Object key : keys) {
String data = (String) key;
data = data.split(" ")[0];
//服务类型以“Alg.Alias”字符串开头"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);
}
}
}我们的代码的示例结果:
Service Type = KeyFactoryService Type = TransformServiceService Type = CertPathBuilderService Type = CipherService Type = SecureRandomService Type = SignatureService Type = AlgorithmParameterGeneratorService Type = KeyPairGeneratorService Type = XMLSignatureFactoryService Type = CertificateFactoryService Type = MessageDigestService Type = KeyInfoFactoryService Type = KeyAgreementService Type = CertStoreService Type = ConfigurationService Type = SSLContextService Type = SaslServerFactoryService Type = AlgorithmParametersService Type = TrustManagerFactoryService Type = GssApiMechanismService Type = TerminalFactoryService Type = MacService Type = KeyGeneratorService Type = PolicyService Type = CertPathValidatorService Type = SaslClientFactoryService Type = SecretKeyFactoryService Type = KeyManagerFactoryService Type = KeyStoreService Type = Provider
热门推荐
10 送花顾客祝福语简短的话
11 退休前辈文案祝福语简短
12 校长转岗祝福语大全简短
13 商业装修开工祝福语简短
14 粤语父母婚礼祝福语简短
15 温馨顺德婚礼祝福语简短
16 嘉宾姐姐出嫁祝福语简短
17 同学朋友吃饭祝福语简短
18 祝福语朋友简短恋爱结婚