Top Description Inners Fields Constructors Methods
sun.security.jca

public final Class ProviderList

extends Object
Class Inheritance
Imports
java.util.*, java.security.AccessController, .PrivilegedAction, .Provider, .Provider.Service, .Security

List of Providers. Used to represent the provider preferences. The system starts out with a ProviderList that only has the names of the Providers. When using ServiceLoader to load the providers, Providers are created semi-eagerly as we iterate through them looking for a match. For compatibility reasons, Providers that could not be loaded are ignored and internally presented as the instance EMPTY_PROVIDER. However, those objects cannot be presented to applications. Call the convert() method to force all Providers to be loaded and to obtain a ProviderList with invalid entries removed. All this is handled by the Security class. Note that all indices used by this class are 0-based per general Java convention. These must be converted to the 1-based indices used by the Security class externally when needed. Instances of this class are immutable. This eliminates the need for cloning and synchronization in consumers. The add() and remove() style methods are static in order to avoid confusion about the immutability.
Author
Andreas Sterbenz
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
pack-priv static class
private class
ProviderList.ServiceIterator

Inner class for an iterator over Services.

Field Summary

Modifier and TypeField and Description
private volatile boolean
private final ProviderConfig[]
pack-priv static final Debug
pack-priv static final ProviderList
private static final Provider
private static final String[]
private static final String[]
private static final Provider[]
private static final ProviderConfig[]
private static ProviderList.PreferredList
private static final String[]
private static final String[]
private static final String[]
private static final String[]
private static final String[]
private final List<Provider>

Constructor Summary

AccessConstructor and Description
private
ProviderList(ProviderConfig[] configs, boolean allLoaded)

Create a new ProviderList from an array of configs

private
ProviderList()

Return a new ProviderList parsed from the java.security Properties.

Method Summary

Modifier and TypeMethod and Description
public static ProviderList
add(ProviderList providerList, Provider p)

pack-priv static ProviderList
public int
getIndex(String name)

Return the index at which the provider with the specified name is installed or -1 if it is not present in this ProviderList.

pack-priv ProviderList
getJarList(String[] jarProvNames)

Construct a special ProviderList for JAR verification.

pack-priv Provider
getProvider(int index)

Return the Provider at the specified index.

public Provider
private ProviderConfig
public Provider.Service
getService(String type, String name)

Return a Service describing an implementation of the specified algorithm from the Provider with the highest precedence that supports that algorithm.

public Iterator<Provider.Service>
getServices(String type, String algorithm)

Return an iterator over all the Services describing implementations of the specified algorithms in precedence order.

public Iterator<Provider.Service>
public static ProviderList
insertAt(ProviderList providerList, Provider p, int position)

private int
public static ProviderList
newList(Provider... providers)

public List<Provider>
providers()

Return an unmodifiable List of all Providers in this List.

public static ProviderList
remove(ProviderList providerList, String name)

pack-priv ProviderList
removeInvalid()

Try to load all Providers and return the ProviderList.

public int
size()

public Provider[]
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

allLoadedback to summary
private volatile boolean allLoaded
configsback to summary
private final ProviderConfig[] configs
debugback to summary
pack-priv static final Debug debug
EMPTYback to summary
pack-priv static final ProviderList EMPTY
EMPTY_PROVIDERback to summary
private static final Provider EMPTY_PROVIDER
HMACSHA2_GROUPback to summary
private static final String[] HMACSHA2_GROUP
HMACSHA3_GROUPback to summary
private static final String[] HMACSHA3_GROUP
P0back to summary
private static final Provider[] P0
PC0back to summary
private static final ProviderConfig[] PC0
preferredPropListback to summary
private static ProviderList.PreferredList preferredPropList
SHA2_GROUPback to summary
private static final String[] SHA2_GROUP
SHA2DSA_GROUPback to summary
private static final String[] SHA2DSA_GROUP
SHA2ECDSA_GROUPback to summary
private static final String[] SHA2ECDSA_GROUP
SHA2RSA_GROUPback to summary
private static final String[] SHA2RSA_GROUP
SHA3_GROUPback to summary
private static final String[] SHA3_GROUP
userListback to summary
private final List<Provider> userList

Constructor Detail

ProviderListback to summary
private ProviderList(ProviderConfig[] configs, boolean allLoaded)

Create a new ProviderList from an array of configs

ProviderListback to summary
private ProviderList()

Return a new ProviderList parsed from the java.security Properties.

Method Detail

addback to summary
public static ProviderList add(ProviderList providerList, Provider p)
fromSecurityPropertiesback to summary
pack-priv static ProviderList fromSecurityProperties()
Annotations
@SuppressWarnings:removal
getIndexback to summary
public int getIndex(String name)

Return the index at which the provider with the specified name is installed or -1 if it is not present in this ProviderList.

getJarListback to summary
pack-priv ProviderList getJarList(String[] jarProvNames)

