Class ComponentFactory<T extends Component>

java.lang.Object
com.sshtools.common.ssh.components.ComponentFactory<T>
All Implemented Interfaces:
Cloneable

public class ComponentFactory<T extends Component> extends Object implements Cloneable

A utility class used to store the available transport components and provide delimited listing as required in the key exchange initialization process.

Author:
Lee David Painter
  • Field Details

    • supported

      protected Map<String,ComponentInstanceFactory<? extends T extends Component>> supported
      The supported components stored in a Hashtable with a String key as the component name such as "3des-cbc" and a Class value storing the implementation class.
    • order

      protected List<String> order
  • Constructor Details

  • Method Details

    • changePositionofAlgorithm

      public String changePositionofAlgorithm(String name, int position) throws SshException
      Throws:
      SshException
    • names

      public Collection<String> names()
    • order

      public void order(String csv) throws SshException
      Throws:
      SshException
    • order

      public String order(String[] ordering) throws SshException
      Throws:
      SshException
    • createNewOrdering

      public String createNewOrdering(int[] ordering) throws SshException
      Throws:
      SshException
    • contains

      public boolean contains(String name)
      Determine whether the factory supports a given component type.
      Parameters:
      name -
      Returns:
      true if the component is supported otherwise false
    • list

      public String list(String preferred, String... ignores)
      List the types of components supported by this factory. Returns the list as a comma delimited string with the preferred value as the first entry in the list. If the preferred value is "" then the list is returned unordered.
      Parameters:
      preferred - The preferred component type.
      ignores - Any items you want to exclude from the returned list.
      Returns:
      A comma delimited String of component types; for example "3des-cbc,blowfish-cbc"
    • list

      public String list(String preferred)
      List the types of components supported by this factory. Returns the list as a comma delimited string with the preferred value as the first entry in the list. If the preferred value is "" then the list is returned unordered.
      Parameters:
      preferred - The preferred component type.
      Returns:
      A comma delimited String of component types; for example "3des-cbc,blowfish-cbc"
    • add

      public void add(ComponentInstanceFactory<?> factory)
      Add a new component type to the factory. This method throws an exception if the class cannot be resolved. The name of the component IS NOT verified to allow component implementations to be overridden.
      Parameters:
      name - name
      factory - factory
      Throws:
      ClassNotFoundException
    • getInstance

      public T getInstance(String name) throws SshException
      Get a new instance of a supported component.
      Parameters:
      name - The name of the component; for example "3des-cbc"
      Returns:
      the newly instantiated object
      Throws:
      ClassNotFoundException
      SshException
    • createInstance

      protected T createInstance(String name, Class<? extends T> cls) throws Throwable
      Override this method to create an instance of the component.
      Parameters:
      cls -
      Returns:
      the newly instantiated object
      Throws:
      Throwable
    • remove

      public void remove(String name)
      Remove a supported component
      Parameters:
      name -
    • clear

      public void clear()
      Clear all of the entries in this component factory.
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • toArray

      public String[] toArray()
    • removeAllBut

      public void removeAllBut(String names)
    • lockComponents

      public void lockComponents()
    • configureSecurityLevel

      public void configureSecurityLevel(SecurityLevel securityLevel) throws SshException
      Throws:
      SshException
    • selectStrongestComponent

      public String selectStrongestComponent(String[] remoteAlgs) throws SshException
      Throws:
      SshException
    • hasComponents

      public boolean hasComponents()
    • order

      public Collection<String> order()
    • list

      public String list()
    • filter

      public String filter(String list, String... ignores)