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;
}
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);
}
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;
}
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;
}
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());
}
Aggregations