Class TrustStore

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.installer.plugin.impl.TrustStore
All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent

@NotThreadSafe public final class TrustStore extends AbstractInitializableComponent
Code to handle (load, update, check) the trust store for an individual plugin. a thin shim on BC.
  • Field Details

  • Constructor Details

    • TrustStore

      public TrustStore()
  • Method Details

    • setPluginId

      public void setPluginId(String what)
      Set the pluginId.
      Parameters:
      what - to set.
    • setIdpHome

      public void setIdpHome(@Nonnull Path what)
      Set IdPHome.
      Parameters:
      what - The idpHome to set.
    • setTrustStore

      public void setTrustStore(@Nullable String what)
      Set explicitTrustStore.
      Parameters:
      what - The value to set.
    • loadStoreFrom

      private static org.bouncycastle.openpgp.PGPPublicKeyRingCollection loadStoreFrom(@Nonnull InputStream in) throws IOException
      Return a store loaded from the supplied stream.
      Parameters:
      in - the stream
      Returns:
      a suitable store
      Throws:
      IOException - from Files.newInputStream(Path, java.nio.file.OpenOption...) and from PGPPublicKeyRingCollection(InputStream, org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator)
    • loadStore

      protected void loadStore() throws IOException
      Load the store from its designated location.
      Throws:
      IOException - from Files.newInputStream(Path, java.nio.file.OpenOption...) and from PGPPublicKeyRingCollection(InputStream, org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator)
    • createNewStore

      protected void createNewStore() throws IOException
      Create an empty store and save to new location.
      Throws:
      IOException - from saveStore() and in the unlikely event that PGPPublicKeyRingCollection(java.util.Collection) has problems.
    • saveStore

      public void saveStore() throws IOException
      Save the store to its designated location.
      Throws:
      IOException - from Files.newOutputStream(Path, java.nio.file.OpenOption...) and from PGPPublicKeyRingCollection.encode(OutputStream)
    • saveStoreInternal

      public void saveStoreInternal() throws IOException
      Save the store to its designated location.
      Throws:
      IOException - from Files.newOutputStream(Path, java.nio.file.OpenOption...) and from PGPPublicKeyRingCollection.encode(OutputStream)
    • importKeyFromStream

      public void importKeyFromStream(TrustStore.Signature sigForKey, @Nonnull InputStream keyStream, @Nonnull Predicate<String> accept) throws IOException
      Load up the provided store and if the key is found and the Predicate allows it add it to the store which we will then save.
      Parameters:
      sigForKey - the signature we are looking for a key for.
      keyStream - where to load the key from
      accept - whether we actually want to install this key
      Throws:
      IOException - if the load or save fails
    • signatureOf

      @Nonnull public static TrustStore.Signature signatureOf(@Nonnull InputStream stream) throws IOException
      Provide an opaque signature object from an input stream.
      Parameters:
      stream - what to read.
      Returns:
      the Signature.
      Throws:
      IOException - if there is a problem reading the file of it it doesn't represent a signature
    • contains

      public boolean contains(@Nonnull TrustStore.Signature signature)
      Does the key that made this signature exist in our keyrings?
      Parameters:
      signature - what to ask about
      Returns:
      whether it is there
    • checkSignature

      public boolean checkSignature(@Nonnull InputStream input, @Nonnull TrustStore.Signature signature) throws IOException
      Run a signature check over the streams.
      Parameters:
      input - what to check
      signature - what to check with
      Returns:
      whether it passed or not
      Throws:
      IOException - if we get an error reading the stream
    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractInitializableComponent
      Throws:
      ComponentInitializationException