use of com.epam.ta.reportportal.ws.model.OperationCompletionRS in project service-authorization by reportportal.
the class OAuthConfigurationEndpoint method deleteOAuthSetting.
/**
* Deletes oauth integration settings
*
* @param profileId settings ProfileID
* @param oauthProviderName ID of third-party OAuth provider
* @return All defined OAuth integration settings
*/
@RequestMapping(value = "/{authId}", method = { DELETE })
@ResponseBody
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "Deletes OAuth Integration Settings", notes = "'default' profile is using till additional UI implementations")
public OperationCompletionRS deleteOAuthSetting(@PathVariable String profileId, @PathVariable("authId") String oauthProviderName) {
ServerSettings settings = repository.findOne(profileId);
BusinessRule.expect(settings, Predicates.notNull()).verify(ErrorType.SERVER_SETTINGS_NOT_FOUND, profileId);
Map<String, OAuth2LoginDetails> serverOAuthDetails = Optional.of(settings.getoAuth2LoginDetails()).orElse(new HashMap<>());
if (null != serverOAuthDetails.remove(oauthProviderName)) {
settings.setoAuth2LoginDetails(serverOAuthDetails);
repository.save(settings);
} else {
throw new ReportPortalException(ErrorType.OAUTH_INTEGRATION_NOT_FOUND);
}
return new OperationCompletionRS("Auth settings '" + oauthProviderName + "' were successfully removed");
}
use of com.epam.ta.reportportal.ws.model.OperationCompletionRS in project service-authorization by reportportal.
the class GithubEndpoint method synchronize.
@ApiOperation(value = "Synchronizes logged-in GitHub user")
@RequestMapping(value = { "/sso/me/github/synchronize" }, method = RequestMethod.POST)
public OperationCompletionRS synchronize(OAuth2Authentication user) {
Serializable upstreamToken = user.getOAuth2Request().getExtensions().get(UPSTREAM_TOKEN);
BusinessRule.expect(upstreamToken, Objects::nonNull).verify(ErrorType.INCORRECT_AUTHENTICATION_TYPE, "Cannot synchronize GitHub User");
this.replicator.synchronizeUser(upstreamToken.toString());
return new OperationCompletionRS("User info successfully synchronized");
}
use of com.epam.ta.reportportal.ws.model.OperationCompletionRS in project service-authorization by reportportal.
the class DeleteAuthIntegrationHandlerImpl method deleteOauthSettingsById.
@Override
public OperationCompletionRS deleteOauthSettingsById(String oauthProviderId) {
OAuthRegistration oAuthRegistration = clientRegistrationRepository.findOAuthRegistrationById(oauthProviderId).orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND, Suppliers.formattedSupplier("Oauth settings with id = {} have not been found.", oauthProviderId).get()));
clientRegistrationRepository.deleteById(oAuthRegistration.getId());
return new OperationCompletionRS(Suppliers.formattedSupplier("Oauth settings with id = '{}' have been successfully removed.", oauthProviderId).get());
}
use of com.epam.ta.reportportal.ws.model.OperationCompletionRS in project service-authorization by reportportal.
the class DeleteAuthIntegrationHandlerImpl method deleteAuthIntegrationById.
@Override
public OperationCompletionRS deleteAuthIntegrationById(Long integrationId) {
Integration integration = integrationRepository.findById(integrationId).orElseThrow(() -> new ReportPortalException(ErrorType.INTEGRATION_NOT_FOUND, integrationId));
BusinessRule.expect(integration.getType().getIntegrationGroup(), equalTo(IntegrationGroupEnum.AUTH)).verify(ErrorType.BAD_REQUEST_ERROR, "Integration should have an 'AUTH' integration group type.");
integrationRepository.deleteById(integrationId);
if (AuthIntegrationType.SAML.getName().equals(integration.getType().getName())) {
eventPublisher.publishEvent(new SamlProvidersReloadEvent(integration.getType()));
}
return new OperationCompletionRS("Auth integration with id= " + integrationId + " has been successfully removed.");
}
Aggregations