Class LibraryCredentials

java.lang.Object
org.gcube.documentstore.security.LibraryCredentials

public final class LibraryCredentials extends Object
Runs the library's own tasks (sending records, flushing, rediscovering the persistence, elaborating the fallback file, reloading a configuration) with the library's own credentials: the secret of the working Context obtained from dsl.ini (LibraryConfigurationBinder), never the secret that a pool thread happens to carry.

When dsl.ini is not available (the library is used outside a SmartGears container), the task runs with the secret already set in the calling thread, as the library always did.

Author:
Luca Frosini (ISTI - CNR)
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    call(Callable<T> task)
    Runs a task with the library's credentials, or with the calling thread's secret if the library has none.
    static org.gcube.common.security.secrets.Secret
    Returns a secret for the library's working Context.
    static boolean
    Tells whether the library has credentials of its own, i.e. whether dsl.ini provides an authorization provider.
    static void
    run(Runnable task)
    Runs a task with the library's credentials, or with the calling thread's secret if the library has none.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getSecret

      public static org.gcube.common.security.secrets.Secret getSecret()
      Returns a secret for the library's working Context.
      Returns:
      the secret, or null if the library has no credentials of its own
    • isAvailable

      public static boolean isAvailable()
      Tells whether the library has credentials of its own, i.e. whether dsl.ini provides an authorization provider.
      Returns:
      true if the library has credentials of its own
    • call

      public static <T> T call(Callable<T> task) throws Exception
      Runs a task with the library's credentials, or with the calling thread's secret if the library has none.
      Type Parameters:
      T - the result type
      Parameters:
      task - the task
      Returns:
      the task's result
      Throws:
      Exception - if the task fails
    • run

      public static void run(Runnable task)
      Runs a task with the library's credentials, or with the calling thread's secret if the library has none.
      Parameters:
      task - the task