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 a
ClientSessionFactory. 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
ConstructorsModifierConstructorDescriptionprotectedAbstractNonPrivilegedService(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.protectedAbstractNonPrivilegedService(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
Modifier and TypeMethodDescriptionprotected void(Re-)Authenticates this service using the security manager provided bygetSecurityManager().protected voidawaitActiveSessions(boolean emergency) Awaits the termination of active sessions.protected SessionTokenCreates a new session token using the client session factory assigned to this service.protected SecurityManagerReturns the security manager that will be used for authentication.protected ClientSessionFactoryReturns the client session factory assigned to this service.voidCopies the designated URI array and stores it internally and authenticates to the system and sets the session factory.voidshutdown(boolean emergency) Awaits the termination of the active sessions and nulls the session factory.protected voidsimpleInit(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 Details
-
AbstractNonPrivilegedService
protected AbstractNonPrivilegedService(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, aConfigurationExceptionwill be thrown.
-
AbstractNonPrivilegedService
protected AbstractNonPrivilegedService(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, aConfigurationExceptionwill be thrown.
-
-
Method Details
-
init
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:
initin interfaceADEPT2Service- Overrides:
initin 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 ornullin case the service is not published.- Throws:
AbortServiceException- If authenticating at the security manager fails, anAbortServiceExceptionwill 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 ornullin case the service is not published.- Throws:
AbortServiceException- If the initialisation of the superclass fails, anAbortServiceExceptionwill be thrown.
-
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
(Re-)Authenticates this service using the security manager provided bygetSecurityManager().- Throws:
AuthenticationException- If the provided credentials are incorrect, anAuthenticationExceptionwill be thrown.AbortServiceException- If the authentication at the security manager fails anAbortServiceExceptionwill be thrown.ConfigurationException- If the password cannot be parsed, aConfigurationExceptionwill be thrown.
-
getSessionFactory
Returns the client session factory assigned to this service.- Returns:
- The client session factory assigned to this service.
-
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:
shutdownin interfaceADEPT2Service- Overrides:
shutdownin classAbstractADEPT2Service- Parameters:
emergency- Whether the shutdown will be an emergency shutdown.
-