Class TppEngineClient
java.lang.Object
io.getlime.security.powerauth.lib.tpp.engine.client.TppEngineClient
public class TppEngineClient
extends java.lang.Object
TPP Engine Client provides methods for communication with the TPP registry and consent engine.
It uses the RestTemplate class to handle REST API calls. Apache HTTP client is used instead of default client
so that error responses contain full response bodies.
- Author:
- Petr Dvorak, petr@wultra.com
-
Constructor Summary
Constructors Constructor Description TppEngineClient(java.lang.String serviceUrl)Create a new client with provided base URL.TppEngineClient(java.lang.String serviceUrl, com.fasterxml.jackson.databind.ObjectMapper objectMapper)Create a new client with provided base URL and custom object mapper. -
Method Summary
Modifier and Type Method Description io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.ConsentDetailResponse>consentDetail(java.lang.String id)Lookup consent details (details of a consent template).io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.UserConsentDetailResponse>consentStatus(java.lang.String userId, java.lang.String consentId, java.lang.String clientId)Lookup consent status for given user and app.io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse>createApplication(io.getlime.security.powerauth.app.tppengine.model.request.CreateTppAppRequest request)Create an application with provided information.io.getlime.core.rest.model.base.response.ResponsedeleteApplication(java.lang.String clientId, java.lang.String tppLicense)Delete an application with provided information.io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse>fetchAppInfo(java.lang.String clientId)Lookup information about a provided app.io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse>fetchAppInfoWithLicenseRestriction(java.lang.String clientId, java.lang.String tppLicense)Lookup information about a provided app.io.getlime.core.rest.model.base.response.ObjectResponse<java.util.List<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse>>fetchApplicationList(java.lang.String tppLicense)Fetch list of TPP applications based on the license info.org.springframework.web.client.RestTemplategetRestTemplate()Get default instance of REST client.io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.GiveConsentResponse>giveConsent(io.getlime.security.powerauth.app.tppengine.model.request.GiveConsentRequest request)Give consent according to request parameters.io.getlime.core.rest.model.base.response.ResponserejectConsent(io.getlime.security.powerauth.app.tppengine.model.request.RemoveConsentRequest request)Reject consent according to request parameters.io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse>renewClientSecret(java.lang.String clientId, java.lang.String tppLicense)Renew the client secret for the application.io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse>updateApplication(java.lang.String clientId, io.getlime.security.powerauth.app.tppengine.model.request.CreateTppAppRequest request)Update an application with provided client ID with a new information.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
TppEngineClient
public TppEngineClient(java.lang.String serviceUrl)Create a new client with provided base URL.- Parameters:
serviceUrl- Base URL.
-
TppEngineClient
public TppEngineClient(java.lang.String serviceUrl, com.fasterxml.jackson.databind.ObjectMapper objectMapper)Create a new client with provided base URL and custom object mapper.- Parameters:
serviceUrl- Base URL.objectMapper- Object mapper.
-
-
Method Details
-
getRestTemplate
public org.springframework.web.client.RestTemplate getRestTemplate()Get default instance of REST client.- Returns:
- RestTemplate with default configuration.
-
consentDetail
public io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.ConsentDetailResponse> consentDetail(java.lang.String id) throws TppEngineClientExceptionLookup consent details (details of a consent template).- Parameters:
id- Username for user account which is being looked up.- Returns:
- Response with user details.
- Throws:
TppEngineClientException- Thrown when client request fails or user does not exist.
-
consentStatus
public io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.UserConsentDetailResponse> consentStatus(java.lang.String userId, java.lang.String consentId, java.lang.String clientId) throws TppEngineClientExceptionLookup consent status for given user and app.- Parameters:
userId- Username for user account which is being looked up.consentId- Identifier of a consent.clientId- Identifier of a TPP app.- Returns:
- Response with details of consent for given user and TPP app.
- Throws:
TppEngineClientException- Thrown when client request fails or user does not exist.
-
giveConsent
public io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.GiveConsentResponse> giveConsent(io.getlime.security.powerauth.app.tppengine.model.request.GiveConsentRequest request) throws TppEngineClientExceptionGive consent according to request parameters.- Parameters:
request- Consent information.- Returns:
- Information about newly created consent.
- Throws:
TppEngineClientException- Thrown when client request fails or authentication fails.
-
rejectConsent
public io.getlime.core.rest.model.base.response.Response rejectConsent(io.getlime.security.powerauth.app.tppengine.model.request.RemoveConsentRequest request) throws TppEngineClientExceptionReject consent according to request parameters.- Parameters:
request- Consent information.- Returns:
- Static OK response. In case consent didn't exist, this operation is no-op.
- Throws:
TppEngineClientException- Thrown when client request fails or authentication fails.
-
fetchAppInfo
public io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse> fetchAppInfo(java.lang.String clientId) throws TppEngineClientExceptionLookup information about a provided app.- Parameters:
clientId- Identifier of a TPP app.- Returns:
- Response with details TPP app with given client ID.
- Throws:
TppEngineClientException- Thrown when client request fails or app does not exist.
-
fetchAppInfoWithLicenseRestriction
public io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse> fetchAppInfoWithLicenseRestriction(java.lang.String clientId, java.lang.String tppLicense) throws TppEngineClientExceptionLookup information about a provided app.- Parameters:
clientId- Identifier of a TPP app.tppLicense- TPP license information.- Returns:
- Response with details TPP app with given client ID.
- Throws:
TppEngineClientException- Thrown when client request fails or app does not exist.
-
fetchApplicationList
public io.getlime.core.rest.model.base.response.ObjectResponse<java.util.List<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse>> fetchApplicationList(java.lang.String tppLicense) throws TppEngineClientExceptionFetch list of TPP applications based on the license info.- Parameters:
tppLicense- TPP license information.- Returns:
- Response with details TPP app with given client ID.
- Throws:
TppEngineClientException- Thrown when client request fails or app does not exist.
-
createApplication
public io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse> createApplication(io.getlime.security.powerauth.app.tppengine.model.request.CreateTppAppRequest request) throws TppEngineClientExceptionCreate an application with provided information.- Parameters:
request- New application information.- Returns:
- Information about newly created application.
- Throws:
TppEngineClientException- Thrown when client request fails or user does not exist.
-
updateApplication
public io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse> updateApplication(java.lang.String clientId, io.getlime.security.powerauth.app.tppengine.model.request.CreateTppAppRequest request) throws TppEngineClientExceptionUpdate an application with provided client ID with a new information.- Parameters:
clientId- Client ID of an app to be updated.request- New application information.- Returns:
- Information about newly created application.
- Throws:
TppEngineClientException- Thrown when client request fails or user does not exist.
-
renewClientSecret
public io.getlime.core.rest.model.base.response.ObjectResponse<io.getlime.security.powerauth.app.tppengine.model.response.TppAppDetailResponse> renewClientSecret(java.lang.String clientId, java.lang.String tppLicense) throws TppEngineClientExceptionRenew the client secret for the application.- Parameters:
clientId- Client ID of an application to be refreshed.tppLicense- License information of TPP.- Returns:
- Information about newly created application.
- Throws:
TppEngineClientException- Thrown when client request fails or user does not exist.
-
deleteApplication
public io.getlime.core.rest.model.base.response.Response deleteApplication(java.lang.String clientId, java.lang.String tppLicense) throws TppEngineClientExceptionDelete an application with provided information.- Parameters:
clientId- Client ID of the app.tppLicense- License information of TPP.- Returns:
- Generic response.
- Throws:
TppEngineClientException- Thrown when client request fails or user does not exist.
-