Construct a special ProviderList for JAR verification. It consists of the providers specified via jarClassNames, which must be on the bootclasspath and cannot be in signed JAR files. This is to avoid possible recursion and deadlock during verification.

getProviderback to summary
pack-priv Provider getProvider(int index)

Return the Provider at the specified index. Returns EMPTY_PROVIDER if the provider could not be loaded at this time.

getProviderback to summary
public Provider getProvider(String name)
getProviderConfigback to summary
private ProviderConfig getProviderConfig(String name)
getServiceback to summary
public Provider.Service getService(String type, String name)

Return a Service describing an implementation of the specified algorithm from the Provider with the highest precedence that supports that algorithm. Return null if no Provider supports this algorithm.

getServicesback to summary
public Iterator<Provider.Service> getServices(String type, String algorithm)

Return an iterator over all the Services describing implementations of the specified algorithms in precedence order. If no implementation exists, this method returns an empty iterator. The elements of this iterator are determined lazily on demand. The iterator returned is NOT thread safe.

getServicesback to summary
public Iterator<Provider.Service> getServices(List<ServiceId> ids)
insertAtback to summary
public static ProviderList insertAt(ProviderList providerList, Provider p, int position)
loadAllback to summary
private int loadAll()
newListback to summary
public static ProviderList newList(Provider... providers)
providersback to summary
public List<Provider> providers()

Return an unmodifiable List of all Providers in this List. The individual Providers are loaded on demand. Elements that could not be initialized are replaced with EMPTY_PROVIDER.

removeback to summary
public static ProviderList remove(ProviderList providerList, String name)
removeInvalidback to summary
pack-priv ProviderList removeInvalid()

Try to load all Providers and return the ProviderList. If one or more Providers could not be loaded, a new ProviderList with those entries removed is returned. Otherwise, the method returns this.

sizeback to summary
public int size()
toArrayback to summary
public Provider[] toArray()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

sun.security.jca back to summary

private Class ProviderList.PreferredEntry

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final String
private final String[]
private boolean
private final String
private final String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
private String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

algorithmback to summary
private final String algorithm
alternateNamesback to summary
private final String[] alternateNames
groupback to summary
private boolean group
providerback to summary
private final String provider
typeback to summary
private final String type

Constructor Detail

PreferredEntryback to summary
pack-priv PreferredEntry(String t, String p)

Method Detail

matchback to summary
pack-priv boolean match(String t, String a)
printback to summary
private String print(String t, String a, String p)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

sun.security.jca back to summary

pack-priv final Class ProviderList.PreferredList

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv ArrayList<ProviderList.PreferredEntry>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
public ProviderList.PreferredEntry
get(int i)

pack-priv ArrayList<ProviderList.PreferredEntry>
pack-priv ArrayList<ProviderList.PreferredEntry>
getAll(String type, String algorithm)

private void
public int
size()

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

listback to summary
pack-priv ArrayList<ProviderList.PreferredEntry> list

Constructor Detail

PreferredListback to summary
pack-priv PreferredList()

Method Detail

addback to summary
public boolean add(ProviderList.PreferredEntry e)
getback to summary
public ProviderList.PreferredEntry get(int i)
getAllback to summary
pack-priv ArrayList<ProviderList.PreferredEntry> getAll(ProviderList.ServiceIterator s)
getAllback to summary
pack-priv ArrayList<ProviderList.PreferredEntry> getAll(String type, String algorithm)
implGetAllback to summary
private void implGetAll(ArrayList<ProviderList.PreferredEntry> l, String type, String algorithm)
sizeback to summary
public int size()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

sun.security.jca back to summary

private final Class ProviderList.ServiceIterator

extends Object
implements Iterator<Provider.Service>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Inner class for an iterator over Services. Customized implementation in order to delay Provider initialization and lookup. Not thread safe.

Field Summary

Modifier and TypeField and Description
private final String
private Provider.Service
private final List<ServiceId>
pack-priv int
private int
pack-priv ArrayList<ProviderList.PreferredEntry>
private int
private List<Provider.Service>
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
ServiceIterator(String type, String algorithm)

pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public Provider.Service
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

private Provider.Service
tryGet(int index)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmback to summary
private final String algorithm
firstServiceback to summary
private Provider.Service firstService
idsback to summary
private final List<ServiceId> ids
indexback to summary
pack-priv int index
preferredIndexback to summary
private int preferredIndex
preferredListback to summary
pack-priv ArrayList<ProviderList.PreferredEntry> preferredList
providerIndexback to summary
private int providerIndex
servicesback to summary
private List<Provider.Service> services
typeback to summary
private final String type

Constructor Detail

ServiceIteratorback to summary
pack-priv ServiceIterator(String type, String algorithm)
ServiceIteratorback to summary
pack-priv ServiceIterator(List<ServiceId> ids)

Method Detail

addServiceback to summary
private void addService(Provider.Service s)
hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public Provider.Service next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Provider.Service

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

Annotations
@Override
tryGetback to summary
private Provider.Service tryGet(int index)