Class AbstractNonPrivilegedService
- java.lang.Object
-
- de.aristaflow.adept2.base.service.AbstractADEPT2Service
-
- de.aristaflow.adept2.base.service.AbstractNonPrivilegedService
-
- All Implemented Interfaces:
ADEPT2Service
,LogService
,ServiceThreadHandling
- Direct Known Subclasses:
AbstractEventManager
@ConfigurationDescription(properties={@Property(name="ServiceAuthUserName",defaultValue="${arflow:confVar.SystemUserName}",description="The user name with which this service authenticates at the global security manager."),,,}) public abstract class AbstractNonPrivilegedService extends AbstractADEPT2Service
An abstract class providing the basic means for authenticating and managing aClientSessionFactory
. This can only be used for services that are created after the global security manager is available.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
AbstractADEPT2Service.ActiveSessions
-
-
Field Summary
-
Fields inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
CONF_CSV_LOGGING, configuration, logger, registry, runtimeRequiredServices, startupRequiredServices
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNonPrivilegedService(org.apache.commons.configuration2.Configuration conf, Registry registry, Class<?> cls)
Creates an ADEPT2 service with the designated registry, a logger for this and assuming that there are no other services required.protected
AbstractNonPrivilegedService(org.apache.commons.configuration2.Configuration conf, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices, Class<?> cls)
Creates an ADEPT2 service with 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 protected void
authenticateService()
(Re-)Authenticates this service using the security manager provided bygetSecurityManager()
.protected void
awaitActiveSessions(boolean emergency)
Awaits the termination of active sessions.protected SessionToken
createSession()
Creates a new session token using the client session factory assigned to this service.protected SecurityManager
getSecurityManager()
Returns the security manager that will be used for authentication.protected ClientSessionFactory
getSessionFactory()
Returns the client session factory assigned to this service.void
init(URI[] localExportedUris, URI[] globalExportedUris)
Copies the designated URI array and stores it internally and authenticates to the system and sets the session factory.void
shutdown(boolean emergency)
Awaits the termination of the active sessions and nulls the session factory.protected void
simpleInit(URI[] localExportedUris, URI[] globalExportedUris)
Initialises this service but does not explicitly authenticate.-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
_sessionActive, _sessionFinished, activeOrInvalidServiceStateException, changeLogContext, changeLogContext, changeLogContext, consoleLog, csvLoggingEnabled, getClassSpecificJulLogger, getDependencyRegistry, getLocalUris, getLogger, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, getUserCredentials, isActive, isSessionActive, isShutdown, logMethodEntry, logMethodEntry, logMethodEntry, logMethodExit, logMethodExit, ping, preShutdown, privilegeSession, privilegeThread, revertLogContextChanges, sessionActive, sessionActive, sessionActive, sessionActive, sessionFinished, sessionFinished, signalShutdown, signalStart, start, unprivilegeThread
-
-
-
-
Constructor Detail
-
AbstractNonPrivilegedService
protected AbstractNonPrivilegedService(org.apache.commons.configuration2.Configuration conf, Registry registry, Class<?> cls) throws ConfigurationException
Creates an ADEPT2 service with the designated registry, a logger for this and assuming that there are no other services required.- Parameters:
conf
- The configuration providing 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, aConfigurationException
will be thrown.
-
AbstractNonPrivilegedService
protected AbstractNonPrivilegedService(org.apache.commons.configuration2.Configuration conf, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices, Class<?> cls) throws ConfigurationException
Creates an ADEPT2 service with the designated registry, a logger for this and the designated required services.- Parameters:
conf
- The configuration providing 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 (ininit(URI[], 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, aConfigurationException
will be thrown.
-
-
Method Detail
-
init
public void init(URI[] localExportedUris, URI[] globalExportedUris) throws AbortServiceException
Copies the designated URI array and stores it internally and authenticates to the system and sets the session factory.
This method can be called any time in overriding init-methods.- Specified by:
init
in interfaceADEPT2Service
- Overrides:
init
in classAbstractADEPT2Service
- Parameters:
localExportedUris
- The URIs with which this service is exported locally or a local URI or an empty array for internal services.globalExportedUris
- The URIs with which this service is published globally ornull
in case the service is not published.- Throws:
AbortServiceException
- If authenticating at the security manager fails, anAbortServiceException
will be thrown.
-
simpleInit
protected void simpleInit(URI[] localExportedUris, URI[] globalExportedUris) throws AbortServiceException
Initialises this service but does not explicitly authenticate. This needs to be done at a later time. The late authentication is required for the registries when the security manager is not set yet.- Parameters:
localExportedUris
- The URIs with which this service is exported locally or a local URI or an empty array for internal services.globalExportedUris
- The URIs with which this service is published globally ornull
in case the service is not published.- Throws:
AbortServiceException
- If the initialisation of the superclass fails, anAbortServiceException
will be thrown.
-
getSecurityManager
protected SecurityManager getSecurityManager()
Returns the security manager that will be used for authentication. This implementation will simply return the security manager provided by the registry. This may be overridden in subclasses.- Returns:
- the security manager that will be used for authentication
-
authenticateService
protected void authenticateService() throws AuthenticationException, AbortServiceException
(Re-)Authenticates this service using the security manager provided bygetSecurityManager()
.- Throws:
AuthenticationException
- If the provided credentials are incorrect, anAuthenticationException
will be thrown.AbortServiceException
- If the authentication at the security manager fails anAbortServiceException
will be thrown.ConfigurationException
- If the password cannot be parsed, aConfigurationException
will be thrown.
-
getSessionFactory
protected ClientSessionFactory getSessionFactory()
Returns the client session factory assigned to this service.- Returns:
- The client session factory assigned to this service.
-
createSession
protected SessionToken createSession()
Creates a new session token using the client session factory assigned to this service.- Returns:
- A new session token using the client session factory assigned to this service.
-
awaitActiveSessions
protected void awaitActiveSessions(boolean emergency)
Awaits the termination of active sessions. This allows subclasses to separate waiting for the termination from shutting down this abstract service.- Parameters:
emergency
- Whether the active sessions should only be awaited for a specific time.
-
shutdown
public void shutdown(boolean emergency)
Awaits the termination of the active sessions and nulls the session factory.- Specified by:
shutdown
in interfaceADEPT2Service
- Overrides:
shutdown
in classAbstractADEPT2Service
- Parameters:
emergency
- Whether the shutdown will be an emergency shutdown.
-
-