Package de.pisa.psa.rst.svc
Class PsaRstApiSvcBas
java.lang.Object
de.pisa.psa.rst.svc.PsaRstApiSvcBas
- Direct Known Subclasses:
IplWsvPsaRstApiSvc
,IplWsvPsaRstApiTestSvc
REST API: service base class
- Since:
- 23.05.2023
- Author:
- weiland
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
cookie name: IAM authentication tokenprotected String
key for the IAM propertiesprotected String
service URL for the IAM tokenprotected de.pisa.psa.com.dxhub.iam.UserInfo
IAM user information for the access tokenprotected org.glassfish.jersey.server.ContainerRequest
container request contextprotected String
the session user -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
createEvent
(de.pisa.psc.srv.glb.PscSsn ssn, String gid, String body, String user, String language, boolean store) create an event recordprotected String[]
get the value of the Authorization headerfinal PsaRstApiEvtHdlDat
getData()
get the request dataprotected final de.pisa.psa.com.dxhub.iam.UserInfo
get the current IAM user informationprotected de.pisa.psa.com.dxhub.iam.UserInfo
getIAMUserInfo
(de.pisa.psc.srv.glb.PscSsn ssn, String account_id, String token) get the IAM user informationprotected String
getLanguageFromRequest
(de.pisa.psc.srv.glb.PscSsn ssn) get the language identifier from the requests accepted languagesprotected Optional<javax.ws.rs.core.Cookie>
getRequestCookie
(String name) get a cookie from the requestprotected String
getRequestHeader
(String key) get a request header valueget all request headerget the acceptable languages for this requestprotected String
get the request methodprotected String
get the request pathprotected String
get the request query stringprotected javax.ws.rs.core.Response
handleRequest
(String gid, String body, String user, String language) handle an incoming requestprotected void
initialize
(de.pisa.psc.srv.glb.PscSsn ssn) initialize the requestprotected boolean
check if the request should be handled synchronouslyprotected de.pisa.psa.ifc.PsaDtoDat
loadConfiguration
(de.pisa.psc.srv.glb.PscSsn ssn, String method, List<String> path_tokens) load the configurationprotected de.pisa.psc.srv.glb.PscSsn
newSsn()
get a new sessionjavax.ws.rs.core.Response
start processing the current eventfinal void
setConfig
(de.pisa.psa.ifc.PsaDtoDat config) set the configurationfinal void
setEvent
(de.pisa.psa.ifc.PsaDtoDat event) set the eventprotected void
validateIAM
(de.pisa.psc.srv.glb.PscSsn ssn) validate the IAM tokenprotected void
validateKey
(de.pisa.psc.srv.glb.PscSsn ssn) validate the authorization key
-
Field Details
-
Request
@Context protected org.glassfish.jersey.server.ContainerRequest Requestcontainer request context -
User
the session user -
IAM_Key
key for the IAM properties -
IAM_Service
service URL for the IAM token -
IAM_User_Info
protected de.pisa.psa.com.dxhub.iam.UserInfo IAM_User_InfoIAM user information for the access token -
COOKIE_JRAUTH
cookie name: IAM authentication token- See Also:
-
-
Constructor Details
-
PsaRstApiSvcBas
public PsaRstApiSvcBas()Constructor
-
-
Method Details
-
getData
get the request data- Returns:
- data
-
setConfig
public final void setConfig(de.pisa.psa.ifc.PsaDtoDat config) set the configuration- Parameters:
config
- configuration object
-
setEvent
public final void setEvent(de.pisa.psa.ifc.PsaDtoDat event) set the event- Parameters:
event
- event object
-
getRequestHeader
get a request header value- Parameters:
key
- key of the header- Returns:
- value
-
getRequestHeaders
get all request header- Returns:
- headers
-
getRequestCookie
get a cookie from the request- Parameters:
name
- name of the cookie- Returns:
- cookie
-
getRequestPath
get the request path- Returns:
- path
-
getRequestMethod
get the request method- Returns:
- method
-
getRequestQuery
get the request query string- Returns:
- query
-
getRequestLanguages
get the acceptable languages for this request- Returns:
- list of locale (e.g. de_DE, en_US)
-
getAuthorizationHeader
get the value of the Authorization header- Returns:
- prefix and token (Strings are never null)
-
newSsn
get a new session- Returns:
- session
- Throws:
Exception
-
handleRequest
protected javax.ws.rs.core.Response handleRequest(String gid, String body, String user, String language) throws Exception handle an incoming request- Parameters:
gid
- PSC_GID of the requested recordbody
- body of the requestuser
- the session user for the eventlanguage
- language of the data to return- Returns:
- the generated response
- Throws:
Exception
-
initialize
initialize the request- Parameters:
ssn
- session- Throws:
Exception
-
loadConfiguration
protected de.pisa.psa.ifc.PsaDtoDat loadConfiguration(de.pisa.psc.srv.glb.PscSsn ssn, String method, List<String> path_tokens) throws Exception load the configuration- Parameters:
ssn
- sessionmethod
- request methodpath_tokens
- request path tokens- Returns:
- configuration dto
- Throws:
Exception
-
validateKey
validate the authorization key- Parameters:
ssn
- session- Throws:
Exception
-
validateIAM
validate the IAM token- Parameters:
ssn
- session- Throws:
Exception
-
getIAMUserInfo
protected de.pisa.psa.com.dxhub.iam.UserInfo getIAMUserInfo(de.pisa.psc.srv.glb.PscSsn ssn, String account_id, String token) throws Exception get the IAM user information- Parameters:
ssn
- sessionaccount_id
- IAM account IDtoken
- IAM token- Returns:
- information
- Throws:
Exception
- if the token is invalid
-
getIAMUserInfo
protected final de.pisa.psa.com.dxhub.iam.UserInfo getIAMUserInfo()get the current IAM user information- Returns:
- information
-
createEvent
protected void createEvent(de.pisa.psc.srv.glb.PscSsn ssn, String gid, String body, String user, String language, boolean store) throws Exception create an event record- Parameters:
ssn
- sessiongid
- PSC_GID of the requested recordbody
- body of the requestuser
- the session user for the eventlanguage
- language of the data to returnstore
- store the event record in the database?- Throws:
Exception
-
getLanguageFromRequest
get the language identifier from the requests accepted languages- Parameters:
ssn
- session- Returns:
- identifier or an empty string if the locale is unknown
- Throws:
Exception
-
isSynchronous
check if the request should be handled synchronously- Returns:
- true for a synchronous handling
- Throws:
Exception
-
processEvent
start processing the current event- Returns:
- the generated response
- Throws:
Exception
-