Class LibraryConfigurationBinder
java.lang.Object
org.gcube.documentstore.configuration.LibraryConfigurationBinder
The configuration of the Document Store Lib
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected org.gcube.common.security.factories.AuthorizationProviderstatic final Stringstatic final Stringprotected longThe time in milliseconds after which the configuration is considered expired.protected CalendarThe time when the library configuration was created.protected static longstatic final Stringprotected static LibraryConfigurationBinderprotected StringThe working Context of the library, chosen among the Contexts of its credentials; computed on first use and kept for the lifetime of this configuration. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringchooseWorkingContext(Set<String> contexts) Chooses the working Context among the given Contexts, deterministically: the Context with the fewest path segments (the one closest to the root), and among those the first in lexicographic order.org.gcube.common.security.factories.AuthorizationProviderReturns the authorization provider configured by the "dsl.yaml" file inGHN_HOME; the file is read once for the lifetime of this configuration.static LibraryConfigurationBinderReturns the singleton instance ofLibraryConfigurationBinder.Returns the working Context of the library: the Context whose secret the library uses for its own operations.org.gcube.common.security.secrets.SecretReturns a secret for the working Context, obtained from the credentials of the "dsl.yaml" file.
-
Field Details
-
DOCUMENT_STORE_LIB_CONFIGURATION_FILE
- See Also:
-
CONFIGURATION_SECTION_KEY
- See Also:
-
CONFIGURATION_LIFETIME
- See Also:
-
AUTHORIZATION_SECTION_KEY
- See Also:
-
libraryConfigurationBinder
-
DEFAULT_LIFETIME
protected static long DEFAULT_LIFETIME -
creationTime
The time when the library configuration was created. -
configurationLifetime
protected long configurationLifetimeThe time in milliseconds after which the configuration is considered expired. The default value is 5 minutes (seeDEFAULT_LIFETIME). The configuration itself could contains the expiring time. So that we can decide the configuration lifetime. -
authorizationProvider
protected org.gcube.common.security.factories.AuthorizationProvider authorizationProvider -
workingContext
The working Context of the library, chosen among the Contexts of its credentials; computed on first use and kept for the lifetime of this configuration.
-
-
Method Details
-
getInstance
Returns the singleton instance ofLibraryConfigurationBinder. If the instance does not exist or the configuration has expired, a new instance is created.- Returns:
- the singleton instance of
LibraryConfigurationBinder
-
getAuthorizationProvider
public org.gcube.common.security.factories.AuthorizationProvider getAuthorizationProvider() throws ExceptionReturns the authorization provider configured by the "dsl.yaml" file inGHN_HOME; the file is read once for the lifetime of this configuration. Its "authorization" section has the form of the one of SmartGears (AuthorizationSection); its optional "configuration" section gives the lifetime of this configuration in minutes ("configurationExpiringTime").- Returns:
- the authorization provider, or
nullif the file has no authorization section - Throws:
Exception- if the file cannot be read or one of its sections is invalid
-
getWorkingContext
Returns the working Context of the library: the Context whose secret the library uses for its own operations. It is one of the Contexts of the credentials, chosen bychooseWorkingContext(Set), never the Context of the thread that happens to call.- Returns:
- the working Context, or
nullif the credentials give no Context - Throws:
Exception- if the authorization provider cannot be built
-
getWorkingSecret
Returns a secret for the working Context, obtained from the credentials of the "dsl.yaml" file. A new secret is requested at every call, so that an expired token is never reused.- Returns:
- the secret, or
nullif the credentials give no Context - Throws:
Exception- if the secret cannot be obtained
-
chooseWorkingContext
Chooses the working Context among the given Contexts, deterministically: the Context with the fewest path segments (the one closest to the root), and among those the first in lexicographic order.- Parameters:
contexts- the Contexts of the credentials, possiblynullor empty- Returns:
- the chosen Context, or
nullif there is none
-