Class ControllerBase
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.web.context.ServletContextAware
- Direct Known Subclasses:
AuthenticationController
public class ControllerBase
extends java.lang.Object
implements org.springframework.web.context.ServletContextAware
Controller base, which contains essential ADUCID Web Platform methods. There are also predefined authentication post processing methods, which should be overridden if you want to call custom business logic:
afterCheck
- called after authentication process successful result checkafterError
- called after authentication process unsuccessful result checkbeforeLoggedInRedirect
- called before logged in redirectbeforeLogoutRedirect
- called before logout redirectbeforeErrorRedirect
- called before error redirect
When working with ADUCID Web Platform, some exceptions can occur:
AducidStatusException
- AIM status exceptionAducidClientException
- ADUCID Client API exceptionAducidWebException
- ADUCID Web Platform exception
There is limited set of exception wrappings supported:
AducidStatusException
=>AducidClientException
AducidStatusException
=>AducidClientException
=>AducidWebException
Exceptions AducidClientException and AducidWebException can also occur standalone. Exceptions architecture fully supports localization. There are interfaces:
Localizable
- forces exception to support localization message key and message argumentsDescriptive
- forces exception constructor message to support localization message key and default message
In case of ADUCID Web Platform, there is pair AducidWebException
and WebStatus
.
AducidWebException
implements Localizable interface and WebStatus
implements Descriptive
interface. All error message are automatically localized, if possible. Error messages are read from error resource bundles.
Created 12. 10. 2015 15:39:46
- Author:
- Radek Jira
-
Constructor Summary
Constructors Constructor Description ControllerBase()
-
Method Summary
Modifier and Type Method Description protected void
afterCheck(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, com.aducid.principal.AducidPrincipal principal)
Method called after check.protected java.lang.String
afterError(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, java.lang.String redirect)
Method called after error.protected java.lang.String
appendId(java.lang.String url, java.lang.String id)
Appends identifier.protected void
beforeErrorRedirect(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, com.aducid.sdk.enums.Status realStatus, AducidWebException webException, java.lang.Exception originalException, java.lang.String localizedMessage, java.lang.String realErrorPage)
Method called before error redirect.protected java.lang.String
beforeLoggedInRedirect(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, java.lang.String redirect)
Method called before logged in redirect.protected java.lang.String
beforeLogoutRedirect(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, java.lang.String redirect)
Method called before logout redirect.void
checkAnnotationConsistency()
Checks annotation consistency.protected void
forwardToAducidResourcesPage(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, java.lang.String page)
Forwards to /aducid-resources application.protected java.lang.String
generateId()
Generates identifier.java.lang.String
getAducidBinder()
Returns ADUCID Binder application context.java.lang.String
getAducidResources()
Returns ADUCID Resources application URL.protected com.aducid.sdk.AducidAdvancedClient
getAdvancedClient()
Returns ADUCID advanced client instance.java.lang.String
getAimUrl()
Returns AIM URL.protected com.aducid.sdk.pojo.RequestOperationArguments
getClientArguments(java.lang.String path, java.lang.Boolean generateQrCodePicture, javax.servlet.http.HttpServletRequest httpRequest)
Returns client arguments.protected com.aducid.sdk.pojo.RequestOperationArguments
getClientArguments(java.lang.String id, java.lang.String path, java.lang.Boolean generateQrCodePicture, javax.servlet.http.HttpServletRequest httpRequest)
Returns client arguments.protected com.aducid.sdk.pojo.RequestOperationArguments
getClientArguments(java.lang.String id, java.lang.String path, java.lang.String pushPeigId, java.lang.String tlsCertId, java.lang.String peigCssId, java.lang.String peigCssValue, java.lang.Boolean generateQrCodePicture, javax.servlet.http.HttpServletRequest httpRequest)
Returns client arguments.java.lang.String
getErrorPage()
Returns error page.protected com.aducid.sdk.json.AducidJsonClient
getJsonClient()
Returns ADUCID JSON client instance.protected java.lang.String
getLocalizedError(java.lang.Exception exception, java.util.Locale locale)
Returns localized error message.protected java.lang.String
getLocalizedLocalizable(com.aducid.sdk.common.Localizable localizable, java.util.Locale locale)
Returns localized localizable message.protected java.lang.String
getLocalizedStatusable(com.aducid.sdk.common.Statusable statusable, java.util.Locale locale)
Returns localized statusable message.protected com.aducid.sdk.pojo.RequestOperationArguments
getPushClientArguments(java.lang.String path, java.lang.String pushPeigId, java.lang.Boolean generateQrCodePicture, javax.servlet.http.HttpServletRequest httpRequest)
Returns push client arguments.protected java.lang.String
getRealAuthId(java.lang.String id, java.lang.String authId, java.lang.String authKey, javax.servlet.http.HttpServletRequest httpRequest)
Returns real authentication identifier.protected java.lang.String
getRealErrorPage(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id)
Returns real error page.protected java.lang.String
getRealPeigTypePicture(java.lang.String peigTypePicture)
Returns real PEIG type picture.protected com.aducid.sdk.enums.Status
getRealStatus(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, com.aducid.sdk.enums.Status defaultStatus)
Returns real status.protected com.aducid.sdk.pojo.GetPSLAttributesResponse
getResult(java.lang.String id, java.lang.String authId, java.lang.String authKey, javax.servlet.http.HttpServletRequest httpRequest)
Returns result.protected com.aducid.sdk.pojo.GetPSLAttributesResponse
getResultNoLFCheck(java.lang.String id, java.lang.String authId, java.lang.String authKey, javax.servlet.http.HttpServletRequest httpRequest)
Returns result without local factor success check.protected java.lang.String
getRootRedirect(javax.servlet.http.HttpServletRequest httpRequest)
Returns root redirect.javax.servlet.ServletContext
getServletContext()
Returns servlet context.protected com.aducid.sdk.AducidClient
getSimpleClient()
Returns ADUCID simple client instance.protected java.lang.String
getUrl(javax.servlet.http.HttpServletRequest request)
Builds URL from request.protected java.lang.String
getUrl(javax.servlet.http.HttpServletRequest request, java.lang.String path)
Builds URL from request and path.protected java.lang.String
getUrl(javax.servlet.http.HttpServletRequest request, java.lang.String contextPath, java.lang.String path)
Builds URL from request, context path and path.protected com.aducid.sdk.pojo.GetPSLAttributesResponse
getVerificationResult(java.lang.String id, java.lang.String authId, java.lang.String authKey, javax.servlet.http.HttpServletRequest httpRequest)
Returns verification result.protected com.aducid.sdk.pojo.GetPSLAttributesResponse
getVerifyMessageResult(java.lang.String id, java.lang.String authId, java.lang.String authKey, javax.servlet.http.HttpServletRequest httpRequest)
Returns verify message result.protected WebRequestOperationResult
getWebResult(com.aducid.sdk.pojo.RequestOperationResult clientResult, javax.servlet.http.HttpServletRequest httpRequest)
Returns web result.protected boolean
isJson(javax.servlet.http.HttpServletRequest httpRequest)
Checks JSON method call.protected org.springframework.web.servlet.ModelAndView
processWebError(AducidWebException webException, javax.servlet.http.HttpServletRequest httpRequest, java.util.Locale locale)
Processes ADUCID Web Platform exception.protected void
removeErrorFromSession(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id)
Removes error from session.protected void
setErrorToRequest(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id)
Sets error to request.void
setServletContext(javax.servlet.ServletContext servletContext)
-
Constructor Details
-
ControllerBase
public ControllerBase()
-
-
Method Details
-
setServletContext
public void setServletContext(javax.servlet.ServletContext servletContext)- Specified by:
setServletContext
in interfaceorg.springframework.web.context.ServletContextAware
-
getServletContext
public javax.servlet.ServletContext getServletContext()Returns servlet context.
- Returns:
- servlet context
-
getAimUrl
public java.lang.String getAimUrl()Returns AIM URL.
- Returns:
- AIM URL
-
getErrorPage
public java.lang.String getErrorPage()Returns error page.
- Returns:
- error page
-
getAducidResources
public java.lang.String getAducidResources()Returns ADUCID Resources application URL.
- Returns:
- ADUCID Resources application URL
-
getAducidBinder
public java.lang.String getAducidBinder()Returns ADUCID Binder application context.
- Returns:
- ADUCID Binder application context.
-
checkAnnotationConsistency
@PostConstruct public void checkAnnotationConsistency()Checks annotation consistency. Method mapping have to have the same name as method name. It is required by error processing when making decision about error type - classic HTTP response or JSON data structure.
-
afterCheck
protected void afterCheck(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, com.aducid.principal.AducidPrincipal principal) throws AducidWebExceptionMethod called after check. Method should be overridden, if you want to call custom business logic.
- Parameters:
httpRequest
- HTTP requestid
- identifierprincipal
- principal- Throws:
AducidWebException
- when error occurs during web controller call
-
afterError
protected java.lang.String afterError(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, java.lang.String redirect)Method called after error. Method should be overridden, if you want to call custom business logic.
- Parameters:
httpRequest
- HTTP requestid
- identifierredirect
- original redirect- Returns:
- URL, where to redirect user after unsuccessful login
-
beforeLoggedInRedirect
protected java.lang.String beforeLoggedInRedirect(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, java.lang.String redirect) throws AducidWebExceptionMethod called before logged in redirect. Method should be overridden, if you want to call custom business logic.
- Parameters:
httpRequest
- HTTP requestid
- identifierredirect
- original redirect- Returns:
- URL, where to redirect user instead of original redirect
- Throws:
AducidWebException
- when error occurs during web controller call
-
beforeLogoutRedirect
protected java.lang.String beforeLogoutRedirect(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, java.lang.String redirect) throws AducidWebExceptionMethod called before logout redirect. Method should be overridden, if you want to call custom business logic.
- Parameters:
httpRequest
- HTTP requestid
- identifierredirect
- original redirect- Returns:
- URL, where to redirect user instead of original redirect
- Throws:
AducidWebException
- when error occurs during web controller call
-
beforeErrorRedirect
protected void beforeErrorRedirect(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, com.aducid.sdk.enums.Status realStatus, AducidWebException webException, java.lang.Exception originalException, java.lang.String localizedMessage, java.lang.String realErrorPage)Method called before error redirect. Method should be overridden, if you want to call custom business logic.
- Parameters:
httpRequest
- HTTP requestid
- identifierrealStatus
- real statuswebException
- ADUCID Web Platform exceptionoriginalException
- original exceptionlocalizedMessage
- localized messagerealErrorPage
- real error page
-
getPushClientArguments
protected com.aducid.sdk.pojo.RequestOperationArguments getPushClientArguments(java.lang.String path, java.lang.String pushPeigId, java.lang.Boolean generateQrCodePicture, javax.servlet.http.HttpServletRequest httpRequest) throws AducidWebExceptionReturns push client arguments.
- Parameters:
path
- pathpushPeigId
- push PEIG identifiergenerateQrCodePicture
- generate QR code picture flag valuehttpRequest
- HTTP request- Returns:
- request operation arguments
- Throws:
AducidWebException
- when error occurs during web controller call
-
getClientArguments
protected com.aducid.sdk.pojo.RequestOperationArguments getClientArguments(java.lang.String path, java.lang.Boolean generateQrCodePicture, javax.servlet.http.HttpServletRequest httpRequest)Returns client arguments.
- Parameters:
path
- pathgenerateQrCodePicture
- generate QR code picture flag valuehttpRequest
- HTTP request- Returns:
- request operation arguments
-
getClientArguments
protected com.aducid.sdk.pojo.RequestOperationArguments getClientArguments(java.lang.String id, java.lang.String path, java.lang.Boolean generateQrCodePicture, javax.servlet.http.HttpServletRequest httpRequest)Returns client arguments.
- Parameters:
id
- identifierpath
- pathgenerateQrCodePicture
- generate QR code picture flag valuehttpRequest
- HTTP request- Returns:
- request operation arguments
-
getClientArguments
protected com.aducid.sdk.pojo.RequestOperationArguments getClientArguments(java.lang.String id, java.lang.String path, java.lang.String pushPeigId, java.lang.String tlsCertId, java.lang.String peigCssId, java.lang.String peigCssValue, java.lang.Boolean generateQrCodePicture, javax.servlet.http.HttpServletRequest httpRequest)Returns client arguments.
- Parameters:
id
- identifierpath
- pathpushPeigId
- push PEIG identifiertlsCertId
- TLS certificate identifierpeigCssId
- PEIG CSS identifierpeigCssValue
- PEIG CSS valuegenerateQrCodePicture
- generate QR code picture flag valuehttpRequest
- HTTP request- Returns:
- request operation arguments
-
getWebResult
protected WebRequestOperationResult getWebResult(com.aducid.sdk.pojo.RequestOperationResult clientResult, javax.servlet.http.HttpServletRequest httpRequest)Returns web result.
- Parameters:
clientResult
- client resulthttpRequest
- HTTP request- Returns:
- web request operation result
-
getRealAuthId
protected java.lang.String getRealAuthId(java.lang.String id, java.lang.String authId, java.lang.String authKey, javax.servlet.http.HttpServletRequest httpRequest) throws AducidWebExceptionReturns real authentication identifier.
- Parameters:
id
- identifierauthId
- authentication identifierauthKey
- authentication keyhttpRequest
- HTTP request- Returns:
- real authentication identifier
- Throws:
AducidWebException
- when error occurs during web controller call
-
getResult
protected com.aducid.sdk.pojo.GetPSLAttributesResponse getResult(java.lang.String id, java.lang.String authId, java.lang.String authKey, javax.servlet.http.HttpServletRequest httpRequest) throws AducidWebExceptionReturns result.
- Parameters:
id
- identifierauthId
- authentication identifierauthKey
- authentication keyhttpRequest
- HTTP request- Returns:
- result
- Throws:
AducidWebException
- when error occurs during web controller call
-
getResultNoLFCheck
protected com.aducid.sdk.pojo.GetPSLAttributesResponse getResultNoLFCheck(java.lang.String id, java.lang.String authId, java.lang.String authKey, javax.servlet.http.HttpServletRequest httpRequest) throws AducidWebExceptionReturns result without local factor success check.
- Parameters:
id
- identifierauthId
- authentication identifierauthKey
- authentication keyhttpRequest
- HTTP request- Returns:
- result
- Throws:
AducidWebException
- when error occurs during web controller call
-
getVerifyMessageResult
protected com.aducid.sdk.pojo.GetPSLAttributesResponse getVerifyMessageResult(java.lang.String id, java.lang.String authId, java.lang.String authKey, javax.servlet.http.HttpServletRequest httpRequest) throws AducidWebExceptionReturns verify message result.
- Parameters:
id
- identifierauthId
- authentication identifierauthKey
- authentication keyhttpRequest
- HTTP request- Returns:
- result
- Throws:
AducidWebException
- when error occurs during web controller call
-
getVerificationResult
protected com.aducid.sdk.pojo.GetPSLAttributesResponse getVerificationResult(java.lang.String id, java.lang.String authId, java.lang.String authKey, javax.servlet.http.HttpServletRequest httpRequest) throws AducidWebExceptionReturns verification result.
- Parameters:
id
- identifierauthId
- authentication identifierauthKey
- authentication keyhttpRequest
- HTTP request- Returns:
- result
- Throws:
AducidWebException
- when error occurs during web controller call
-
getLocalizedError
protected java.lang.String getLocalizedError(java.lang.Exception exception, java.util.Locale locale)Returns localized error message.
- Parameters:
exception
- common exceptionlocale
- locale- Returns:
- localized error message
-
getLocalizedLocalizable
protected java.lang.String getLocalizedLocalizable(com.aducid.sdk.common.Localizable localizable, java.util.Locale locale)Returns localized localizable message.
- Parameters:
localizable
- localizable exceptionlocale
- locale- Returns:
- localized localizable message
-
getLocalizedStatusable
protected java.lang.String getLocalizedStatusable(com.aducid.sdk.common.Statusable statusable, java.util.Locale locale)Returns localized statusable message.
- Parameters:
statusable
- statusable exceptionlocale
- locale- Returns:
- localized statusable message
-
getJsonClient
Returns ADUCID JSON client instance.
- Returns:
- ADUCID JSON client instance
- Throws:
AducidWebException
- when error occurs during web controller call
-
getAdvancedClient
Returns ADUCID advanced client instance.
- Returns:
- ADUCID advanced client instance
- Throws:
AducidWebException
- when error occurs during web controller call
-
getSimpleClient
Returns ADUCID simple client instance.
- Returns:
- ADUCID simple client instance
- Throws:
AducidWebException
- when error occurs during web controller call
-
getUrl
protected java.lang.String getUrl(javax.servlet.http.HttpServletRequest request)Builds URL from request.
- Parameters:
request
- HTTP request- Returns:
- URL
-
getUrl
protected java.lang.String getUrl(javax.servlet.http.HttpServletRequest request, java.lang.String path)Builds URL from request and path.
- Parameters:
request
- HTTP requestpath
- path- Returns:
- URL
-
getUrl
protected java.lang.String getUrl(javax.servlet.http.HttpServletRequest request, java.lang.String contextPath, java.lang.String path)Builds URL from request, context path and path.
- Parameters:
request
- HTTP requestcontextPath
- context pathpath
- path- Returns:
- URL
-
getRealPeigTypePicture
protected java.lang.String getRealPeigTypePicture(java.lang.String peigTypePicture)Returns real PEIG type picture.
- Parameters:
peigTypePicture
- PEIG type picture- Returns:
- real PEIG type picture
-
forwardToAducidResourcesPage
protected void forwardToAducidResourcesPage(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse, java.lang.String page) throws AducidWebExceptionForwards to /aducid-resources application.
- Parameters:
httpRequest
- HTTP requesthttpResponse
- HTTP responsepage
- page- Throws:
AducidWebException
- when error occurs during web controller call
-
isJson
protected boolean isJson(javax.servlet.http.HttpServletRequest httpRequest)Checks JSON method call.
- Parameters:
httpRequest
- HTTP request- Returns:
- true, if method call is JSON
-
getRootRedirect
protected java.lang.String getRootRedirect(javax.servlet.http.HttpServletRequest httpRequest)Returns root redirect.
- Parameters:
httpRequest
- HTTP request- Returns:
- root redirect
-
getRealErrorPage
protected java.lang.String getRealErrorPage(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id)Returns real error page.
- Parameters:
httpRequest
- HTTP requestid
- identifier- Returns:
- real error page
-
getRealStatus
protected com.aducid.sdk.enums.Status getRealStatus(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id, com.aducid.sdk.enums.Status defaultStatus)Returns real status.
- Parameters:
httpRequest
- HTTP requestid
- identifierdefaultStatus
- default status- Returns:
- real status
-
processWebError
@ExceptionHandler(AducidWebException.class) protected org.springframework.web.servlet.ModelAndView processWebError(AducidWebException webException, javax.servlet.http.HttpServletRequest httpRequest, java.util.Locale locale)Processes ADUCID Web Platform exception.
- Parameters:
webException
- ADUCID Web Platform exceptionhttpRequest
- HTTP requestlocale
- locale- Returns:
- model and view
-
removeErrorFromSession
protected void removeErrorFromSession(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id)Removes error from session.
- Parameters:
httpRequest
- HTTP requestid
- identifier
-
setErrorToRequest
protected void setErrorToRequest(javax.servlet.http.HttpServletRequest httpRequest, java.lang.String id)Sets error to request.
- Parameters:
httpRequest
- HTTP requestid
- identifier
-
generateId
protected java.lang.String generateId()Generates identifier.
- Returns:
- identifier
-
appendId
protected java.lang.String appendId(java.lang.String url, java.lang.String id)Appends identifier.
- Parameters:
url
- URLid
- identifier- Returns:
- URL with identifier
-