本文整理了Java中java.security.Provider.getServices()
方法的一些代码示例,展示了Provider.getServices()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Provider.getServices()
方法的具体详情如下:
包路径:java.security.Provider
类名称:Provider
方法名:getServices
[英]Returns an unmodifiable Set of all services registered by this provider.
[中]返回此提供程序注册的所有服务的不可修改集。
代码示例来源:origin: stackoverflow.com
for (Provider p: Security.getProviders()) p.getServices().forEach(System.out::println);
代码示例来源:origin: stackoverflow.com
Provider[] providers = Security.getProviders();
for (Provider provider : providers) {
Log.i("CRYPTO","provider: "+provider.getName());
Set<Provider.Service> services = provider.getServices();
for (Provider.Service service : services) {
Log.i("CRYPTO"," algorithm: "+service.getAlgorithm());
}
}
代码示例来源:origin: stackoverflow.com
import java.security.Provider;
import java.security.Security;
public class SecurityListings {
public static void main(String[] args) {
for (Provider provider : Security.getProviders()) {
System.out.println("Provider: " + provider.getName());
for (Provider.Service service : provider.getServices()) {
System.out.println(" Algorithm: " + service.getAlgorithm());
}
}
}
}
代码示例来源:origin: robovm/robovm
/**
* Get the service of the specified type
*
*/
synchronized Provider.Service getService(String type) {
updatePropertyServiceTable();
if (lastServicesByType != null && type.equals(lastType)) {
return lastServicesByType;
}
Provider.Service service;
for (Iterator<Service> it = getServices().iterator(); it.hasNext();) {
service = it.next();
if (type.equals(service.type)) {
lastType = type;
lastServicesByType = service;
return service;
}
}
return null;
}
代码示例来源:origin: wildfly/wildfly
/**
* Find a provider service which matches the given predicate.
*
* @param providerSupplier the provider supplier
* @param matchPredicate the predicate to test
* @return the provider service, or {@code null} if none is found
*/
public static Provider.Service findProviderService(Supplier<Provider[]> providerSupplier, Predicate<Provider.Service> matchPredicate) {
Assert.checkNotNullParam("providerSupplier", providerSupplier);
Assert.checkNotNullParam("matchPredicate", matchPredicate);
for (Provider provider : providerSupplier.get()) {
for (Provider.Service service : provider.getServices()) {
if (matchPredicate.test(service)) {
return service;
}
}
}
return null;
}
代码示例来源:origin: robovm/robovm
/**
* Adds information about provider services into HashMap.
*/
public static synchronized void initServiceInfo(Provider p) {
for (Provider.Service service : p.getServices()) {
String type = service.getType();
if (cachedSecureRandomService == null && type.equals("SecureRandom")) {
cachedSecureRandomService = service;
}
String key = type + "." + service.getAlgorithm().toUpperCase(Locale.US);
if (!services.containsKey(key)) {
services.put(key, service);
}
for (String alias : Engine.door.getAliases(service)) {
key = type + "." + alias.toUpperCase(Locale.US);
if (!services.containsKey(key)) {
services.put(key, service);
}
}
}
}
代码示例来源:origin: robovm/robovm
/**
* Returns a {@code Set} of all registered algorithms for the specified
* cryptographic service. {@code "Signature"}, {@code "Cipher"} and {@code
* "KeyStore"} are examples for such kind of services.
*
* @param serviceName
* the case-insensitive name of the service.
* @return a {@code Set} of all registered algorithms for the specified
* cryptographic service, or an empty {@code Set} if {@code
* serviceName} is {@code null} or if no registered provider
* provides the requested service.
*/
public static Set<String> getAlgorithms(String serviceName) {
Set<String> result = new HashSet<String>();
// compatibility with RI
if (serviceName == null) {
return result;
}
for (Provider provider : getProviders()) {
for (Provider.Service service: provider.getServices()) {
if (service.getType().equalsIgnoreCase(serviceName)) {
result.add(service.getAlgorithm());
}
}
}
return result;
}
代码示例来源:origin: wildfly/wildfly
/**
* @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#getMechanismNames(java.util.Map)
*/
@Override
public String[] getMechanismNames(Map<String, ?> properties) {
Set<String> names = new LinkedHashSet<>();
for (Provider current : providerSupplier.get()) {
Set<Service> services = current.getServices();
if (services != null) {
for (Service currentService : services) {
if (SERVICE_TYPE.equals(currentService.getType())) {
try {
String[] serviceMechNames = ((HttpServerAuthenticationMechanismFactory) currentService.newInstance(null)).getMechanismNames(properties);
Collections.addAll(names, serviceMechNames);
} catch (NoSuchAlgorithmException e) {
log.debug("Unable to create instance", e);
}
}
}
}
}
if (names.size() == 0 && log.isTraceEnabled()) {
log.tracef("No %s provided by provider loader in %s: %s", SERVICE_TYPE, getClass().getSimpleName(), Arrays.toString(providerSupplier.get()));
}
return names.toArray(new String[names.size()]);
}
代码示例来源:origin: wildfly/wildfly
@Override
public String[] getMechanismNames(final Map<String, ?> props) {
final BiPredicate<String, Provider> mechFilter = SaslFactories.getProviderFilterPredicate(props);
final Set<String> names = new LinkedHashSet<>();
for (Provider currentProvider : providerSupplier.get()) {
Set<Service> services = currentProvider.getServices();
if (services != null) {
for (Service service : services) {
if (SERVICE_TYPE.equals(service.getType())) {
try {
final String[] mechanismNames = ((SaslServerFactory) service.newInstance(null)).getMechanismNames(props);
Collections.addAll(names, SaslFactories.filterMechanismsByProvider(mechanismNames, 0, 0, currentProvider, mechFilter));
} catch (NoSuchAlgorithmException | ClassCastException | InvalidParameterException e) {
log.debug("Unable to create instance", e);
}
}
}
}
}
if (names.size() == 0 && log.isTraceEnabled()) {
log.tracef("No %s provided by provider supplier in %s: %s", SERVICE_TYPE, getClass().getSimpleName(), Arrays.toString(providerSupplier.get()));
}
return names.toArray(new String[names.size()]);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public String[] getMechanismNames(final Map<String, ?> props) {
final BiPredicate<String, Provider> mechFilter = SaslFactories.getProviderFilterPredicate(props);
final Set<String> names = new LinkedHashSet<>();
for (Provider currentProvider : providerSupplier.get()) {
Set<Service> services = currentProvider.getServices();
if (services != null) {
for (Service service : services) {
if (SERVICE_TYPE.equals(service.getType())) {
try {
final String[] mechanismNames = ((SaslClientFactory) service.newInstance(null)).getMechanismNames(props);
Collections.addAll(names, SaslFactories.filterMechanismsByProvider(mechanismNames, 0, 0, currentProvider, mechFilter));
} catch (NoSuchAlgorithmException | ClassCastException | InvalidParameterException e) {
log.debug("Unable to create instance", e);
}
}
}
}
}
if (names.size() == 0 && log.isTraceEnabled()) {
log.tracef("No %s provided by providers in %s: %s", SERVICE_TYPE, getClass().getSimpleName(), Arrays.toString(providerSupplier.get()));
}
return names.toArray(new String[names.size()]);
}
}
代码示例来源:origin: wildfly/wildfly
/**
* @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#createAuthenticationMechanism(java.lang.String, java.util.Map, javax.security.auth.callback.CallbackHandler)
*/
@Override
public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map<String, ?> properties, CallbackHandler callbackHandler) throws HttpAuthenticationException {
for (Provider current : providerSupplier.get()) {
Set<Service> services = current.getServices();
if (services != null) {
for (Service currentService : services) {
if (SERVICE_TYPE.equals(currentService.getType())) {
try {
HttpServerAuthenticationMechanismFactory factory = (HttpServerAuthenticationMechanismFactory) currentService.newInstance(null);
HttpServerAuthenticationMechanism mechanism = factory.createAuthenticationMechanism(mechanismName, properties, callbackHandler);
if (mechanism != null) {
return mechanism;
}
} catch (NoSuchAlgorithmException e) {
log.debug("Unable to create instance", e);
}
}
}
}
}
if (log.isTraceEnabled()) {
log.tracef("No %s provided by provider loader in %s: %s", SERVICE_TYPE, getClass().getSimpleName(), Arrays.toString(providerSupplier.get()));
}
return null;
}
代码示例来源:origin: wildfly/wildfly
continue;
Set<Service> services = currentProvider.getServices();
if (services != null) {
for (Service service : currentProvider.getServices()) {
if (SERVICE_TYPE.equals(service.getType())) {
try {
代码示例来源:origin: wildfly/wildfly
Set<Service> services = currentProvider.getServices();
if (services != null) {
for (Provider.Service service : services) {
代码示例来源:origin: wildfly/wildfly
continue;
Set<Service> services = provider.getServices();
if (services != null) {
for (Provider.Service service : services) {
代码示例来源:origin: stackoverflow.com
import java.security.Provider;
import java.security.Security;
public class JceLook {
public static void main(String[] args) {
System.out.println("Algorithms Supported in this JCE.");
System.out.println("====================");
// heading
System.out.println("Provider: type.algorithm -> className" + "\n aliases:" + "\n attributes:\n");
// discover providers
Provider[] providers = Security.getProviders();
for (Provider provider : providers) {
System.out.println("<><><>" + provider + "<><><>\n");
// discover services of each provider
for (Provider.Service service : provider.getServices()) {
System.out.println(service);
}
System.out.println();
}
}
}
代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common
public Set<Service> getServices() {
Provider p = getProvider();
if (p != null) {
return p.getServices();
} else {
return Collections.emptySet();
}
}
代码示例来源:origin: io.skullabs.kikaha/kikaha-core
private void showAvailableSecurityProviders(){
HashSet<String> strings = new HashSet<>();
for ( Provider provider : Security.getProviders() ) {
for ( Provider.Service serviceProvider : provider.getServices() )
strings.add( serviceProvider.getAlgorithm() );
}
log.debug( "Available security provides: " + String.join( " " , strings ) );
}
代码示例来源:origin: stackoverflow.com
for (Provider provider : Security.getProviders()) {
for (Provider.Service service : provider.getServices()) {
System.out.println(provider.getName() + ": " + service.getType() + "." + service.getAlgorithm());
// check these values and find a best match
}
}
代码示例来源:origin: com.madgag.spongycastle/bctls-jdk15on
public synchronized final Set<Provider.Service> getServices()
{
Set<Provider.Service> serviceSet = super.getServices();
Set<Provider.Service> bcServiceSet = new HashSet<Provider.Service>();
for (Provider.Service service: serviceSet)
{
bcServiceSet.add(getService(service.getType(), service.getAlgorithm()));
}
return bcServiceSet;
}
代码示例来源:origin: stackoverflow.com
Provider[] providers = Security.getProviders();
for (Provider p : providers) {
String providerStr = String.format("%s/%s/%f\n", p.getName(),
p.getInfo(), p.getVersion());
Set<Service> services = p.getServices();
for (Service s : services) {
if ("MessageDigest".equals(s.getType())) {
System.out.printf("\t%s/%s/%s", s.getType(),
s.getAlgorithm(), s.getClassName());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!