Class DefaultContextHelperService
- java.lang.Object
-
- com.broadleafcommerce.auth.client.service.DefaultContextHelperService
-
- All Implemented Interfaces:
ContextHelperService
public class DefaultContextHelperService extends Object implements ContextHelperService
This class uses the RequestContextHolder to read the client_id for the current request, then looks up the corresponding tenant id.
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthorizationServerService<AuthorizationServer>authorizationServerServiceprotected AuthorizedClientService<AuthorizedClient>authorizedClientService
-
Constructor Summary
Constructors Constructor Description DefaultContextHelperService(AuthorizedClientService<AuthorizedClient> authorizedClientService, AuthorizationServerService<AuthorizationServer> authorizationServerService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AuthorizationServergetAuthorizationServer(String serverId)Finds theAuthorizationServerfor the given server IDprotected AuthorizationServerService<AuthorizationServer>getAuthorizationServerService()protected AuthorizedClientgetAuthorizedClient(String clientId)Finds theAuthorizedClientcorresponding to the given client IDprotected AuthorizedClientService<AuthorizedClient>getAuthorizedClientService()StringgetClientId()Get the client id from the request contextStringgetTenantId()Use the client id from the request context to look up the tenant idvoidsetClientId(String clientId)Set the client id on the request context
-
-
-
Field Detail
-
authorizedClientService
protected final AuthorizedClientService<AuthorizedClient> authorizedClientService
-
authorizationServerService
protected final AuthorizationServerService<AuthorizationServer> authorizationServerService
-
-
Constructor Detail
-
DefaultContextHelperService
public DefaultContextHelperService(AuthorizedClientService<AuthorizedClient> authorizedClientService, AuthorizationServerService<AuthorizationServer> authorizationServerService)
-
-
Method Detail
-
getClientId
public String getClientId()
Description copied from interface:ContextHelperServiceGet the client id from the request context- Specified by:
getClientIdin interfaceContextHelperService- Returns:
-
setClientId
public void setClientId(String clientId)
Description copied from interface:ContextHelperServiceSet the client id on the request context- Specified by:
setClientIdin interfaceContextHelperService
-
getTenantId
public String getTenantId()
Description copied from interface:ContextHelperServiceUse the client id from the request context to look up the tenant id- Specified by:
getTenantIdin interfaceContextHelperService- Returns:
-
getAuthorizedClient
protected AuthorizedClient getAuthorizedClient(String clientId)
Finds theAuthorizedClientcorresponding to the given client ID- Parameters:
clientId- The client id from the web request- Returns:
- the authorized client from the datastore that matches the given client ID
- Throws:
IllegalArgumentException- if the client was not found
-
getAuthorizationServer
protected AuthorizationServer getAuthorizationServer(String serverId)
Finds theAuthorizationServerfor the given server ID- Parameters:
serverId- the id of the authorization server to retrieve- Returns:
- the authorization server from the datastore matching the given serverID
- Throws:
IllegalArgumentException- if the authorization server was not found
-
getAuthorizedClientService
protected AuthorizedClientService<AuthorizedClient> getAuthorizedClientService()
-
getAuthorizationServerService
protected AuthorizationServerService<AuthorizationServer> getAuthorizationServerService()
-
-