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>
authorizationServerService
protected 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 AuthorizationServer
getAuthorizationServer(String serverId)
Finds theAuthorizationServer
for the given server IDprotected AuthorizationServerService<AuthorizationServer>
getAuthorizationServerService()
protected AuthorizedClient
getAuthorizedClient(String clientId)
Finds theAuthorizedClient
corresponding to the given client IDprotected AuthorizedClientService<AuthorizedClient>
getAuthorizedClientService()
String
getClientId()
Get the client id from the request contextString
getTenantId()
Use the client id from the request context to look up the tenant idvoid
setClientId(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:ContextHelperService
Get the client id from the request context- Specified by:
getClientId
in interfaceContextHelperService
- Returns:
-
setClientId
public void setClientId(String clientId)
Description copied from interface:ContextHelperService
Set the client id on the request context- Specified by:
setClientId
in interfaceContextHelperService
-
getTenantId
public String getTenantId()
Description copied from interface:ContextHelperService
Use the client id from the request context to look up the tenant id- Specified by:
getTenantId
in interfaceContextHelperService
- Returns:
-
getAuthorizedClient
protected AuthorizedClient getAuthorizedClient(String clientId)
Finds theAuthorizedClient
corresponding 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 theAuthorizationServer
for 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()
-
-