public class DefaultAuthorizedClientService<P extends AuthorizedClient,D extends com.broadleafcommerce.data.tracking.core.mapping.ModelMapperMappable & com.broadleafcommerce.data.tracking.core.mapping.BusinessTypeAware> extends Object implements AuthorizedClientService<P>
Constructor and Description |
---|
DefaultAuthorizedClientService(AuthorizationServerService<AuthorizationServer> serverService,
AuthorizedClientRepository<D> repository,
SimplePayloadMapper mapper,
com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager validator,
org.springframework.security.crypto.password.PasswordEncoder passwordEncoder,
TenantUrlResolver tenantUrlResolver) |
Modifier and Type | Method and Description |
---|---|
P |
create(P authorizedClient)
Create a new authorized client.
|
void |
delete(P authorizedClient)
Delete an authorized client.
|
void |
deleteById(String id)
Delete an authorized client by ID.
|
boolean |
existsById(String id)
Check if an authorized client exists by its ID.
|
Optional<P> |
findAdminClient(String tenantId)
Finds the authorized client for the admin within the given context.
|
org.springframework.data.domain.Page<P> |
findAll(org.springframework.data.domain.Pageable pageable)
Find all authorized clients.
|
org.springframework.data.domain.Page<P> |
findAllByServerId(String serverId,
org.springframework.data.domain.Pageable pageable)
Finds all authorized clients within an authorization server.
|
Optional<P> |
findApplicationClient(String applicationId)
Finds the authorized client for the application within the given context.
|
Optional<P> |
findApplicationClient(String applicationId,
String tenantId)
Finds the authorized client for the application within the given context.
|
Optional<P> |
findByClientId(String authorizedClientId)
Find an authorized client by its client ID.
|
Optional<P> |
findById(String id)
Find an authorized client by its ID.
|
protected Optional<D> |
findRepositoryDomainById(String id) |
protected Optional<P> |
fromRepositoryDomain(Optional<D> optionalDomain) |
protected org.springframework.data.domain.Page<P> |
fromRepositoryDomain(org.springframework.data.domain.Page<D> page) |
protected String |
generateAuthorizedClientId(P authorizedClient)
Generates a Base64, 16-bit string appended with the server name as the client ID for a newly
created authorized client.
|
protected SimplePayloadMapper |
getMapper() |
protected org.springframework.security.crypto.password.PasswordEncoder |
getPasswordEncoder() |
protected AuthorizedClientRepository<D> |
getRepository() |
protected AuthorizationServerService<AuthorizationServer> |
getServerService() |
protected TenantUrlResolver |
getTenantUrlResolver() |
protected com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager |
getValidator() |
P |
replace(String id,
P authorizedClient)
Replace an authorized client.
|
Optional<String> |
resolveAbsolutePathForUri(String uri,
AuthorizedClient client)
Resolves the absolute path for the string uri provided
|
Optional<String> |
resolveAbsolutePathsForRelativeDefaultRedirectUri(AuthorizedClient client)
Resolves the absolute path for the default redirect uri on the provided
AuthorizedClient |
Set<String> |
resolveAbsolutePathsForRelativeRedirectUris(AuthorizedClient client)
Resolves the absolute path for the redirect uris on the provided
AuthorizedClient |
Set<String> |
resolveAbsolutePathsForUris(Set<String> uris,
AuthorizedClient client)
Resolves the absolute path for the string uris provided
|
protected Optional<org.springframework.web.util.UriComponentsBuilder> |
resolveBaseUri(AuthorizedClient client)
Determines the base URI of the application or admin the client is used for.
|
P |
save(P authorizedClient)
Save an authorized client.
|
protected void |
validate(P authorizedClient) |
protected void |
validateUniqueAdminClientPerTenant(P authorizedClient,
org.springframework.validation.Errors errors) |
public DefaultAuthorizedClientService(AuthorizationServerService<AuthorizationServer> serverService, AuthorizedClientRepository<D> repository, SimplePayloadMapper mapper, com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager validator, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder, TenantUrlResolver tenantUrlResolver)
public org.springframework.data.domain.Page<P> findAll(org.springframework.data.domain.Pageable pageable)
AuthorizedClientService
findAll
in interface AuthorizedClientService<P extends AuthorizedClient>
pageable
- the pageablepublic org.springframework.data.domain.Page<P> findAllByServerId(String serverId, org.springframework.data.domain.Pageable pageable)
AuthorizedClientService
findAllByServerId
in interface AuthorizedClientService<P extends AuthorizedClient>
serverId
- the server IDpageable
- the pageablepublic Optional<P> findAdminClient(String tenantId)
AuthorizedClientService
findAdminClient
in interface AuthorizedClientService<P extends AuthorizedClient>
public Optional<P> findApplicationClient(String applicationId, String tenantId)
AuthorizedClientService
findApplicationClient
in interface AuthorizedClientService<P extends AuthorizedClient>
public Optional<P> findApplicationClient(String applicationId)
AuthorizedClientService
findApplicationClient
in interface AuthorizedClientService<P extends AuthorizedClient>
public boolean existsById(String id)
AuthorizedClientService
existsById
in interface AuthorizedClientService<P extends AuthorizedClient>
id
- the authorized client IDpublic Optional<P> findById(String id)
AuthorizedClientService
findById
in interface AuthorizedClientService<P extends AuthorizedClient>
id
- the authorized client IDpublic Optional<P> findByClientId(String authorizedClientId)
AuthorizedClientService
findByClientId
in interface AuthorizedClientService<P extends AuthorizedClient>
authorizedClientId
- the client ID of the authorization clientpublic P create(P authorizedClient)
AuthorizedClientService
AuthorizedClient#getServer()
must not be null.create
in interface AuthorizedClientService<P extends AuthorizedClient>
authorizedClient
- the authorized client to createprotected String generateAuthorizedClientId(P authorizedClient)
authorizedClient
- the new authorized clientpublic P save(P authorizedClient)
AuthorizedClientService
save
in interface AuthorizedClientService<P extends AuthorizedClient>
authorizedClient
- the authorized client to savepublic P replace(String id, P authorizedClient)
AuthorizedClientService
replace
in interface AuthorizedClientService<P extends AuthorizedClient>
id
- the authorized client ID to replaceauthorizedClient
- the authorized client replacementpublic void delete(P authorizedClient)
AuthorizedClientService
delete
in interface AuthorizedClientService<P extends AuthorizedClient>
authorizedClient
- the authorized client to deletepublic void deleteById(String id)
AuthorizedClientService
deleteById
in interface AuthorizedClientService<P extends AuthorizedClient>
id
- the ID of the authorized client to deletepublic Optional<String> resolveAbsolutePathsForRelativeDefaultRedirectUri(AuthorizedClient client)
AuthorizedClientService
AuthorizedClient
resolveAbsolutePathsForRelativeDefaultRedirectUri
in interface AuthorizedClientService<P extends AuthorizedClient>
client
- The AuthorizedClient
to resolve the default redirect uri forAuthorizedClient
if one is resolved else an empty Optional
public Set<String> resolveAbsolutePathsForRelativeRedirectUris(AuthorizedClient client)
AuthorizedClientService
AuthorizedClient
resolveAbsolutePathsForRelativeRedirectUris
in interface AuthorizedClientService<P extends AuthorizedClient>
client
- The AuthorizedClient
to resolve the redirect uris forAuthorizedClient
that could be resolvedpublic Optional<String> resolveAbsolutePathForUri(String uri, AuthorizedClient client)
AuthorizedClientService
resolveAbsolutePathForUri
in interface AuthorizedClientService<P extends AuthorizedClient>
uri
- The uri to resolve the absolute path forclient
- The AuthorizedClient
to use for finding the domain, host, etc.Optional
public Set<String> resolveAbsolutePathsForUris(Set<String> uris, AuthorizedClient client)
AuthorizedClientService
resolveAbsolutePathsForUris
in interface AuthorizedClientService<P extends AuthorizedClient>
uris
- The uris to resolve absolute paths forclient
- The AuthorizedClient
to use for finding the domain, host, etc.protected Optional<org.springframework.web.util.UriComponentsBuilder> resolveBaseUri(AuthorizedClient client)
Delegates to TenantUrlResolver
.
To preserve best-effort for the remainder of the flow, this method will not throw
exceptions. Errors will be gracefully logged, and Optional.empty()
will be
returned.
client
- the client whose admin or application base URI needs to be foundUriComponentsBuilder
representing the base URI if successfully found,
Optional.empty()
otherwiseprotected org.springframework.data.domain.Page<P> fromRepositoryDomain(org.springframework.data.domain.Page<D> page)
protected void validate(P authorizedClient)
protected void validateUniqueAdminClientPerTenant(P authorizedClient, org.springframework.validation.Errors errors)
protected AuthorizationServerService<AuthorizationServer> getServerService()
protected AuthorizedClientRepository<D> getRepository()
protected SimplePayloadMapper getMapper()
protected com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidatorManager getValidator()
protected org.springframework.security.crypto.password.PasswordEncoder getPasswordEncoder()
protected TenantUrlResolver getTenantUrlResolver()
Copyright © 2021. All rights reserved.