Class AbstractConfigurableAuthenticatedService
- java.lang.Object
-
- de.aristaflow.adept2.base.service.AbstractADEPT2Service
-
- de.aristaflow.adept2.base.service.AbstractAuthenticatedService
-
- de.aristaflow.adept2.base.service.AbstractConfigurableAuthenticatedService
-
- All Implemented Interfaces:
ADEPT2Service,AuthenticatingService,ConfigurableService,LogService,ServiceThreadHandling
public abstract class AbstractConfigurableAuthenticatedService extends AbstractAuthenticatedService implements ConfigurableService
This class extends an authenticated service by the means for changing a configuration. However, subclasses need to implement which of its keys may be changed by a specific user (getChangeableConfigurationKeys(SessionToken)) and setting the configuration values since both depends on the semantic of the configuration keys.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
AbstractADEPT2Service.ActiveSessions
-
-
Field Summary
Fields Modifier and Type Field Description static intCFG_RETRY_MAXThe maximum of retries for getConfiguration.-
Fields inherited from class de.aristaflow.adept2.base.service.AbstractAuthenticatedService
CFG_EARLY_SERVICEAUTH_ORGPOSID, CFG_EARLY_SERVICEAUTH_ORGPOSNAME, CFG_EARLY_SERVICEAUTH_PASSWORD, CFG_EARLY_SERVICEAUTH_USERNAME, CFG_SERVICEAUTH_ORGPOSID, CFG_SERVICEAUTH_ORGPOSNAME, CFG_SERVICEAUTH_PASSWORD, CFG_SERVICEAUTH_USERNAME
-
Fields inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
CONF_CSV_LOGGING, configuration, logger, registry, runtimeRequiredServices, startupRequiredServices
-
Fields inherited from interface de.aristaflow.adept2.base.service.ConfigurableService
CONF_RUNTIME_CONF_PREFIX
-
-
Constructor Summary
Constructors Constructor Description AbstractConfigurableAuthenticatedService(org.apache.commons.configuration2.Configuration configuration, Registry registry, Class<?> cls)Creates a configurable service with the designated configuration, the designated registry, a logger for this and assuming that there are no other services required.AbstractConfigurableAuthenticatedService(org.apache.commons.configuration2.Configuration configuration, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices, Class<?> cls)Creates a configurable service with the designated configuration, the designated registry, a logger for this and the designated required services.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>getChangeableConfigurationKeys(SessionToken session)Gets a list of configuration keys that may be changed by the owner of the designated session token.org.apache.commons.configuration2.ConfigurationgetConfiguration(SessionToken session)Gets the configuration of this service for displaying it.StringgetConfigurationValue(SessionToken session, String key)Gets the string representation of the configuration value for the designated key ornullif the key does not exist or has no value.voidsetConfigurationValue(SessionToken session, String key, String value)Sets the designated configuration value.-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractAuthenticatedService
_sessionActive, authenticateService, awaitActiveSessions, createChildSession, createSession, getAgent, getSecurityManager, getSessionFactory, getStartupRequired, getTopLevelAgent, getUserCredentials, globalSecurityManagerAvailable, init, isEarlyService, sessionHasAllCapabilities, sessionHasAllTopLevelCapabilities, sessionHasCapability, sessionHasOneCapability, sessionHasOneTopLevelCapability, shutdown
-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
_sessionFinished, activeOrInvalidServiceStateException, changeLogContext, changeLogContext, changeLogContext, consoleLog, csvLoggingEnabled, getClassSpecificJulLogger, getDependencyRegistry, getLocalUris, getLogger, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, isActive, isSessionActive, isShutdown, logMethodEntry, logMethodEntry, logMethodEntry, logMethodExit, logMethodExit, ping, preShutdown, privilegeSession, privilegeThread, revertLogContextChanges, sessionActive, sessionActive, sessionActive, sessionActive, sessionFinished, sessionFinished, signalShutdown, signalStart, start, unprivilegeThread
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.aristaflow.adept2.base.service.ADEPT2Service
getLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, init, ping, preShutdown, shutdown, start
-
-
-
-
Field Detail
-
CFG_RETRY_MAX
public static final int CFG_RETRY_MAX
The maximum of retries for getConfiguration.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractConfigurableAuthenticatedService
public AbstractConfigurableAuthenticatedService(org.apache.commons.configuration2.Configuration configuration, Registry registry, Class<?> cls) throws ConfigurationExceptionCreates a configurable service with the designated configuration, the designated registry, a logger for this and assuming that there are no other services required.- Parameters:
configuration- The configuration of this service that can be changed (at least parts of it) at runtime and that provides the logon credentials for this service.registry- The registry to be used for accessing services by this service. This is provided as parameter to the constructor when creating a service.cls- The class specifying the name of the logger of this service.- Throws:
ConfigurationException- If the password for this authenticated service cannot be parsed from the configuration, aConfigurationExceptionwill be thrown.
-
AbstractConfigurableAuthenticatedService
public AbstractConfigurableAuthenticatedService(org.apache.commons.configuration2.Configuration configuration, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices, Class<?> cls) throws ConfigurationExceptionCreates a configurable service with the designated configuration, the designated registry, a logger for this and the designated required services.- Parameters:
configuration- The configuration of this service that can be changed (at least parts of it) at runtime and that provides the logon credentials for this service.registry- The registry to be used for accessing services by this service. This is provided as parameter to the constructor when creating a service.startupRequiredServices- The service type names of services required at startup time (inAbstractAuthenticatedService.init(java.net.URI[], java.net.URI[])andAbstractADEPT2Service.start()).runtimeRequiredServices- The service type names of services required at runtime (after startup time).cls- The class specifying the name of the logger of this service.- Throws:
ConfigurationException- If the password for this authenticated service cannot be parsed from the configuration, aConfigurationExceptionwill be thrown.
-
-
Method Detail
-
getConfiguration
public org.apache.commons.configuration2.Configuration getConfiguration(SessionToken session)
Description copied from interface:ConfigurableServiceGets the configuration of this service for displaying it. It usually contains all configuration values of a service. Not all of them may be changed and not all of them by all users! Therefore filter the configuration appropriately based on the changeable keys. The returned configuration must not be changed directly since it usually is a copy of the configuration. UseConfigurableService.setConfigurationValue(SessionToken, String, String)for changing configuration values.Note to implementors: As stated above return a copy of the configuration and not the configuration itself. Additionally make sure the returned configuration is serialisable since it may be transfered to a remote machine.
- Specified by:
getConfigurationin interfaceConfigurableService- Parameters:
session- The session which is used to check for access rights on this method.- Returns:
- The configuration of the service. Some of its values may be changed.
-
getConfigurationValue
public String getConfigurationValue(SessionToken session, String key)
Description copied from interface:ConfigurableServiceGets the string representation of the configuration value for the designated key ornullif the key does not exist or has no value.- Specified by:
getConfigurationValuein interfaceConfigurableService- Parameters:
session- The session which is used to check for access rights on this method.key- The key of the configuration value.- Returns:
- The string representation of the configuration value of the designated key or
nullif the key does not exist or has no value.
-
getChangeableConfigurationKeys
public List<String> getChangeableConfigurationKeys(SessionToken session)
Description copied from interface:ConfigurableServiceGets a list of configuration keys that may be changed by the owner of the designated session token. Note that these may contain keys that are not yet in the configuration.- Specified by:
getChangeableConfigurationKeysin interfaceConfigurableService- Parameters:
session- The session which is used to check for access rights on this method and to determine which configuration keys can be changed by the designated user.- Returns:
- A list of strings that represent the keys that may be changed by the user identified by the designated session token.
-
setConfigurationValue
public void setConfigurationValue(SessionToken session, String key, String value) throws ConfigurationException
Description copied from interface:ConfigurableServiceSets the designated configuration value. Be sure to use a valid key. The keys are specified by the service. The value has to conform to the key, for instance, if the value is a list, the string has to reflect this appropriately. Use the empty string as value to delete the configuration.Note to implementors: Check the configuration value for validity and the session token for whether it is allowed to change the configuration.
- Specified by:
setConfigurationValuein interfaceConfigurableService- Parameters:
session- The session which is used to check for access rights on this method.key- The key for the configuration value.value- The string representation of the configuration value to be set.- Throws:
ConfigurationException- If there are problems setting the designated value, for instance, the value does not conform to the designated key or is not a valid value at all, aConfigurationExceptionwill be thrown.
-
-