本文整理匯總了Java中java.security.Provider.Service方法的典型用法代碼示例。如果您正苦於以下問題:Java Provider.Service方法的具體用法?Java Provider.Service怎麽用?Java Provider.Service使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.security.Provider
的用法示例。
在下文中一共展示了Provider.Service方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: listCiphers
import java.security.Provider; //導入方法依賴的package包/類
private static void listCiphers(Queue<String> arguments) {
for (Provider provider : Security.getProviders()) {
for (Provider.Service service : provider.getServices()) {
if (service.getType().equals("Cipher")) {
System.out.println("Provider: " + provider.getName() + " Algorithm: " + service.getAlgorithm());
}
}
}
}
示例2: getInstance
import java.security.Provider; //導入方法依賴的package包/類
/**
* Returns a RedactableSignature object that implements the specified redactable signature algorithm.
* <p>
* This method traverses the list of registered security Providers, starting with the most preferred Provider. A new
* RedactableSignature object encapsulating the RedactableSignatureSpi implementation from the first Provider that
* supports the specified algorithm is returned.
* <p>
* Note that the list of registered providers may be retrieved via the <code>Security.getProviders()</code> method.
*
* @param algorithm the name of the requested algorithm
* @return a new RedactableSignature object.
* @throws NoSuchAlgorithmException if no Provider supports a RedactableSignature implementation for the specified
* algorithm.
*/
public static RedactableSignature getInstance(String algorithm) throws NoSuchAlgorithmException {
NoSuchAlgorithmException failure = new NoSuchAlgorithmException(algorithm +
"RedactableSignature not available");
List<Provider.Service> services = GetInstance.getServices(TYPE, algorithm);
for (Provider.Service service : services) {
try {
GetInstance.Instance instance = GetInstance.getInstance(service, RedactableSignatureSpi.class);
return getInstance(instance, algorithm);
} catch (NoSuchAlgorithmException e) {
failure = e;
}
}
throw failure;
}
示例3: getInstance
import java.security.Provider; //導入方法依賴的package包/類
/**
* Returns a RedactableXMLSignature object that implements the specified redactable signature algorithm.
* <p>
* This method traverses the list of registered security Providers, starting with the most preferred Provider. A new
* RedactableXMLSignature object encapsulating the RedactableXMLSignatureSpi implementation from the first Provider
* that supports the specified algorithm is returned.
* <p>
* Note that the list of registered providers may be retrieved via the <code>Security.getProviders()</code> method.
*
* @param algorithm the name of the requested algorithm
* @return a new RedactableXMLSignature object.
* @throws NoSuchAlgorithmException if no Provider supports a RedactableXMLSignature implementation for the
* specified algorithm.
*/
public static RedactableXMLSignature getInstance(String algorithm) throws NoSuchAlgorithmException {
NoSuchAlgorithmException failure = new NoSuchAlgorithmException(algorithm
+ " RedactableXMLSignature not available");
List<Provider.Service> services = GetInstance.getServices(TYPE, algorithm);
for (Provider.Service service : services) {
try {
GetInstance.Instance instance = GetInstance.getInstance(service, RedactableXMLSignatureSpi.class);
return getInstance(instance, algorithm);
} catch (NoSuchAlgorithmException e) {
failure = e;
}
}
throw failure;
}
示例4: getSecureRandom
import java.security.Provider; //導入方法依賴的package包/類
static SecureRandom getSecureRandom() throws KeyManagementException {
if (cryptoProvider == null) {
return new SecureRandom();
}
// Try "PKCS11" first. If that is not supported, iterate through
// the provider and return the first working implementation.
try {
return SecureRandom.getInstance("PKCS11", cryptoProvider);
} catch (NoSuchAlgorithmException e) {
// ignore
}
for (Provider.Service s : cryptoProvider.getServices()) {
if (s.getType().equals("SecureRandom")) {
try {
return SecureRandom.getInstance(s.getAlgorithm(), cryptoProvider);
} catch (NoSuchAlgorithmException ee) {
// ignore
}
}
}
throw new KeyManagementException("FIPS mode: no SecureRandom "
+ " implementation found in provider " + cryptoProvider.getName());
}
示例5: main
import java.security.Provider; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
for (Provider p : Security.getProviders()) {
for (Provider.Service s : p.getServices()) {
if (s.getType().equals("SecureRandom") &&
!s.getAlgorithm().contains("Block")) {
test(SecureRandom.getInstance(s.getAlgorithm(), p));
}
}
}
Security.setProperty("securerandom.drbg.config", "HMAC_DRBG");
test(SecureRandom.getInstance("DRBG"));
Security.setProperty("securerandom.drbg.config", "CTR_DRBG");
test(SecureRandom.getInstance("DRBG"));
}
示例6: getInstance
import java.security.Provider; //導入方法依賴的package包/類
/**
* Returns an Accumulator object that implements the specified accumulator algorithm.
* <p>
* This method traverses the list of registered security Providers, starting with the most preferred Provider. A new
* Accumulator object encapsulating the AccumulatorSpi implementation from the first Provider that supports the
* specified algorithm is returned.
* <p>
* Note that the list of registered providers may be retrieved via the <code>Security.getProviders()</code> method.
*
* @param algorithm the name of the requested algorithm
* @return a new Accumulator object
* @throws NoSuchAlgorithmException if no Provider supports an Accumulator implementation for the specified
* algorithm
*/
public static Accumulator getInstance(String algorithm) throws NoSuchAlgorithmException {
NoSuchAlgorithmException failure = new NoSuchAlgorithmException(algorithm + "Accumulator not available");
List<Provider.Service> services = GetInstance.getServices("Accumulator", algorithm);
for (Provider.Service service : services) {
try {
GetInstance.Instance instance = GetInstance.getInstance(service, AccumulatorSpi.class);
return getInstance(instance, algorithm);
} catch (NoSuchAlgorithmException e) {
failure = e;
}
}
throw failure;
}
示例7: listKeyGenerators
import java.security.Provider; //導入方法依賴的package包/類
private static void listKeyGenerators(Queue<String> arguments) {
for (Provider provider : Security.getProviders()) {
for (Provider.Service service : provider.getServices()) {
if (service.getType().equals("KeyGenerator")) {
System.out.println("Provider: " + provider.getName() + " Algorithm: " + service.getAlgorithm());
}
}
}
}
示例8: getSupportedAlgorithms
import java.security.Provider; //導入方法依賴的package包/類
/**
* Returns supported algorithms of specified type.
*/
static List<String> getSupportedAlgorithms(String type, String alg,
Provider p) {
// prepare a list of supported algorithms
List<String> algorithms = new ArrayList<>();
Set<Provider.Service> services = p.getServices();
for (Provider.Service service : services) {
if (service.getType().equals(type)
&& service.getAlgorithm().startsWith(alg)) {
algorithms.add(service.getAlgorithm());
}
}
return algorithms;
}