Package com.smeup.kokos.sdk.util.mapper
Class ExecutionContextMapper
java.lang.Object
com.smeup.kokos.sdk.util.mapper.ExecutionContextMapper
- Author:
- mattia.bonardi This mapper create the ExecutionContext instance from ExecutionContextDTO
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractAppName(Map<String, String> headers) Extracts the app name from the given headers, either from the V3 auth header or from the JWT bearer token, without looking up the correspondingAppconfiguration.static StringextractAuthToken(Map<String, String> headers) Extracts the auth token from the given headers: either the "AuthToken" cookie value or theAuthorizationheader (stripping the "Bearer " prefix if present).extractHeadersFromRequest(org.eclipse.jetty.server.Request request) ExtractsTRACKED_HEADERSand the "AuthToken" cookie from a Jetty request.static ExecutionContextstatic ExecutionContextstatic ExecutionContextfromHeaders(Map<String, String> headers) Builds a partialExecutionContextfrom a plain header map (user/app/version only).static ExecutionContextDTOtoDTO(ExecutionContext context) Encodes aKokosUserinto the V3 auth header values, ready to be set on an outgoing (proxied) request.Encodes aKokosUserinto the V3 auth header values and, whenversionis non-blank, the API version header (HeaderManager.V3.VERSION).toPropertiesDTO(ExecutionContext context)
-
Field Details
-
AUTH_TOKEN_KEY
Cookie name used to carry the auth token when it's not sent as a bearer header.- See Also:
-
TRACKED_HEADERS
Auth and V3 headers copied from an incoming request into a plain map. Does not includeAUTH_TOKEN_KEY(cookie) or transport-specific keys.
-
-
Method Details
-
fromDTO
-
fromDTO
-
toDTO
-
toPropertiesDTO
-
fromHeaders
Builds a partialExecutionContextfrom a plain header map (user/app/version only). Resolves identity from V3 auth headers when present, otherwise from the JWT bearer token.Internal: intended for
ExecutionContextManageronly. External callers must useExecutionContextManager.createContext(Map, IServiceCaller).- Parameters:
headers- the request headers (and, optionally, the "AuthToken" cookie value)- Returns:
- the resolved (not yet hydrated) execution context
- Throws:
Exception- if no usable auth token/headers are found, or the app is unknown
-
toHeaders
Encodes aKokosUserinto the V3 auth header values, ready to be set on an outgoing (proxied) request. The auth-properties entry is omitted when the user has no additional properties. -
toHeaders
Encodes aKokosUserinto the V3 auth header values and, whenversionis non-blank, the API version header (HeaderManager.V3.VERSION). Ready to be set on an outgoing (proxied) request. -
extractAuthToken
Extracts the auth token from the given headers: either the "AuthToken" cookie value or theAuthorizationheader (stripping the "Bearer " prefix if present).- Returns:
- the token, or
nullif absent
-
extractAppName
Extracts the app name from the given headers, either from the V3 auth header or from the JWT bearer token, without looking up the correspondingAppconfiguration. Useful for callers (e.g. legacy/standalone connectors) that only need the raw app name.- Throws:
Exception- if no app name can be resolved
-
extractHeadersFromRequest
public static Map<String,String> extractHeadersFromRequest(org.eclipse.jetty.server.Request request) ExtractsTRACKED_HEADERSand the "AuthToken" cookie from a Jetty request.
-