Search in sources :

Example 1 with OperationCompletionRS

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");
}
Also used : OAuth2LoginDetails(com.epam.ta.reportportal.database.entity.settings.OAuth2LoginDetails) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ServerSettings(com.epam.ta.reportportal.database.entity.settings.ServerSettings) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with OperationCompletionRS

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");
}
Also used : Serializable(java.io.Serializable) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with OperationCompletionRS

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());
}
Also used : OAuthRegistration(com.epam.ta.reportportal.entity.oauth.OAuthRegistration) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Example 4 with OperationCompletionRS

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.");
}
Also used : Integration(com.epam.ta.reportportal.entity.integration.Integration) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) SamlProvidersReloadEvent(com.epam.reportportal.auth.event.SamlProvidersReloadEvent) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)4 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)3 ApiOperation (io.swagger.annotations.ApiOperation)2 SamlProvidersReloadEvent (com.epam.reportportal.auth.event.SamlProvidersReloadEvent)1 OAuth2LoginDetails (com.epam.ta.reportportal.database.entity.settings.OAuth2LoginDetails)1 ServerSettings (com.epam.ta.reportportal.database.entity.settings.ServerSettings)1 Integration (com.epam.ta.reportportal.entity.integration.Integration)1 OAuthRegistration (com.epam.ta.reportportal.entity.oauth.OAuthRegistration)1 Serializable (java.io.Serializable)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1