Search in sources :

Example 31 with ReportPortalException

use of com.epam.ta.reportportal.exception.ReportPortalException in project service-authorization by reportportal.

the class GetSamlIntegrationsStrategy method getIntegration.

@Override
public AbstractAuthResource getIntegration() {
    IntegrationType samlIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.SAML.getName()).orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND, AuthIntegrationType.SAML.getName()));
    List<Integration> providers = integrationRepository.findAllGlobalByType(samlIntegrationType);
    SamlProvidersResource resource = TO_PROVIDERS_RESOURCE.apply(providers);
    resource.setType(samlIntegrationType.getName());
    return resource;
}
Also used : Integration(com.epam.ta.reportportal.entity.integration.Integration) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) SamlProvidersResource(com.epam.ta.reportportal.ws.model.integration.auth.SamlProvidersResource) AuthIntegrationType(com.epam.reportportal.auth.integration.AuthIntegrationType) IntegrationType(com.epam.ta.reportportal.entity.integration.IntegrationType)

Example 32 with ReportPortalException

use of com.epam.ta.reportportal.exception.ReportPortalException in project service-authorization by reportportal.

the class GetLdapStrategy method getIntegration.

@Override
public AbstractLdapResource getIntegration() {
    IntegrationType ldapIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.LDAP.getName()).orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND, AuthIntegrationType.LDAP.getName()));
    // or else empty integration with default 'enabled = false' flag
    LdapResource ldapResource = LdapConverter.TO_RESOURCE.apply(integrationRepository.findByNameAndTypeIdAndProjectIdIsNull(AuthIntegrationType.LDAP.getName(), ldapIntegrationType.getId()).orElseGet(Integration::new));
    ldapResource.setType(ldapIntegrationType.getName());
    return ldapResource;
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) AbstractLdapResource(com.epam.ta.reportportal.ws.model.integration.auth.AbstractLdapResource) LdapResource(com.epam.ta.reportportal.ws.model.integration.auth.LdapResource) AuthIntegrationType(com.epam.reportportal.auth.integration.AuthIntegrationType) IntegrationType(com.epam.ta.reportportal.entity.integration.IntegrationType)

Example 33 with ReportPortalException

use of com.epam.ta.reportportal.exception.ReportPortalException in project service-authorization by reportportal.

the class OAuthSuccessHandler method getToken.

@Override
protected OAuth2AccessToken getToken(Authentication authentication) {
    OAuth2Authentication oAuth2Authentication = ofNullable((OAuth2Authentication) authentication).orElseThrow(() -> new ReportPortalException(ErrorType.ACCESS_DENIED));
    String login = String.valueOf(oAuth2Authentication.getPrincipal());
    return tokenServicesFacade.get().createToken(ReportPortalClient.ui, normalizeId(login), authentication, ofNullable(oAuth2Authentication.getOAuth2Request()).map(OAuth2Request::getExtensions).orElseGet(Collections::emptyMap));
}
Also used : OAuth2Request(org.springframework.security.oauth2.provider.OAuth2Request) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) OAuth2Authentication(org.springframework.security.oauth2.provider.OAuth2Authentication)

Aggregations

ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)33 Test (org.junit.jupiter.api.Test)7 InputStream (java.io.InputStream)6 AuthIntegrationType (com.epam.reportportal.auth.integration.AuthIntegrationType)5 BaseTest (com.epam.ta.reportportal.BaseTest)5 ClassPathResource (org.springframework.core.io.ClassPathResource)5 Integration (com.epam.ta.reportportal.entity.integration.Integration)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 IntegrationType (com.epam.ta.reportportal.entity.integration.IntegrationType)3 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)3 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)3 Filter (com.epam.ta.reportportal.commons.querygen.Filter)2 QueryBuilder (com.epam.ta.reportportal.commons.querygen.QueryBuilder)2 ID (com.epam.ta.reportportal.dao.constant.WidgetRepositoryConstants.ID)2 JooqFieldNameTransformer.fieldName (com.epam.ta.reportportal.dao.util.JooqFieldNameTransformer.fieldName)2 QueryUtils (com.epam.ta.reportportal.dao.util.QueryUtils)2 ServerSettings (com.epam.ta.reportportal.database.entity.settings.ServerSettings)2 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)2 Log (com.epam.ta.reportportal.entity.log.Log)2 JStatusEnum (com.epam.ta.reportportal.jooq.enums.JStatusEnum)2