@ConfigurationDescription(properties={@Property(name="ServiceAuthUserName",defaultValue="${arflow:confVar.SystemUserName}",description="The user name with which this service authenticates at the global security manager."),,,,,,,}) public class AbstractAuthenticatedService extends AbstractADEPT2Service implements AuthenticatingService
SessionFactory as well as some session management (token verification and alike).AbstractADEPT2Service.ActiveSessions| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CFG_EARLY_SERVICEAUTH_ORGPOSID
The configuration key for the organisational position ID of this service in the early phase
(before the global security manager is available).
|
static java.lang.String |
CFG_EARLY_SERVICEAUTH_ORGPOSNAME
The configuration key for the organisational position of this service in the early phase
(before the global security manager is available).
|
static java.lang.String |
CFG_EARLY_SERVICEAUTH_PASSWORD
The configuration key for the password of this service in the early phase (before the global
security manager is available.
|
static java.lang.String |
CFG_EARLY_SERVICEAUTH_USERNAME
The configuration key for the user name of this service in the early phase (before the global
security manager is available.
|
static java.lang.String |
CFG_SERVICEAUTH_ORGPOSID
The configuration key for the organisational position ID of this service.
|
static java.lang.String |
CFG_SERVICEAUTH_ORGPOSNAME
The configuration key for the organisational position of this service identified by its name.
|
static java.lang.String |
CFG_SERVICEAUTH_PASSWORD
The configuration key for the password of this service.
|
static java.lang.String |
CFG_SERVICEAUTH_USERNAME
The configuration key for the user name of this service.
|
CONF_CSV_LOGGING, configuration, logger, registry, runtimeRequiredServices, startupRequiredServices| Constructor and Description |
|---|
AbstractAuthenticatedService(Configuration conf,
Registry registry,
java.lang.Class<?> cls)
Creates an ADEPT2 service with the designated registry, a logger for this and assuming that
there are no other services required except the org model manager for non-early services.
|
AbstractAuthenticatedService(Configuration conf,
Registry registry,
java.lang.String[] startupRequiredServices,
java.lang.String[] runtimeRequiredServices,
java.lang.Class<?> cls)
Creates an ADEPT2 service with the designated registry, a logger for this
and the designated required services.
|
| Modifier and Type | Method and Description |
|---|---|
void |
_sessionActive(SessionToken session,
java.util.UUID templID,
java.util.UUID baseTemplID,
java.util.UUID embdTemplID,
java.util.UUID instID,
EBPInstanceReference ebpIR,
int addStackElems)
Registers the designated session as active, tracks the current thread and
registers the log context (if CSV-logging is configured).
|
protected void |
authenticateService()
(Re-)Authenticates this service using the security manager provided by
getSecurityManager(). |
protected void |
awaitActiveSessions(boolean emergency)
Awaits the termination of active sessions.
|
SessionToken |
createChildSession(SessionToken parentSession)
Creates a new child session token to the given session using the session
factory assigned to this service.
|
SessionToken |
createSession()
Creates a new session token using the session factory assigned to this
service.
|
QualifiedAgent |
getAgent(SessionToken session)
Gets the agent of the designated session token.
|
protected SecurityManager |
getSecurityManager()
Returns the security manager that will be used for authentication.
|
SessionFactory |
getSessionFactory()
Returns the session factory assigned to this service.
|
protected static java.lang.String[] |
getStartupRequired(Registry registry,
java.lang.String[] startupRequiredServices)
Gets the startup required services of this service.
|
QualifiedAgent |
getTopLevelAgent(SessionToken session)
Gets the agent of the top-level session token of the designated session token.
|
Pair<QualifiedAgent,QualifiedAgent> |
getUserCredentials(SessionToken session)
Gets the agent of the top-level session token and the agent of the
designated session token if a session factory is available.
|
void |
globalSecurityManagerAvailable()
Notifies this service that the global security manager is available.
|
void |
init(java.net.URI[] localExportedUris,
java.net.URI[] globalExportedUris)
Copies the designated URI array and stores it internally and authenticates
to the system and sets the session factory.
|
protected static boolean |
isEarlyService(Registry registry)
Gets whether this service is an early service and is started before the
global security manager.
|
boolean |
sessionHasCapability(SessionToken session,
java.lang.String capability)
Returns whether the given session has the specified capability.
|
void |
shutdown(boolean emergency)
Awaits the termination of the active sessions and nulls the session factory.
|
_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, unprivilegeThreadpublic static final java.lang.String CFG_SERVICEAUTH_USERNAME
public static final java.lang.String CFG_SERVICEAUTH_ORGPOSID
public static final java.lang.String CFG_SERVICEAUTH_ORGPOSNAME
public static final java.lang.String CFG_SERVICEAUTH_PASSWORD
public static final java.lang.String CFG_EARLY_SERVICEAUTH_USERNAME
public static final java.lang.String CFG_EARLY_SERVICEAUTH_ORGPOSID
public static final java.lang.String CFG_EARLY_SERVICEAUTH_ORGPOSNAME
public static final java.lang.String CFG_EARLY_SERVICEAUTH_PASSWORD
public AbstractAuthenticatedService(Configuration conf, Registry registry, java.lang.Class<?> cls) throws ConfigurationException
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.ConfigurationException - If the password for this authenticated service cannot be parsed
from the configuration, a ConfigurationException will be thrown.public AbstractAuthenticatedService(Configuration conf, Registry registry, java.lang.String[] startupRequiredServices, java.lang.String[] runtimeRequiredServices, java.lang.Class<?> cls) throws ConfigurationException
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 (in init(URI[], URI[]) and AbstractADEPT2Service.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.ConfigurationException - If the password for this authenticated
service cannot be parsed from the configuration, a
ConfigurationException will be thrown.protected static boolean isEarlyService(Registry registry)
registry - The registry of the service or null in case no
registry is provided, for instance when creating a registry
itself.protected static java.lang.String[] getStartupRequired(Registry registry, java.lang.String[] startupRequiredServices)
registry - The registry of the service.startupRequiredServices - The services required at startup as declared
by the service.public void _sessionActive(SessionToken session, java.util.UUID templID, java.util.UUID baseTemplID, java.util.UUID embdTemplID, java.util.UUID instID, EBPInstanceReference ebpIR, int addStackElems)
AbstractADEPT2ServiceInvalidStateException. AbstractADEPT2Service.sessionFinished(SessionToken).
This method synchronises on the activeSessions object. So be
sure not to hold any locks or at least acquire the locks in a well-defined
order.
This method should not be called directly. Call
AbstractADEPT2Service.sessionActive(SessionToken),
AbstractADEPT2Service.sessionActive(SessionToken, int),
AbstractADEPT2Service.sessionActive(SessionToken, UUID, UUID, UUID, UUID) or
AbstractADEPT2Service.sessionActive(SessionToken, UUID, UUID, EBPInstanceReference)
instead.
_sessionActive in class AbstractADEPT2Servicesession - The session token with which a method is called and
therefore active. This must not be null.templID - The template ID for the log record. This may be null.baseTemplID - The base template ID for the log record. This may be
null.embdTemplID - The (internal) ID of the embedded template ID the for
the log record. This may be null.instID - The instance ID for the log record. This may be null.ebpIR - The EBPInstanceReference for the log record. This
may be null.addStackElems - The additional elements to be removed from the stack
so that the real method name is logged instead of a
sessionActive. This is usually 0. Unless you override
this method or call some sessionActive methods
internally before calling methods of this class.ServiceAccessControlException - If the designated session token has
no integrity and therefore the agents cannot be determined, a
ServiceAccessControlExceptionwill be thrown.public void init(java.net.URI[] localExportedUris,
java.net.URI[] globalExportedUris)
throws AbortServiceException
In case of an early service, this will not authenticate to the system! Such
a service need to authenticateService() later when the security
manager is available.
init in interface ADEPT2Serviceinit in class AbstractADEPT2ServicelocalExportedUris - 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 or null in case the service is not
published.AbortServiceException - If authenticating at the security manager
fails, an AbortServiceException will be thrown.public void globalSecurityManagerAvailable()
throws AbortServiceException
AuthenticatingServiceglobalSecurityManagerAvailable in interface AuthenticatingServiceAbortServiceException - If there are problems re-authenticating at
the global security manager, an
AbortServiceException will be thrown.protected SecurityManager getSecurityManager()
protected void authenticateService()
throws AuthenticationException,
AbortServiceException
getSecurityManager().AuthenticationException - If the provided credentials are incorrect, an
AuthenticationException will be thrown.AbortServiceException - If the authentication at the security manager fails an
AbortServiceException will be thrown.ConfigurationException - If the password cannot be parsed, a
ConfigurationException will be thrown.public SessionFactory getSessionFactory()
public SessionToken createSession()
public SessionToken createChildSession(SessionToken parentSession)
parentSession - the session for which to create a child sessionpublic boolean sessionHasCapability(SessionToken session, java.lang.String capability)
session - the session to checkcapability - the capability to check forServiceAccessControlException - if the integrity of the session's
security token failsprotected void awaitActiveSessions(boolean emergency)
emergency - Whether the active sessions should only be awaited for a
specific time.public void shutdown(boolean emergency)
shutdown in interface ADEPT2Serviceshutdown in class AbstractADEPT2Serviceemergency - Whether the shutdown will be an emergency shutdown.public Pair<QualifiedAgent,QualifiedAgent> getUserCredentials(SessionToken session)
getUserCredentials in class AbstractADEPT2Servicesession - The session token of which to retrieve the agent of the
top-level session token and the own agent.ServiceAccessControlException - If the designated session token has
no integrity and therefore the agents cannot be determined, a
ServiceAccessControlExceptionwill be thrown.public QualifiedAgent getTopLevelAgent(SessionToken session)
session - The session token of which to retrieve the agent of the top-level session token.ServiceAccessControlException - If the designated session token has no integrity and
therefore the agent of the top-level session token cannot be determined, a
ServiceAccessControlExceptionwill be thrown.public QualifiedAgent getAgent(SessionToken session)
session - The session token of which to retrieve the agent.ServiceAccessControlException - If the designated session token has no integrity and
therefore the agent cannot be determined, a
ServiceAccessControlException will be thrown.