Search in sources :

Example 1 with OAuthRegistration

use of com.epam.ta.reportportal.entity.oauth.OAuthRegistration in project service-authorization by reportportal.

the class CreateAuthIntegrationHandlerImpl method createOrUpdateOauthSettings.

@Override
public OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource) {
    OAuthRegistration oAuthRegistration = OAuthProviderFactory.fillOAuthRegistration(oauthProviderId, clientRegistrationResource);
    OAuthRegistration updatedOauthRegistration = clientRegistrationRepository.findOAuthRegistrationById(oauthProviderId).map(existingRegistration -> {
        clientRegistrationRepository.deleteById(existingRegistration.getId());
        oAuthRegistration.setId(existingRegistration.getId());
        return oAuthRegistration;
    }).orElse(oAuthRegistration);
    return OAuthRegistrationConverters.TO_RESOURCE.apply(clientRegistrationRepository.save(updatedOauthRegistration));
}
Also used : OAuthRegistration(com.epam.ta.reportportal.entity.oauth.OAuthRegistration) AuthIntegrationType(com.epam.reportportal.auth.integration.AuthIntegrationType) OAuthRegistrationConverters(com.epam.reportportal.auth.integration.converter.OAuthRegistrationConverters) UpdateAuthRQ(com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ) Integration(com.epam.ta.reportportal.entity.integration.Integration) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Autowired(org.springframework.beans.factory.annotation.Autowired) IntegrationTypeRepository(com.epam.ta.reportportal.dao.IntegrationTypeRepository) AbstractAuthResource(com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource) AuthIntegrationStrategy(com.epam.reportportal.auth.integration.handler.impl.strategy.AuthIntegrationStrategy) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) AuthIntegrationStrategyProvider(com.epam.reportportal.auth.integration.provider.AuthIntegrationStrategyProvider) CreateAuthIntegrationHandler(com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler) MutableClientRegistrationRepository(com.epam.reportportal.auth.store.MutableClientRegistrationRepository) IntegrationType(com.epam.ta.reportportal.entity.integration.IntegrationType) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) OAuthProviderFactory(com.epam.reportportal.auth.oauth.OAuthProviderFactory) Service(org.springframework.stereotype.Service) OAuthRegistrationResource(com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource) OAuthRegistration(com.epam.ta.reportportal.entity.oauth.OAuthRegistration)

Example 2 with OAuthRegistration

use of com.epam.ta.reportportal.entity.oauth.OAuthRegistration 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)

Aggregations

OAuthRegistration (com.epam.ta.reportportal.entity.oauth.OAuthRegistration)2 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)2 AuthIntegrationType (com.epam.reportportal.auth.integration.AuthIntegrationType)1 OAuthRegistrationConverters (com.epam.reportportal.auth.integration.converter.OAuthRegistrationConverters)1 CreateAuthIntegrationHandler (com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler)1 AuthIntegrationStrategy (com.epam.reportportal.auth.integration.handler.impl.strategy.AuthIntegrationStrategy)1 AuthIntegrationStrategyProvider (com.epam.reportportal.auth.integration.provider.AuthIntegrationStrategyProvider)1 OAuthProviderFactory (com.epam.reportportal.auth.oauth.OAuthProviderFactory)1 MutableClientRegistrationRepository (com.epam.reportportal.auth.store.MutableClientRegistrationRepository)1 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 IntegrationTypeRepository (com.epam.ta.reportportal.dao.IntegrationTypeRepository)1 Integration (com.epam.ta.reportportal.entity.integration.Integration)1 IntegrationType (com.epam.ta.reportportal.entity.integration.IntegrationType)1 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)1 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)1 AbstractAuthResource (com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource)1 UpdateAuthRQ (com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ)1 OAuthRegistrationResource (com.epam.ta.reportportal.ws.model.settings.OAuthRegistrationResource)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1