use of io.gravitee.rest.api.service.impl.configuration.application.registration.client.register.ClientRegistrationRequest in project gravitee-management-rest-api by gravitee-io.
the class ClientRegistrationServiceImpl method convert.
private ClientRegistrationRequest convert(NewApplicationEntity application) {
ClientRegistrationRequest request = new ClientRegistrationRequest();
request.setClientName(application.getName());
request.setApplicationType(application.getSettings().getoAuthClient().getApplicationType());
request.setClientUri(application.getSettings().getoAuthClient().getClientUri());
request.setGrantTypes(application.getSettings().getoAuthClient().getGrantTypes());
request.setLogoUri(application.getSettings().getoAuthClient().getLogoUri());
request.setRedirectUris(application.getSettings().getoAuthClient().getRedirectUris());
request.setResponseTypes(application.getSettings().getoAuthClient().getResponseTypes());
return request;
}
use of io.gravitee.rest.api.service.impl.configuration.application.registration.client.register.ClientRegistrationRequest in project gravitee-management-rest-api by gravitee-io.
the class ClientRegistrationServiceImpl method register.
@Override
public ClientRegistrationResponse register(NewApplicationEntity application) {
// Create an OAuth client
Set<ClientRegistrationProviderEntity> providers = findAll();
if (providers == null || providers.isEmpty()) {
throw new MissingDynamicClientRegistrationProviderException();
}
// For now, took the first provider
ClientRegistrationProviderEntity provider = providers.iterator().next();
// Get provider client
DynamicClientRegistrationProviderClient registrationProviderClient = getDCRClient(false, provider);
ClientRegistrationRequest clientRegistrationRequest = convert(application);
if (provider.getSoftwareId() != null && !provider.getSoftwareId().isEmpty()) {
clientRegistrationRequest.setSoftwareId(provider.getSoftwareId());
}
return registrationProviderClient.register(clientRegistrationRequest);
}
use of io.gravitee.rest.api.service.impl.configuration.application.registration.client.register.ClientRegistrationRequest in project gravitee-management-rest-api by gravitee-io.
the class ClientRegistrationServiceImpl method update.
@Override
public ClientRegistrationResponse update(String previousRegistrationResponse, UpdateApplicationEntity application) {
try {
ClientRegistrationResponse registrationResponse = mapper.readValue(previousRegistrationResponse, ClientRegistrationResponse.class);
if (registrationResponse.getRegistrationAccessToken() == null || registrationResponse.getRegistrationAccessToken().isEmpty() || registrationResponse.getRegistrationClientUri() == null || registrationResponse.getRegistrationClientUri().isEmpty()) {
throw new RegisteredClientNotUpdatableException();
}
// Update an OAuth client
Set<ClientRegistrationProviderEntity> providers = findAll();
if (providers == null || providers.isEmpty()) {
throw new MissingDynamicClientRegistrationProviderException();
}
// For now, took the first provider
ClientRegistrationProviderEntity provider = providers.iterator().next();
// Get provider client
DynamicClientRegistrationProviderClient registrationProviderClient = getDCRClient(false, provider);
ClientRegistrationRequest registrationRequest = mapper.readValue(previousRegistrationResponse, ClientRegistrationRequest.class);
registrationRequest.setSoftwareId(provider.getSoftwareId());
return registrationProviderClient.update(registrationResponse.getRegistrationAccessToken(), registrationResponse.getRegistrationClientUri(), convert(registrationRequest, application), application.getSettings().getoAuthClient().getClientId());
} catch (Exception ex) {
LOGGER.error("Unexpected error while updating a client", ex);
return null;
}
}
Aggregations