Search in sources :

Example 6 with IntegrationType

use of com.epam.ta.reportportal.entity.integration.IntegrationType 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 7 with IntegrationType

use of com.epam.ta.reportportal.entity.integration.IntegrationType in project service-authorization by reportportal.

the class SamlIntegrationStrategy method updateBasePath.

private void updateBasePath(Integration integration, String basePath) {
    final IntegrationType integrationType = integration.getType();
    final IntegrationTypeDetails typeDetails = ofNullable(integrationType.getDetails()).orElseGet(() -> {
        final IntegrationTypeDetails details = new IntegrationTypeDetails();
        integrationType.setDetails(details);
        return details;
    });
    final Map<String, Object> detailsMapping = ofNullable(typeDetails.getDetails()).orElseGet(() -> {
        final Map<String, Object> details = new HashMap<>();
        typeDetails.setDetails(details);
        return details;
    });
    detailsMapping.put(BASE_PATH.getParameterName(), basePath);
}
Also used : IntegrationTypeDetails(com.epam.ta.reportportal.entity.integration.IntegrationTypeDetails) HashMap(java.util.HashMap) IntegrationType(com.epam.ta.reportportal.entity.integration.IntegrationType)

Example 8 with IntegrationType

use of com.epam.ta.reportportal.entity.integration.IntegrationType 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 9 with IntegrationType

use of com.epam.ta.reportportal.entity.integration.IntegrationType in project service-authorization by reportportal.

the class SamlUserReplicator method replicateUser.

public User replicateUser(ReportPortalSamlAuthentication samlAuthentication) {
    String userName = CROP_DOMAIN.apply(samlAuthentication.getPrincipal());
    Optional<User> userOptional = userRepository.findByLogin(userName);
    if (userOptional.isPresent()) {
        return userOptional.get();
    }
    IntegrationType samlIntegrationType = integrationTypeRepository.findByName(AuthIntegrationType.SAML.getName()).orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND, AuthIntegrationType.SAML.getName()));
    List<Integration> providers = integrationRepository.findAllGlobalByType(samlIntegrationType);
    Optional<Integration> samlProvider = providers.stream().filter(provider -> {
        Optional<String> idpUrlOptional = SamlParameter.IDP_URL.getParameter(provider);
        return idpUrlOptional.isPresent() && idpUrlOptional.get().equalsIgnoreCase(samlAuthentication.getIssuer());
    }).findFirst();
    User user = new User();
    user.setLogin(userName);
    List<Attribute> details = samlAuthentication.getDetails();
    if (samlProvider.isPresent()) {
        populateUserDetailsIfSettingsArePresent(user, samlProvider.get(), details);
    } else {
        populateUserDetails(user, details);
    }
    user.setUserType(UserType.SAML);
    user.setRole(UserRole.USER);
    user.setExpired(false);
    Project project = generatePersonalProject(user);
    user.getProjects().add(project.getUsers().iterator().next());
    user.setMetadata(defaultMetaData());
    userRepository.save(user);
    return user;
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) PersonalProjectService(com.epam.ta.reportportal.util.PersonalProjectService) Autowired(org.springframework.beans.factory.annotation.Autowired) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) IntegrationType(com.epam.ta.reportportal.entity.integration.IntegrationType) UserRole(com.epam.ta.reportportal.entity.user.UserRole) IntegrationRepository(com.epam.ta.reportportal.dao.IntegrationRepository) UserType(com.epam.ta.reportportal.entity.user.UserType) AbstractUserReplicator(com.epam.reportportal.auth.integration.AbstractUserReplicator) ContentTypeResolver(com.epam.reportportal.commons.ContentTypeResolver) AuthIntegrationType(com.epam.reportportal.auth.integration.AuthIntegrationType) User(com.epam.ta.reportportal.entity.user.User) Integration(com.epam.ta.reportportal.entity.integration.Integration) UserRepository(com.epam.ta.reportportal.dao.UserRepository) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IntegrationTypeRepository(com.epam.ta.reportportal.dao.IntegrationTypeRepository) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Component(org.springframework.stereotype.Component) List(java.util.List) ProjectRepository(com.epam.ta.reportportal.dao.ProjectRepository) CollectionUtils(org.springframework.util.CollectionUtils) Optional(java.util.Optional) UserBinaryDataService(com.epam.ta.reportportal.binary.UserBinaryDataService) CROP_DOMAIN(com.epam.reportportal.auth.util.AuthUtils.CROP_DOMAIN) SamlParameter(com.epam.reportportal.auth.integration.parameter.SamlParameter) Transactional(org.springframework.transaction.annotation.Transactional) Integration(com.epam.ta.reportportal.entity.integration.Integration) User(com.epam.ta.reportportal.entity.user.User) Optional(java.util.Optional) Project(com.epam.ta.reportportal.entity.project.Project) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IntegrationType(com.epam.ta.reportportal.entity.integration.IntegrationType) AuthIntegrationType(com.epam.reportportal.auth.integration.AuthIntegrationType)

Example 10 with IntegrationType

use of com.epam.ta.reportportal.entity.integration.IntegrationType in project commons-dao by reportportal.

the class IntegrationRepositoryTest method shouldFindAllByProjectIdAndIntegrationTypeWhenExists.

@Test
void shouldFindAllByProjectIdAndIntegrationTypeWhenExists() {
    IntegrationType integrationType = integrationTypeRepository.findById(JIRA_INTEGRATION_TYPE_ID).get();
    List<Integration> integrations = integrationRepository.findAllByProjectIdAndType(DEFAULT_PERSONAL_PROJECT_ID, integrationType);
    assertNotNull(integrations);
    assertEquals(1L, integrations.size());
}
Also used : Integration(com.epam.ta.reportportal.entity.integration.Integration) IntegrationType(com.epam.ta.reportportal.entity.integration.IntegrationType) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

IntegrationType (com.epam.ta.reportportal.entity.integration.IntegrationType)13 Integration (com.epam.ta.reportportal.entity.integration.Integration)8 AuthIntegrationType (com.epam.reportportal.auth.integration.AuthIntegrationType)6 BaseTest (com.epam.ta.reportportal.BaseTest)5 Test (org.junit.jupiter.api.Test)5 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)4 AuthIntegrationStrategy (com.epam.reportportal.auth.integration.handler.impl.strategy.AuthIntegrationStrategy)2 AbstractUserReplicator (com.epam.reportportal.auth.integration.AbstractUserReplicator)1 SamlParameter (com.epam.reportportal.auth.integration.parameter.SamlParameter)1 CROP_DOMAIN (com.epam.reportportal.auth.util.AuthUtils.CROP_DOMAIN)1 ContentTypeResolver (com.epam.reportportal.commons.ContentTypeResolver)1 UserBinaryDataService (com.epam.ta.reportportal.binary.UserBinaryDataService)1 IntegrationRepository (com.epam.ta.reportportal.dao.IntegrationRepository)1 IntegrationTypeRepository (com.epam.ta.reportportal.dao.IntegrationTypeRepository)1 ProjectRepository (com.epam.ta.reportportal.dao.ProjectRepository)1 UserRepository (com.epam.ta.reportportal.dao.UserRepository)1 IntegrationTypeDetails (com.epam.ta.reportportal.entity.integration.IntegrationTypeDetails)1 Project (com.epam.ta.reportportal.entity.project.Project)1 User (com.epam.ta.reportportal.entity.user.User)1 UserRole (com.epam.ta.reportportal.entity.user.UserRole)1