use of com.epam.ta.reportportal.entity.integration.Integration in project service-authorization by reportportal.
the class SamlIntegrationStrategy method save.
@Override
protected Integration save(Integration integration) {
populateProviderDetails(integration);
final Integration result = super.save(integration);
eventPublisher.publishEvent(new SamlProvidersReloadEvent(result.getType()));
return result;
}
use of com.epam.ta.reportportal.entity.integration.Integration 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.");
}
use of com.epam.ta.reportportal.entity.integration.Integration 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;
}
use of com.epam.ta.reportportal.entity.integration.Integration 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;
}
use of com.epam.ta.reportportal.entity.integration.Integration 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());
}
Aggregations