code: public static synchronized int insertProviderAt(Provider provider,
              int position) {
          String providerName = provider.getName();
          check("insertProvider." + providerName);
          ProviderList list = Providers.getFullProviderList();
          ProviderList newList = ProviderList.insertAt(list, provider, position - 1);
          if (list == newList) {
              return -1;
          }
          increaseVersion();
          Providers.setProviderList(newList);
          return newList.getIndex(providerName) + 1;
      }
docs: Adds a new provider, at a specified position. The position is
  the preference order in which providers are searched for
  requested algorithms.  The position is 1-based, that is,
  1 is most preferred, followed by 2, and so on.
  
  <p>If the given provider is installed at the requested position,
  the provider that used to be at that position, and all providers
  with a position greater than <code>position</code>, are shifted up
  one position (towards the end of the list of installed providers).
  
  <p>A provider cannot be added if it is already installed.
  
  <p>First, if there is a security manager, its
  <code>checkSecurityAccess</code>
  method is called with the string
  <code>"insertProvider."+provider.getName()</code>
  to see if it's ok to add a new provider.
  If the default implementation of <code>checkSecurityAccess</code>
  is used (i.e., that method is not overriden), then this will result in
  a call to the security manager's <code>checkPermission</code> method
  with a
  <code>SecurityPermission("insertProvider."+provider.getName())</code>
  permission.
  
  @param provider the provider to be added.
  
  @param position the preference position that the caller would
  like for this provider.
  
  @return the actual preference position in which the provider was
  added, or -1 if the provider was not added because it is
  already installed.
  
  @throws  NullPointerException if provider is null
  @throws  SecurityException
  if a security manager exists and its <code>{@link
  java.lang.SecurityManager#checkSecurityAccess}</code> method
  denies access to add a new provider
  
  @see #getProvider
  @see #removeProvider
  @see java.security.SecurityPermission